Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
34907c36
Commit
34907c36
authored
Mar 25, 2014
by
catch
Browse files
Issue
#2224209
by alexpott: Field instance configuration should depend on its bundle.
parent
13242b5a
Changes
11
Hide whitespace changes
Inline
Side-by-side
core/modules/comment/lib/Drupal/comment/Tests/CommentValidationTest.php
View file @
34907c36
...
...
@@ -51,6 +51,13 @@ public function testValidation() {
'name'
=>
'comment'
,
'type'
=>
'comment'
,
))
->
save
();
// Create a page node type.
$this
->
entityManager
->
getStorageController
(
'node_type'
)
->
create
(
array
(
'type'
=>
'page'
,
'name'
=>
'page'
,
))
->
save
();
// Add comment field instance to page content.
$this
->
entityManager
->
getStorageController
(
'field_instance_config'
)
->
create
(
array
(
'field_name'
=>
'comment'
,
...
...
core/modules/contact/lib/Drupal/contact/Tests/Views/ContactFieldsTest.php
View file @
34907c36
...
...
@@ -47,6 +47,11 @@ protected function setUp() {
));
$this
->
field
->
save
();
entity_create
(
'contact_category'
,
array
(
'id'
=>
'contact_message'
,
'label'
=>
'Test contact category'
,
))
->
save
();
entity_create
(
'field_instance_config'
,
array
(
'field_name'
=>
$this
->
field
->
name
,
'entity_type'
=>
'contact_message'
,
...
...
core/modules/field/lib/Drupal/field/Entity/FieldInstanceConfig.php
View file @
34907c36
...
...
@@ -368,6 +368,13 @@ public function calculateDependencies() {
parent
::
calculateDependencies
();
// Manage dependencies.
$this
->
addDependency
(
'entity'
,
$this
->
field
->
getConfigDependencyName
());
$bundle_entity_type_id
=
\
Drupal
::
entityManager
()
->
getDefinition
(
$this
->
entity_type
)
->
getBundleEntityType
();
if
(
$bundle_entity_type_id
!=
'bundle'
)
{
// If the target entity type uses entities to manage its bundles then
// depend on the bundle entity.
$bundle_entity
=
\
Drupal
::
entityManager
()
->
getStorageController
(
$bundle_entity_type_id
)
->
load
(
$this
->
bundle
);
$this
->
addDependency
(
'entity'
,
$bundle_entity
->
getConfigDependencyName
());
}
return
$this
->
dependencies
;
}
...
...
core/modules/field/lib/Drupal/field/Tests/Views/FieldTestBase.php
View file @
34907c36
...
...
@@ -52,6 +52,12 @@ abstract class FieldTestBase extends ViewTestBase {
protected
function
setUp
()
{
parent
::
setUp
();
// Ensure the page node type exists.
entity_create
(
'node_type'
,
array
(
'type'
=>
'page'
,
'name'
=>
'page'
,
))
->
save
();
ViewTestData
::
createTestViews
(
get_class
(
$this
),
array
(
'field_test_views'
));
}
...
...
core/modules/field/tests/Drupal/field/Tests/FieldInstanceConfigEntityUnitTest.php
View file @
34907c36
...
...
@@ -71,16 +71,7 @@ public static function getInfo() {
public
function
setUp
()
{
$this
->
entityTypeId
=
$this
->
randomName
();
$this
->
entityType
=
$this
->
getMock
(
'\Drupal\Core\Entity\EntityTypeInterface'
);
$this
->
entityType
->
expects
(
$this
->
any
())
->
method
(
'getProvider'
)
->
will
(
$this
->
returnValue
(
'entity'
));
$this
->
entityManager
=
$this
->
getMock
(
'\Drupal\Core\Entity\EntityManagerInterface'
);
$this
->
entityManager
->
expects
(
$this
->
any
())
->
method
(
'getDefinition'
)
->
with
(
$this
->
entityTypeId
)
->
will
(
$this
->
returnValue
(
$this
->
entityType
));
$this
->
uuid
=
$this
->
getMock
(
'\Drupal\Component\Uuid\UuidInterface'
);
...
...
@@ -111,10 +102,40 @@ public function testCalculateDependencies() {
->
method
(
'getField'
)
->
with
(
'test_entity_type'
,
'test_field'
)
->
will
(
$this
->
returnValue
(
$field
));
$values
=
array
(
'field_name'
=>
'test_field'
,
'entity_type'
=>
'test_entity_type'
,
$this
->
entityTypeId
,
'bundle'
=>
'test_bundle'
);
// Mock the interfaces necessary to create a dependency on a bundle entity.
$bundle_entity
=
$this
->
getMock
(
'Drupal\Core\Config\Entity\ConfigEntityInterface'
);
$bundle_entity
->
expects
(
$this
->
any
())
->
method
(
'getConfigDependencyName'
)
->
will
(
$this
->
returnValue
(
'test.test_entity_type.id'
));
$storage_controller
=
$this
->
getMock
(
'\Drupal\Core\Config\Entity\ConfigStorageControllerInterface'
);
$storage_controller
->
expects
(
$this
->
any
())
->
method
(
'load'
)
->
with
(
'test_bundle'
)
->
will
(
$this
->
returnValue
(
$bundle_entity
));
$this
->
entityManager
->
expects
(
$this
->
any
())
->
method
(
'getStorageController'
)
->
with
(
'bundle_entity_type'
)
->
will
(
$this
->
returnValue
(
$storage_controller
));
$target_entity_type
=
$this
->
getMock
(
'\Drupal\Core\Entity\EntityTypeInterface'
);
$target_entity_type
->
expects
(
$this
->
any
())
->
method
(
'getBundleEntityType'
)
->
will
(
$this
->
returnValue
(
'bundle_entity_type'
));
$this
->
entityManager
->
expects
(
$this
->
any
())
->
method
(
'getDefinition'
)
->
with
(
'test_entity_type'
)
->
will
(
$this
->
returnValue
(
$target_entity_type
));
$values
=
array
(
'field_name'
=>
'test_field'
,
'entity_type'
=>
'test_entity_type'
,
'bundle'
=>
'test_bundle'
);
$entity
=
new
FieldInstanceConfig
(
$values
,
$this
->
entityTypeId
);
$dependencies
=
$entity
->
calculateDependencies
();
$this
->
assertContains
(
'field.field.test_entity_type.test_field'
,
$dependencies
[
'entity'
]);
$this
->
assertContains
(
'test.test_entity_type.id'
,
$dependencies
[
'entity'
]);
}
}
core/modules/forum/config/field.instance.taxonomy_term.forums.forum_container.yml
View file @
34907c36
...
...
@@ -16,3 +16,4 @@ field_type: list_boolean
dependencies
:
entity
:
-
field.field.forum.forum_container
-
taxonomy.vocabulary.forums
core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareCombinationTest.php
View file @
34907c36
...
...
@@ -53,6 +53,29 @@ public static function getInfo() {
public
function
setUp
()
{
parent
::
setUp
();
// Create the 'private' field, which allows the node to be marked as private
// (restricted access) in a given translation.
$field_private
=
entity_create
(
'field_config'
,
array
(
'name'
=>
'field_private'
,
'entity_type'
=>
'node'
,
'type'
=>
'list_boolean'
,
'cardinality'
=>
1
,
'translatable'
=>
TRUE
,
'settings'
=>
array
(
'allowed_values'
=>
array
(
0
=>
'Not private'
,
1
=>
'Private'
),
),
));
$field_private
->
save
();
entity_create
(
'field_instance_config'
,
array
(
'field_name'
=>
$field_private
->
name
,
'entity_type'
=>
'node'
,
'bundle'
=>
'page'
,
'widget'
=>
array
(
'type'
=>
'options_buttons'
,
),
))
->
save
();
// After enabling a node access module, the access table has to be rebuild.
node_access_rebuild
();
...
...
core/modules/node/lib/Drupal/node/Tests/NodeAccessLanguageAwareTest.php
View file @
34907c36
...
...
@@ -46,6 +46,29 @@ public static function getInfo() {
public
function
setUp
()
{
parent
::
setUp
();
// Create the 'private' field, which allows the node to be marked as private
// (restricted access) in a given translation.
$field_private
=
entity_create
(
'field_config'
,
array
(
'name'
=>
'field_private'
,
'entity_type'
=>
'node'
,
'type'
=>
'list_boolean'
,
'cardinality'
=>
1
,
'translatable'
=>
TRUE
,
'settings'
=>
array
(
'allowed_values'
=>
array
(
0
=>
'Not private'
,
1
=>
'Private'
),
),
));
$field_private
->
save
();
entity_create
(
'field_instance_config'
,
array
(
'field_name'
=>
$field_private
->
name
,
'entity_type'
=>
'node'
,
'bundle'
=>
'page'
,
'widget'
=>
array
(
'type'
=>
'options_buttons'
,
),
))
->
save
();
// After enabling a node access module, the access table has to be rebuild.
node_access_rebuild
();
...
...
core/modules/node/tests/modules/node_access_test_language/node_access_test_language.install
deleted
100644 → 0
View file @
13242b5a
<?php
/**
* @file
* Install, update and uninstall functions for the node_access_test_language
* module.
*/
/**
* Implements hook_install().
*
* Creates the 'private' field, which allows the node to be marked as private
* (restricted access) in a given translation.
*/
function
node_access_test_language_install
()
{
$field_private
=
entity_create
(
'field_config'
,
array
(
'name'
=>
'field_private'
,
'entity_type'
=>
'node'
,
'type'
=>
'list_boolean'
,
'cardinality'
=>
1
,
'translatable'
=>
TRUE
,
'settings'
=>
array
(
'allowed_values'
=>
array
(
0
=>
'Not private'
,
1
=>
'Private'
),
),
));
$field_private
->
save
();
entity_create
(
'field_instance_config'
,
array
(
'field_name'
=>
$field_private
->
name
,
'entity_type'
=>
'node'
,
'bundle'
=>
'page'
,
'widget'
=>
array
(
'type'
=>
'options_buttons'
,
),
))
->
save
();
}
/**
* Implements hook_uninstall().
*/
function
node_access_test_language_uninstall
()
{
entity_load
(
'field_instance_config'
,
'node.page.field_private'
)
->
delete
();
}
core/profiles/standard/config/field.instance.node.article.field_image.yml
View file @
34907c36
...
...
@@ -29,3 +29,4 @@ field_type: image
dependencies
:
entity
:
-
field.field.node.field_image
-
node.type.article
core/profiles/standard/config/field.instance.node.article.field_tags.yml
View file @
34907c36
...
...
@@ -13,3 +13,4 @@ langcode: und
dependencies
:
entity
:
-
field.field.node.field_tags
-
node.type.article
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