Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
WCMS
uw_ct_contact
Commits
21731493
Commit
21731493
authored
Jun 18, 2021
by
Chris Shantz
Browse files
Merge branch '1.0.x' into prod/1.0.x
parents
c1231b57
31e56c75
Changes
2
Hide whitespace changes
Inline
Side-by-side
config/install/core.entity_view_display.node.uw_ct_contact.default.yml
View file @
21731493
...
...
@@ -25,7 +25,6 @@ dependencies:
module
:
-
layout_builder
-
layout_builder_restrictions
-
layout_discovery
-
link
-
metatag
-
options
...
...
@@ -37,264 +36,17 @@ third_party_settings:
enabled
:
true
sections
:
-
layout_id
:
layout_onecol
layout_id
:
uw_1_column
layout_settings
:
label
:
'
'
components
:
f8261f1e-fe7c-43d0-9566-708524c34ddc
:
uuid
:
f8261f1e-fe7c-43d0-9566-708524c34ddc
region
:
content
configuration
:
label_display
:
'
0'
context_mapping
:
entity
:
layout_builder.entity
id
:
'
extra_field_block:node:uw_ct_contact:links'
additional
:
{
}
weight
:
0
6c850174-9fdc-4b58-ad65-428c56046ca0
:
uuid
:
6c850174-9fdc-4b58-ad65-428c56046ca0
region
:
content
configuration
:
label_display
:
'
0'
context_mapping
:
entity
:
layout_builder.entity
id
:
'
field_block:node:uw_ct_contact:field_uw_ct_contact_watiam_id'
formatter
:
label
:
above
settings
:
link_to_entity
:
false
third_party_settings
:
{
}
type
:
string
additional
:
{
}
weight
:
1
4e53e503-840c-438f-b446-c6cbdc040ae5
:
uuid
:
4e53e503-840c-438f-b446-c6cbdc040ae5
region
:
content
configuration
:
label_display
:
'
0'
context_mapping
:
entity
:
layout_builder.entity
id
:
'
field_block:node:uw_ct_contact:field_uw_ct_contact_method'
formatter
:
label
:
above
settings
:
{
}
third_party_settings
:
{
}
type
:
list_default
additional
:
{
}
weight
:
2
eeaec06e-d062-4780-83b2-3c657fdfdb6f
:
uuid
:
eeaec06e-d062-4780-83b2-3c657fdfdb6f
region
:
content
configuration
:
label_display
:
'
0'
context_mapping
:
entity
:
layout_builder.entity
id
:
'
field_block:node:uw_ct_contact:field_uw_ct_contact_fields'
formatter
:
label
:
above
settings
:
{
}
third_party_settings
:
{
}
type
:
list_default
additional
:
{
}
weight
:
3
fe0cbec5-d988-4332-882a-a4ce4f079ec7
:
uuid
:
fe0cbec5-d988-4332-882a-a4ce4f079ec7
region
:
content
configuration
:
label_display
:
'
0'
context_mapping
:
entity
:
layout_builder.entity
id
:
'
field_block:node:uw_ct_contact:field_uw_ct_contact_image'
formatter
:
type
:
entity_reference_entity_view
label
:
above
settings
:
view_mode
:
default
link
:
false
third_party_settings
:
{
}
additional
:
{
}
weight
:
4
b71813c0-d98d-4c99-bb49-52b2237fc4d3
:
uuid
:
b71813c0-d98d-4c99-bb49-52b2237fc4d3
region
:
content
configuration
:
label_display
:
'
0'
context_mapping
:
entity
:
layout_builder.entity
id
:
'
field_block:node:uw_ct_contact:field_uw_ct_contact_sort_name'
formatter
:
label
:
above
settings
:
link_to_entity
:
false
third_party_settings
:
{
}
type
:
string
additional
:
{
}
weight
:
5
36518197-d7f5-4617-8900-d17bc6cd0aa7
:
uuid
:
36518197-d7f5-4617-8900-d17bc6cd0aa7
region
:
content
configuration
:
label_display
:
'
0'
context_mapping
:
entity
:
layout_builder.entity
id
:
'
field_block:node:uw_ct_contact:field_uw_ct_contact_group'
formatter
:
label
:
above
settings
:
link
:
true
third_party_settings
:
{
}
type
:
entity_reference_label
additional
:
{
}
weight
:
6
52632676-8730-4480-a83b-83953def5a89
:
uuid
:
52632676-8730-4480-a83b-83953def5a89
region
:
content
configuration
:
label_display
:
'
0'
context_mapping
:
entity
:
layout_builder.entity
id
:
'
field_block:node:uw_ct_contact:field_uw_ct_contact_affiliation'
formatter
:
label
:
above
settings
:
link_to_entity
:
false
third_party_settings
:
{
}
type
:
string
additional
:
{
}
weight
:
7
2c58b590-59ad-4439-b2e6-c00ad9ae13ae
:
uuid
:
2c58b590-59ad-4439-b2e6-c00ad9ae13ae
region
:
content
configuration
:
label_display
:
'
0'
context_mapping
:
entity
:
layout_builder.entity
id
:
'
field_block:node:uw_ct_contact:field_uw_ct_contact_title'
formatter
:
label
:
above
settings
:
link_to_entity
:
false
third_party_settings
:
{
}
type
:
string
additional
:
{
}
weight
:
8
e9e9bd33-aa7a-4006-ac5a-579550fe5e8f
:
uuid
:
e9e9bd33-aa7a-4006-ac5a-579550fe5e8f
region
:
content
configuration
:
label_display
:
'
0'
context_mapping
:
entity
:
layout_builder.entity
id
:
'
field_block:node:uw_ct_contact:field_uw_ct_contact_email'
formatter
:
label
:
above
settings
:
{
}
third_party_settings
:
{
}
type
:
basic_string
additional
:
{
}
weight
:
9
88cbc5aa-9a0e-4a76-82f9-1faf53f89437
:
uuid
:
88cbc5aa-9a0e-4a76-82f9-1faf53f89437
region
:
content
configuration
:
label_display
:
'
0'
context_mapping
:
entity
:
layout_builder.entity
id
:
'
field_block:node:uw_ct_contact:field_uw_ct_contact_phone'
formatter
:
label
:
above
settings
:
{
}
third_party_settings
:
{
}
type
:
basic_string
additional
:
{
}
weight
:
10
348344ab-8442-4ee8-b944-d4feef0fb115
:
uuid
:
348344ab-8442-4ee8-b944-d4feef0fb115
region
:
content
configuration
:
label_display
:
'
0'
context_mapping
:
entity
:
layout_builder.entity
id
:
'
field_block:node:uw_ct_contact:field_uw_ct_contact_location'
formatter
:
label
:
above
settings
:
link_to_entity
:
false
third_party_settings
:
{
}
type
:
string
additional
:
{
}
weight
:
11
f1a68099-81e0-4df9-9071-c8e032a030f7
:
uuid
:
f1a68099-81e0-4df9-9071-c8e032a030f7
region
:
content
configuration
:
label_display
:
'
0'
context_mapping
:
entity
:
layout_builder.entity
id
:
'
field_block:node:uw_ct_contact:field_uw_ct_contact_contact_for'
formatter
:
label
:
above
settings
:
link_to_entity
:
false
third_party_settings
:
{
}
type
:
string
additional
:
{
}
weight
:
12
fca6bbda-9a49-422c-8285-f15109ac40df
:
uuid
:
fca6bbda-9a49-422c-8285-f15109ac40df
region
:
content
configuration
:
label_display
:
'
0'
context_mapping
:
entity
:
layout_builder.entity
id
:
'
field_block:node:uw_ct_contact:field_uw_ct_contact_info'
formatter
:
label
:
above
settings
:
{
}
third_party_settings
:
{
}
type
:
text_default
additional
:
{
}
weight
:
13
13087c47-018b-4fa1-9d88-7047ea1f9319
:
uuid
:
13087c47-018b-4fa1-9d88-7047ea1f9319
region
:
content
configuration
:
label_display
:
'
0'
context_mapping
:
entity
:
layout_builder.entity
id
:
'
field_block:node:uw_ct_contact:field_uw_ct_contact_link_profile'
formatter
:
label
:
above
settings
:
trim_length
:
80
url_only
:
false
url_plain
:
false
rel
:
'
'
target
:
'
'
third_party_settings
:
{
}
type
:
link
additional
:
{
}
weight
:
14
e1bd7cf8-ca13-4c37-8dc8-bcaeb348ec3e
:
uuid
:
e1bd7cf8-ca13-4c37-8dc8-bcaeb348ec3e
region
:
content
configuration
:
label_display
:
'
0'
context_mapping
:
entity
:
layout_builder.entity
id
:
'
field_block:node:uw_ct_contact:field_uw_ct_contact_link_persona'
formatter
:
label
:
above
settings
:
trim_length
:
80
url_only
:
false
url_plain
:
false
rel
:
'
'
target
:
'
'
third_party_settings
:
{
}
type
:
link
additional
:
{
}
weight
:
15
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
:
{
}
...
...
uw_ct_contact.install
0 → 100644
View file @
21731493
<?php
/**
* @file
* Install, update and uninstall for contacts.
*/
use
Drupal\node\Entity\Node
;
/**
* Removes all the node fields from the layout.
*/
function
uw_ct_contact_update_8101
(
&
$sandbox
)
{
// The list of components/blocks to be removed.
$components_to_remove
=
[
'extra_field_block:node:uw_ct_contact:links'
,
'extra_field_block:node:uw_ct_contact:links'
,
'field_block:node:uw_ct_contact:field_uw_ct_contact_watiam_id'
,
'field_block:node:uw_ct_contact:field_uw_ct_contact_method'
,
'field_block:node:uw_ct_contact:field_uw_ct_contact_fields'
,
'field_block:node:uw_ct_contact:field_uw_ct_contact_image'
,
'field_block:node:uw_ct_contact:field_uw_ct_contact_sort_name'
,
'field_block:node:uw_ct_contact:field_uw_ct_contact_group'
,
'field_block:node:uw_ct_contact:field_uw_ct_contact_affiliation'
,
'field_block:node:uw_ct_contact:field_uw_ct_contact_title'
,
'field_block:node:uw_ct_contact:field_uw_ct_contact_email'
,
'field_block:node:uw_ct_contact:field_uw_ct_contact_phone'
,
'field_block:node:uw_ct_contact:field_uw_ct_contact_location'
,
'field_block:node:uw_ct_contact:field_uw_ct_contact_contact_for'
,
'field_block:node:uw_ct_contact:field_uw_ct_contact_info'
,
'field_block:node:uw_ct_contact:field_uw_ct_contact_link_profile'
,
'field_block:node:uw_ct_contact:field_uw_ct_contact_link_persona'
,
];
// Get all the nids for contacts.
$nids
=
\
Drupal
::
entityQuery
(
'node'
)
->
condition
(
'type'
,
'uw_ct_contact'
)
->
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
();
}
}
}
}
}
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment