Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
custom_elements
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
custom_elements
Commits
f8bc25b8
Commit
f8bc25b8
authored
May 10, 2019
by
Wolfgang Ziegler
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3053803
: Fix extra fields to be rendered via layout builder.
parent
09c3b277
Branches
Branches containing commit
Tags
8.x-2.0-alpha3
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
custom_elements.install
+24
-0
24 additions, 0 deletions
custom_elements.install
custom_elements.module
+16
-0
16 additions, 0 deletions
custom_elements.module
src/CustomElementsEntityViewDisplayTrait.php
+4
-3
4 additions, 3 deletions
src/CustomElementsEntityViewDisplayTrait.php
with
44 additions
and
3 deletions
custom_elements.install
0 → 100644
+
24
−
0
View file @
f8bc25b8
<?php
/**
* @file
* Module install file.
*/
/**
* Implements hook_install().
*/
function
custom_elements_install
()
{
// Make sure our module comes after layout_builder.
// @see custom_elements_module_implements_alter().
module_set_weight
(
'custom_elements'
,
10
);
}
/**
* Set module weight.
*/
function
custom_elements_update_8201
()
{
// Make sure our module comes after layout_builder.
// @see custom_elements_module_implements_alter().
module_set_weight
(
'custom_elements'
,
10
);
}
This diff is collapsed.
Click to expand it.
custom_elements.module
+
16
−
0
View file @
f8bc25b8
...
...
@@ -76,6 +76,14 @@ function custom_elements_module_implements_alter(&$implementations, $hook) {
unset
(
$implementations
[
'custom_elements'
]);
$implementations
[
'custom_elements'
]
=
$group
;
}
// Be sure our entity_view_alter hook comes last, even after layout builder
// which also tries to make it come last.
// @see custom_elements_install().
if
(
$hook
===
'entity_view_alter'
)
{
$group
=
$implementations
[
'custom_elements'
];
unset
(
$implementations
[
'custom_elements'
]);
$implementations
[
'custom_elements'
]
=
$group
;
}
}
/**
...
...
@@ -95,5 +103,13 @@ function custom_elements_entity_view_alter(array &$build, Drupal\Core\Entity\Ent
// Alter the build array to apply custom elements rendering.
if
(
!
empty
(
$build
[
'#custom_elements_enabled'
]))
{
$build
[
'#theme'
]
=
'custom_element'
;
// Add layout builder sections, but be sure to do so once extra fields
// were added by layout_builder_entity_view_alter()
// @see custom_elements_module_implements_alter().
// @see \Drupal\custom_elements\CustomElementsEntityViewDisplayTrait::buildMultipleViaCustomElements()
if
(
!
empty
(
$build
[
'#custom_elements_add_layout_builder_section'
]))
{
$build
[
'#custom_element'
]
->
setSlot
(
'sections'
,
$build
[
'_layout_builder'
]);
}
}
}
This diff is collapsed.
Click to expand it.
src/CustomElementsEntityViewDisplayTrait.php
+
4
−
3
View file @
f8bc25b8
...
...
@@ -31,9 +31,10 @@ trait CustomElementsEntityViewDisplayTrait {
$build
[
'#view_mode'
]
=
$this
->
originalMode
;
$build
[
'#custom_element'
]
=
$this
->
getCustomElementGenerator
()
->
generate
(
$entity
,
$build
[
'#view_mode'
]);
// Add layout build sections unless already done so.
if
(
isset
(
$build
[
'_layout_builder'
])
&&
empty
(
$build
[
'#custom_element'
]
->
getSlot
(
'sections'
)))
{
$build
[
'#custom_element'
]
->
setSlot
(
'sections'
,
$build
[
'_layout_builder'
]);
// Add layout build sections later during entity_view_alter().
// @see custom_elements_entity_view_alter()
if
(
isset
(
$build
[
'_layout_builder'
])
&&
!
isset
(
$build
[
'#custom_elements_add_layout_builder_section'
]))
{
$build
[
'#custom_elements_add_layout_builder_section'
]
=
TRUE
;
}
}
}
...
...
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