Skip to content
Snippets Groups Projects
Commit 869507b1 authored by Chris Shantz's avatar Chris Shantz
Browse files

Merge branch '1.0.x' into prod/1.0.x

parents a5153009 c92f8ba9
No related branches found
No related tags found
No related merge requests found
......@@ -158,7 +158,8 @@ class UwCtSidebarEventSubscriber extends UwCblBase implements EventSubscriberInt
if ($node->field_uw_attach_page->entity) {
// Set the title of sidebar to be the title of the node reference.
$node->setTitle($node->field_uw_attach_page->entity->getTitle() . ' (sidebar)');
$title = $this->t('@node_title (sidebar)', ['@node_title' => $node->field_uw_attach_page->entity->getTitle()]);
$node->setTitle($title);
}
}
......@@ -175,6 +176,9 @@ class UwCtSidebarEventSubscriber extends UwCblBase implements EventSubscriberInt
// Get the values from the form_state.
$values = $form_state->getValues();
// Define entity id.
$entity_id = 0;
// If the entity reference is not empty, meaning that there is an
// entity entered, then ensure that we can add that entity.
if (!empty($values['field_uw_attach_page'][0]['target_id'])) {
......@@ -186,11 +190,17 @@ class UwCtSidebarEventSubscriber extends UwCblBase implements EventSubscriberInt
// Sidebar node path is like '/node/100'.
$sidebar_node_path = $values['path'][0]['source'];
// Get node id from sidebar node path.
$sidebar_nid = substr($sidebar_node_path, 6);
// See function declaration for what is returned in this function call.
$entity_id = $this->uwService->getOrCheckAttachedSidebar($attached_page_nid, $sidebar_nid, 'check');
// Make sure sidebar node path is not empty due to
// substr(): Passing null to parameter #1 ($string)
// of type string is deprecated.
if (!empty($sidebar_node_path)) {
// Get node id from sidebar node path.
$sidebar_nid = substr($sidebar_node_path, 6);
if (!is_null($sidebar_nid)) {
// See function declaration for what is returned in function call.
$entity_id = $this->uwService->getOrCheckAttachedSidebar($attached_page_nid, $sidebar_nid, 'check');
}
}
// If the entity_id is greater than 0, means that the attached_page_nid
// is already attached to some other sidebar, then display an error.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment