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
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
custom_elements
Commits
6a0d7907
Commit
6a0d7907
authored
9 months ago
by
Roderik Muit
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3467817
by roderik, junkuncz: Node 'title' field cannot be enabled in CE UI
parent
416c7c67
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!76
Ignore configurability of fields (because not all fields have this property).
Pipeline
#254826
canceled
9 months ago
Stage: build
Stage: validate
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Entity/EntityCeDisplay.php
+18
-17
18 additions, 17 deletions
src/Entity/EntityCeDisplay.php
with
18 additions
and
17 deletions
src/Entity/EntityCeDisplay.php
+
18
−
17
View file @
6a0d7907
...
...
@@ -2,10 +2,9 @@
namespace
Drupal\custom_elements\Entity
;
use
Drupal\Core\Config\Entity\ConfigEntityBase
;
use
Drupal\Core\Entity\EntityDisplayBase
;
use
Drupal\Core\Entity\EntityStorageInterface
;
use
Drupal\Core\Field\BaseFieldDefinition
;
use
Drupal\Core\Field\FieldDefinition
;
use
Drupal\Core\Plugin\DefaultLazyPluginCollection
as
DefaultLazyPluginCollectionAlias
;
use
Drupal\custom_elements
\CustomElementGenerator
;
...
...
@@ -212,7 +211,7 @@ class EntityCeDisplay extends EntityDisplayBase implements EntityCeDisplayInterf
* {@inheritdoc}
*/
protected
function
init
()
{
//
Do not call parent::init();
we don't need its display defaults.
//
Override parent method:
we don't need its display defaults.
if
(
!
$this
->
targetEntityType
)
{
return
;
}
...
...
@@ -224,11 +223,11 @@ class EntityCeDisplay extends EntityDisplayBase implements EntityCeDisplayInterf
$initialized
=
!
empty
(
$this
->
content
)
||
$this
->
forceAutoProcessing
;
if
(
!
$initialized
)
{
// Enable components
options as done
in the regular entity_view_display.
// Enable components
that are enabled
in the regular entity_view_display.
/** @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $entity_view_display */
$entity_view_display
=
\Drupal
::
service
(
'entity_display.repository'
)
->
getViewDisplay
(
$this
->
targetEntityType
,
$this
->
bundle
,
$this
->
originalMode
);
$field_definitions
=
\Drupal
::
service
(
'entity_field.manager'
)
->
getFieldDefinitions
(
$this
->
targetEntityType
,
$this
->
bundle
);
$field_definitions
=
$this
->
getFieldDefinitions
(
);
// @todo Add support for statically set values.
// Enable every component with "auto" that is enabled in the display.
...
...
@@ -312,27 +311,29 @@ class EntityCeDisplay extends EntityDisplayBase implements EntityCeDisplayInterf
* {@inheritdoc}
*/
public
function
preSave
(
EntityStorageInterface
$storage
)
{
// Work around some of the parent code.
// Work around some of the parent
method's
code.
$this
->
hidden
=
[];
parent
::
preSave
(
$storage
);
unset
(
$this
->
hidden
);
}
/**
* Gets the definitions of the fields that are candidate for display.
* {@inheritdoc}
*/
public
function
toArray
()
{
// Skip over parent method: all fields' display is configurable, no field
// must be disallowed because of its definitions.
return
ConfigEntityBase
::
toArray
();
}
/**
* {@inheritdoc}
*/
protected
function
getFieldDefinitions
()
{
// Override parent method: do not filter field definitions, all fields'
// display is configurable.
if
(
!
isset
(
$this
->
fieldDefinitions
))
{
$definitions
=
\Drupal
::
service
(
'entity_field.manager'
)
->
getFieldDefinitions
(
$this
->
targetEntityType
,
$this
->
bundle
);
$this
->
fieldDefinitions
=
$definitions
;
foreach
(
$this
->
fieldDefinitions
as
$field_definition
)
{
if
(
$field_definition
instanceof
BaseFieldDefinition
||
$field_definition
instanceof
FieldDefinition
)
{
// We'd like to be able to configure all the fields thus override
// displayConfigurable to true for all field definitions.
$field_definition
->
setDisplayConfigurable
(
$this
->
displayContext
,
TRUE
);
}
}
$this
->
fieldDefinitions
=
\Drupal
::
service
(
'entity_field.manager'
)
->
getFieldDefinitions
(
$this
->
targetEntityType
,
$this
->
bundle
);
}
return
$this
->
fieldDefinitions
;
...
...
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