Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uw_ct_sidebar
Manage
Activity
Members
Labels
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WCMS
uw_ct_sidebar
Commits
869507b1
Commit
869507b1
authored
1 year ago
by
Chris Shantz
Browse files
Options
Downloads
Plain Diff
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
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/EventSubscriber/UwCtSidebarEventSubscriber.php
+16
-6
16 additions, 6 deletions
src/EventSubscriber/UwCtSidebarEventSubscriber.php
with
16 additions
and
6 deletions
src/EventSubscriber/UwCtSidebarEventSubscriber.php
+
16
−
6
View file @
869507b1
...
...
@@ -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.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment