Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
drupal
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Custom Issue Tracker
Custom Issue Tracker
Labels
Merge Requests
225
Merge Requests
225
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
project
drupal
Commits
9eb4efb9
Commit
9eb4efb9
authored
Dec 10, 2014
by
webchick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue
#2390615
by alexpott: Add method to determine config dependency key depending on entity type
parent
7c6a23fe
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
3 deletions
+35
-3
core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php
core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php
+7
-0
core/lib/Drupal/Core/Entity/ContentEntityType.php
core/lib/Drupal/Core/Entity/ContentEntityType.php
+7
-0
core/lib/Drupal/Core/Entity/EntityType.php
core/lib/Drupal/Core/Entity/EntityType.php
+10
-0
core/lib/Drupal/Core/Entity/EntityTypeInterface.php
core/lib/Drupal/Core/Entity/EntityTypeInterface.php
+10
-0
core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php
...Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php
+1
-3
No files found.
core/lib/Drupal/Core/Config/Entity/ConfigEntityType.php
View file @
9eb4efb9
...
...
@@ -125,4 +125,11 @@ public function getDataTable() {
return
FALSE
;
}
/**
* {@inheritdoc}
*/
public
function
getConfigDependencyKey
()
{
return
'config'
;
}
}
core/lib/Drupal/Core/Entity/ContentEntityType.php
View file @
9eb4efb9
...
...
@@ -29,4 +29,11 @@ public function getConfigPrefix() {
return
FALSE
;
}
/**
* {@inheritdoc}
*/
public
function
getConfigDependencyKey
()
{
return
'content'
;
}
}
core/lib/Drupal/Core/Entity/EntityType.php
View file @
9eb4efb9
...
...
@@ -680,4 +680,14 @@ public function getListCacheTags() {
return
$this
->
list_cache_tags
;
}
/**
* {@inheritdoc}
*/
public
function
getConfigDependencyKey
()
{
// Return 'content' for the default implementation as important distinction
// is that dependencies on other configuration entities are hard
// dependencies and have to exist before creating the dependent entity.
return
'content'
;
}
}
core/lib/Drupal/Core/Entity/EntityTypeInterface.php
View file @
9eb4efb9
...
...
@@ -638,4 +638,14 @@ public function setUriCallback($callback);
* @return string[]
*/
public
function
getListCacheTags
();
/**
* Gets the key that is used to store configuration dependencies.
*
* @return string
* The key to be used in configuration dependencies when storing
* dependencies on entities of this type.
*/
public
function
getConfigDependencyKey
();
}
core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php
View file @
9eb4efb9
...
...
@@ -247,17 +247,15 @@ public function hasNewEntity() {
*/
public
static
function
calculateDependencies
(
FieldDefinitionInterface
$field_definition
)
{
$dependencies
=
[];
if
(
is_array
(
$field_definition
->
default_value
)
&&
count
(
$field_definition
->
default_value
))
{
$target_entity_type
=
\
Drupal
::
entityManager
()
->
getDefinition
(
$field_definition
->
getFieldStorageDefinition
()
->
getSetting
(
'target_type'
));
$key
=
$target_entity_type
instanceof
ConfigEntityType
?
'config'
:
'content'
;
foreach
(
$field_definition
->
default_value
as
$default_value
)
{
if
(
is_array
(
$default_value
)
&&
isset
(
$default_value
[
'target_uuid'
]))
{
$entity
=
\
Drupal
::
entityManager
()
->
loadEntityByUuid
(
$target_entity_type
->
id
(),
$default_value
[
'target_uuid'
]);
// If the entity does not exist do not create the dependency.
// @see \Drupal\Core\Field\EntityReferenceFieldItemList::processDefaultValue()
if
(
$entity
)
{
$dependencies
[
$
key
][]
=
$entity
->
getConfigDependencyName
();
$dependencies
[
$
target_entity_type
->
getConfigDependencyKey
()
][]
=
$entity
->
getConfigDependencyName
();
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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