Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ctools
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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
ctools
Merge requests
!58
Check if a field exists before setting it in the build array.
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Check if a field exists before setting it in the build array.
issue/ctools-2966909:2966909-ctools-block-field
into
8.x-3.x
Overview
0
Commits
1
Pipelines
3
Changes
1
Merged
Jakob P
requested to merge
issue/ctools-2966909:2966909-ctools-block-field
into
8.x-3.x
1 year ago
Overview
0
Commits
1
Pipelines
3
Changes
1
Expand
Closes
#2966909
0
0
Merge request reports
Compare
8.x-3.x
version 1
9923ce8b
1 year ago
8.x-3.x (base)
and
latest version
latest version
29e09813
1 commit,
1 year ago
version 1
9923ce8b
1 commit,
1 year ago
1 file
+
7
−
4
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
modules/ctools_block/src/Plugin/Block/EntityField.php
+
7
−
4
Options
@@ -137,10 +137,13 @@ class EntityField extends BlockBase implements ContextAwarePluginInterface, Cont
/** @var \Drupal\Core\Entity\FieldableEntityInterface $entity */
$entity
=
$this
->
getContextValue
(
'entity'
);
$build
=
[];
/** @var \Drupal\Core\Field\FieldItemListInterface $field */
$field
=
$entity
->
{
$this
->
fieldName
};
$display_settings
=
$this
->
getConfiguration
()[
'formatter'
];
$build
[
'field'
]
=
$field
->
view
(
$display_settings
);
if
(
$entity
->
hasField
(
$this
->
fieldName
))
{
/** @var \Drupal\Core\Field\FieldItemListInterface $field */
$field
=
$entity
->
{
$this
->
fieldName
};
$display_settings
=
$this
->
getConfiguration
()[
'formatter'
];
$build
[
'field'
]
=
$field
->
view
(
$display_settings
);
}
// Set the cache data appropriately.
$build
[
'#cache'
][
'contexts'
]
=
$this
->
getCacheContexts
();
Loading