Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
uw_ct_profile
Manage
Activity
Members
Labels
Code
Merge requests
1
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_profile
Commits
f59ce836
Commit
f59ce836
authored
3 years ago
by
Chris Shantz
Browse files
Options
Downloads
Plain Diff
Merge branch '1.0.x' into prod/1.0.x
parents
8425aa43
f5460df4
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
config/install/core.entity_view_display.node.uw_ct_profile.default.yml
+9
-221
9 additions, 221 deletions
...l/core.entity_view_display.node.uw_ct_profile.default.yml
uw_ct_profile.install
+140
-0
140 additions, 0 deletions
uw_ct_profile.install
with
149 additions
and
221 deletions
config/install/core.entity_view_display.node.uw_ct_profile.default.yml
+
9
−
221
View file @
f59ce836
...
...
@@ -19,7 +19,6 @@ dependencies:
module
:
-
layout_builder
-
layout_builder_restrictions
-
layout_discovery
-
link
-
metatag
-
text
...
...
@@ -30,228 +29,17 @@ third_party_settings:
enabled
:
true
sections
:
-
layout_id
:
layout_onecol
layout_id
:
uw_1_column
layout_settings
:
label
:
'
'
components
:
0f0aa3c2-e8e0-450d-ae9e-eb1236beb93b
:
uuid
:
0f0aa3c2-e8e0-450d-ae9e-eb1236beb93b
region
:
content
configuration
:
label_display
:
'
0'
context_mapping
:
entity
:
layout_builder.entity
id
:
'
extra_field_block:node:uw_ct_profile:content_moderation_control'
additional
:
{
}
weight
:
0
5dff8854-8cd7-4aac-b4b2-e3d94aa774f0
:
uuid
:
5dff8854-8cd7-4aac-b4b2-e3d94aa774f0
region
:
content
configuration
:
label_display
:
'
0'
context_mapping
:
entity
:
layout_builder.entity
id
:
'
extra_field_block:node:uw_ct_profile:links'
additional
:
{
}
weight
:
1
df906141-92a5-438e-aa7f-46a5a99ea210
:
uuid
:
df906141-92a5-438e-aa7f-46a5a99ea210
region
:
content
configuration
:
label_display
:
'
0'
context_mapping
:
entity
:
layout_builder.entity
id
:
'
field_block:node:uw_ct_profile:field_uw_ct_profile_contact'
formatter
:
label
:
above
settings
:
link
:
true
third_party_settings
:
{
}
type
:
entity_reference_label
additional
:
{
}
weight
:
2
e6b7394a-2ca7-4884-961a-93d068bd8042
:
uuid
:
e6b7394a-2ca7-4884-961a-93d068bd8042
region
:
content
configuration
:
label_display
:
'
0'
context_mapping
:
entity
:
layout_builder.entity
id
:
'
field_block:node:uw_ct_profile:field_uw_ct_profile_sort_name'
formatter
:
label
:
above
settings
:
link_to_entity
:
false
third_party_settings
:
{
}
type
:
string
additional
:
{
}
weight
:
3
81786680-092f-46e1-a584-045e022886ee
:
uuid
:
81786680-092f-46e1-a584-045e022886ee
region
:
content
configuration
:
label_display
:
'
0'
context_mapping
:
entity
:
layout_builder.entity
id
:
'
field_block:node:uw_ct_profile:field_uw_ct_profile_image'
formatter
:
type
:
entity_reference_entity_view
label
:
above
settings
:
view_mode
:
default
link
:
false
third_party_settings
:
{
}
additional
:
{
}
weight
:
4
36ed29a8-e565-4626-acc1-629e7a92bab1
:
uuid
:
36ed29a8-e565-4626-acc1-629e7a92bab1
region
:
content
configuration
:
label_display
:
'
0'
context_mapping
:
entity
:
layout_builder.entity
id
:
'
field_block:node:uw_ct_profile:field_uw_ct_profile_affiliation'
formatter
:
label
:
above
settings
:
link_to_entity
:
false
third_party_settings
:
{
}
type
:
string
additional
:
{
}
weight
:
5
c72e8bf2-a041-4f0a-9c5f-63197945f525
:
uuid
:
c72e8bf2-a041-4f0a-9c5f-63197945f525
region
:
content
configuration
:
label_display
:
'
0'
context_mapping
:
entity
:
layout_builder.entity
id
:
'
field_block:node:uw_ct_profile:field_uw_ct_profile_title'
formatter
:
label
:
above
settings
:
link_to_entity
:
false
third_party_settings
:
{
}
type
:
string
additional
:
{
}
weight
:
6
9f76eb46-312d-4557-a236-e0263755692d
:
uuid
:
9f76eb46-312d-4557-a236-e0263755692d
region
:
content
configuration
:
label_display
:
'
0'
context_mapping
:
entity
:
layout_builder.entity
id
:
'
field_block:node:uw_ct_profile:field_uw_ct_profile_info_link'
formatter
:
label
:
above
settings
:
trim_length
:
80
url_only
:
false
url_plain
:
false
rel
:
'
'
target
:
'
'
third_party_settings
:
{
}
type
:
link
additional
:
{
}
weight
:
7
1ae0861a-7118-4b53-af86-244f12b4009d
:
uuid
:
1ae0861a-7118-4b53-af86-244f12b4009d
region
:
content
configuration
:
label_display
:
'
0'
context_mapping
:
entity
:
layout_builder.entity
id
:
'
field_block:node:uw_ct_profile:field_uw_ct_profile_link_persona'
formatter
:
label
:
above
settings
:
trim_length
:
80
url_only
:
false
url_plain
:
false
rel
:
'
'
target
:
'
'
third_party_settings
:
{
}
type
:
link
additional
:
{
}
weight
:
8
d12b807e-79b2-4f6a-b66e-d59a0df9a3e6
:
uuid
:
d12b807e-79b2-4f6a-b66e-d59a0df9a3e6
region
:
content
configuration
:
label_display
:
'
0'
context_mapping
:
entity
:
layout_builder.entity
id
:
'
field_block:node:uw_ct_profile:field_uw_ct_profile_type'
formatter
:
label
:
above
settings
:
link
:
true
third_party_settings
:
{
}
type
:
entity_reference_label
additional
:
{
}
weight
:
9
f8caa792-d1f3-4426-bfa3-7be4e4eb6647
:
uuid
:
f8caa792-d1f3-4426-bfa3-7be4e4eb6647
region
:
content
configuration
:
label_display
:
'
0'
context_mapping
:
entity
:
layout_builder.entity
id
:
'
field_block:node:uw_ct_profile:field_uw_meta_tags'
formatter
:
label
:
above
settings
:
{
}
third_party_settings
:
{
}
type
:
metatag_empty_formatter
additional
:
{
}
weight
:
10
16bda8ea-47c5-48b1-9594-13c7b124812a
:
uuid
:
16bda8ea-47c5-48b1-9594-13c7b124812a
region
:
content
configuration
:
label_display
:
'
0'
context_mapping
:
entity
:
layout_builder.entity
id
:
'
field_block:node:uw_ct_profile:field_uw_meta_image'
formatter
:
label
:
above
settings
:
link
:
true
third_party_settings
:
{
}
type
:
entity_reference_label
additional
:
{
}
weight
:
11
2895e4ca-6383-438b-bb9a-7703af1e0518
:
uuid
:
2895e4ca-6383-438b-bb9a-7703af1e0518
region
:
content
configuration
:
label_display
:
'
0'
context_mapping
:
entity
:
layout_builder.entity
id
:
'
field_block:node:uw_ct_profile:field_uw_meta_description'
formatter
:
label
:
above
settings
:
{
}
third_party_settings
:
{
}
type
:
basic_string
additional
:
{
}
weight
:
12
7589756f-fe12-401f-9499-44f8495ddbe8
:
uuid
:
7589756f-fe12-401f-9499-44f8495ddbe8
region
:
content
configuration
:
label_display
:
'
0'
context_mapping
:
entity
:
layout_builder.entity
id
:
'
field_block:node:uw_ct_profile:field_uw_profile_summary'
formatter
:
label
:
above
settings
:
{
}
third_party_settings
:
{
}
type
:
text_default
additional
:
{
}
weight
:
13
layout_builder_styles_style
:
uw_lbs_contained_width
expand_collapse
:
setting
:
0
heading_selector
:
h2
group
:
other
group_title
:
'
'
layout_builder_id
:
'
'
components
:
{
}
third_party_settings
:
{
}
layout_builder_restrictions
:
allowed_block_categories
:
{
}
...
...
This diff is collapsed.
Click to expand it.
uw_ct_profile.install
0 → 100644
+
140
−
0
View file @
f59ce836
<?php
/**
* @file
* Install, update and uninstall for profiles.
*/
use
Drupal\node\Entity\Node
;
/**
* Removes all the node fields from the layout.
*/
function
uw_ct_profile_update_8101
(
&
$sandbox
)
{
// The list of components/blocks to be removed.
$components_to_remove
=
[
'extra_field_block:node:uw_ct_profile:content_moderation_control'
,
'extra_field_block:node:uw_ct_profile:links'
,
'field_block:node:uw_ct_profile:field_uw_ct_profile_contact'
,
'field_block:node:uw_ct_profile:field_uw_ct_profile_sort_name'
,
'field_block:node:uw_ct_profile:field_uw_ct_profile_image'
,
'field_block:node:uw_ct_profile:field_uw_ct_profile_affiliation'
,
'field_block:node:uw_ct_profile:field_uw_ct_profile_title'
,
'field_block:node:uw_ct_profile:field_uw_ct_profile_info_link'
,
'field_block:node:uw_ct_profile:field_uw_ct_profile_link_persona'
,
'field_block:node:uw_ct_profile:field_uw_ct_profile_type'
,
'field_block:node:uw_ct_profile:field_uw_meta_tags'
,
'field_block:node:uw_ct_profile:field_uw_meta_image'
,
'field_block:node:uw_ct_profile:field_uw_meta_description'
,
'field_block:node:uw_ct_profile:field_uw_profile_summary'
,
];
// Get all the nids for profiles.
$nids
=
\Drupal
::
entityQuery
(
'node'
)
->
condition
(
'type'
,
'uw_ct_profile'
)
->
execute
();
// Load all the contact nodes.
$nodes
=
Node
::
loadMultiple
(
$nids
);
// Step through each of the nodes and remove the sections
// that were locked in fields before. This will only remove
// the layouts for the current revision.
foreach
(
$nodes
as
$node
)
{
// Load the sections.
$sections
=
$node
->
get
(
'layout_builder__layout'
)
->
getSections
();
// Step through each of the sections and load the components
// and see if it needs to be removed.
foreach
(
$sections
as
$section_id
=>
$section
)
{
// Get the components for the section.
$components
=
$section
->
getComponents
();
// Step through each of the components and see if it needs
// to be removed.
foreach
(
$components
as
$id
=>
$component
)
{
// Get the configuration for the component which will have
// the uuid.
$config
=
$component
->
get
(
'configuration'
);
// If the uuid is in the list of components to be removed,
// then remove that component.
if
(
in_array
(
$config
[
'id'
],
$components_to_remove
))
{
$sections
[
$section_id
]
->
removeComponent
(
$id
);
}
}
}
// Set the new value of the sections, with the removed
// components and save the node.
$node
->
layout_builder__layout
->
setValue
(
$sections
);
$node
->
save
();
// Get the node id from the node object.
$nid
=
$node
->
id
();
// Get all the revisions for the nid.
$query
=
\Drupal
::
database
()
->
select
(
'node_revision'
,
'nr'
);
$query
->
addField
(
'nr'
,
'vid'
);
$query
->
condition
(
'nr.nid'
,
$nid
);
$revisions
=
$query
->
execute
()
->
fetchAll
();
// Step through each of the revisions and remove the sections.
foreach
(
$revisions
as
$revision
)
{
// Get the vid.
$vid
=
$revision
->
vid
;
// Get all the sections for the revision.
$query
=
\Drupal
::
database
()
->
select
(
'node_revision__layout_builder__layout'
,
'nrlbl'
);
$query
->
addField
(
'nrlbl'
,
'layout_builder__layout_section'
);
$query
->
addField
(
'nrlbl'
,
'delta'
);
$query
->
condition
(
'nrlbl.entity_id'
,
$nid
);
$query
->
condition
(
'nrlbl.revision_id'
,
$vid
);
$sections
=
$query
->
execute
()
->
fetchAll
();
// If the sections are not empty, remove fields from layout.
if
(
!
empty
(
$sections
))
{
// Step through each section and remove fields.
foreach
(
$sections
as
$section
)
{
// Get the section object.
$section_info
=
unserialize
(
$section
->
layout_builder__layout_section
);
// Get the components for the section.
$components
=
$section_info
->
getComponents
();
// Step through each of the components and see if it needs
// to be removed.
foreach
(
$components
as
$id
=>
$component
)
{
// Get the configuration for the component which will have
// the uuid.
$config
=
$component
->
get
(
'configuration'
);
// If the uuid is in the list of components to be removed,
// then remove that component.
if
(
in_array
(
$config
[
'id'
],
$components_to_remove
))
{
$section_info
->
removeComponent
(
$id
);
}
}
// Update query to remove components.
$query
=
\Drupal
::
database
()
->
update
(
'node_revision__layout_builder__layout'
)
->
fields
(
[
'layout_builder__layout_section'
=>
serialize
(
$section_info
),
]
)
->
condition
(
'entity_id'
,
$nid
)
->
condition
(
'revision_id'
,
$vid
)
->
condition
(
'delta'
,
$section
->
delta
)
->
execute
();
}
}
}
}
}
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