diff --git a/core/modules/field/src/Tests/TestItemWithDependenciesTest.php b/core/modules/field/src/Tests/TestItemWithDependenciesTest.php index b5ad7e1..2692e16 100644 --- a/core/modules/field/src/Tests/TestItemWithDependenciesTest.php +++ b/core/modules/field/src/Tests/TestItemWithDependenciesTest.php @@ -50,7 +50,7 @@ public function testTestItemWithDepenencies() { $this->assertEqual([ 'content' => ['node:article:uuid'], 'config' => ['field.storage.entity_test.field_test'], - 'module' => ['field_test', 'test_module'] + 'module' => ['entity_test', 'field_test', 'test_module'] ], $field->getDependencies()); } diff --git a/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php b/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php index 992f698..5b5eba6 100644 --- a/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php +++ b/core/modules/field/tests/src/Unit/FieldConfigEntityUnitTest.php @@ -7,6 +7,7 @@ namespace Drupal\Tests\field\Unit; +use Drupal\Core\Entity\EntityType; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\Core\DependencyInjection\ContainerBuilder; @@ -115,26 +116,10 @@ protected function setUp() { */ public function testCalculateDependencies() { // 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 = $this->getMock('\Drupal\Core\Config\Entity\ConfigEntityStorageInterface'); - $storage->expects($this->any()) - ->method('load') - ->with('test_bundle') - ->will($this->returnValue($bundle_entity)); - - $this->entityManager->expects($this->any()) - ->method('getStorage') - ->with('bundle_entity_type') - ->will($this->returnValue($storage)); - $target_entity_type = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface'); $target_entity_type->expects($this->any()) - ->method('getBundleEntityType') - ->will($this->returnValue('bundle_entity_type')); + ->method('getBundleConfigDependency') + ->will($this->returnValue(array('type' => 'config', 'name' => 'test.test_entity_type.id'))); $this->entityManager->expects($this->at(0)) ->method('getDefinition') @@ -192,10 +177,10 @@ public function testCalculateDependenciesIncorrectBundle() { ->with('bundle_entity_type') ->will($this->returnValue($storage)); - $target_entity_type = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface'); - $target_entity_type->expects($this->any()) - ->method('getBundleEntityType') - ->will($this->returnValue('bundle_entity_type')); + $target_entity_type = new EntityType(array( + 'id' => 'test_entity_type', + 'bundle_entity_type' => 'bundle_entity_type', + )); $this->entityManager->expects($this->at(0)) ->method('getDefinition') diff --git a/core/modules/field_ui/src/Access/FormModeAccessCheck.php b/core/modules/field_ui/src/Access/FormModeAccessCheck.php index 9b4080b..055f588 100644 --- a/core/modules/field_ui/src/Access/FormModeAccessCheck.php +++ b/core/modules/field_ui/src/Access/FormModeAccessCheck.php @@ -64,6 +64,11 @@ public function __construct(EntityManagerInterface $entity_manager) { public function access(Route $route, RouteMatchInterface $route_match, AccountInterface $account, $form_mode_name = 'default', $bundle = NULL) { $access = AccessResult::neutral(); if ($entity_type_id = $route->getDefault('entity_type_id')) { + if (empty($bundle)) { + $entity_type = $this->entityManager->getDefinition($entity_type_id); + $bundle = $route_match->getRawParameter($entity_type->getBundleEntityType()); + } + $visibility = FALSE; if ($form_mode_name == 'default') { $visibility = TRUE; diff --git a/core/modules/field_ui/src/Access/ViewModeAccessCheck.php b/core/modules/field_ui/src/Access/ViewModeAccessCheck.php index 02696ad..a3e5e46 100644 --- a/core/modules/field_ui/src/Access/ViewModeAccessCheck.php +++ b/core/modules/field_ui/src/Access/ViewModeAccessCheck.php @@ -64,6 +64,11 @@ public function __construct(EntityManagerInterface $entity_manager) { public function access(Route $route, RouteMatchInterface $route_match, AccountInterface $account, $view_mode_name = 'default', $bundle = NULL) { $access = AccessResult::neutral(); if ($entity_type_id = $route->getDefault('entity_type_id')) { + if (empty($bundle)) { + $entity_type = $this->entityManager->getDefinition($entity_type_id); + $bundle = $route_match->getRawParameter($entity_type->getBundleEntityType()); + } + $visibility = FALSE; if ($view_mode_name == 'default') { $visibility = TRUE; diff --git a/core/modules/language/tests/src/Unit/ContentLanguageSettingsUnitTest.php b/core/modules/language/tests/src/Unit/ContentLanguageSettingsUnitTest.php index 920edea..04ab81b 100644 --- a/core/modules/language/tests/src/Unit/ContentLanguageSettingsUnitTest.php +++ b/core/modules/language/tests/src/Unit/ContentLanguageSettingsUnitTest.php @@ -88,26 +88,10 @@ protected function setUp() { */ public function testCalculateDependencies() { // 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 = $this->getMock('\Drupal\Core\Config\Entity\ConfigEntityStorageInterface'); - $storage->expects($this->any()) - ->method('load') - ->with('test_bundle') - ->will($this->returnValue($bundle_entity)); - - $this->entityManager->expects($this->any()) - ->method('getStorage') - ->with('bundle_entity_type') - ->will($this->returnValue($storage)); - $target_entity_type = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface'); $target_entity_type->expects($this->any()) - ->method('getBundleEntityType') - ->will($this->returnValue('bundle_entity_type')); + ->method('getBundleConfigDependency') + ->will($this->returnValue(array('type' => 'config', 'name' => 'test.test_entity_type.id'))); $this->entityManager->expects($this->any()) ->method('getDefinition') diff --git a/core/modules/rdf/src/Entity/RdfMapping.php b/core/modules/rdf/src/Entity/RdfMapping.php index 1ecade4..a4d8783 100644 --- a/core/modules/rdf/src/Entity/RdfMapping.php +++ b/core/modules/rdf/src/Entity/RdfMapping.php @@ -137,6 +137,7 @@ public function calculateDependencies() { // Create dependency on the bundle. $entity_type = \Drupal::entityManager()->getDefinition($this->targetEntityType); + $this->addDependency('module', $entity_type->getProvider()); if ($bundle_config_dependency = $entity_type->getBundleConfigDependency($this->bundle)) { $this->addDependency($bundle_config_dependency['type'], $bundle_config_dependency['name']); } diff --git a/core/modules/rdf/tests/src/Unit/RdfMappingConfigEntityUnitTest.php b/core/modules/rdf/tests/src/Unit/RdfMappingConfigEntityUnitTest.php index 196d726..4901d9c 100644 --- a/core/modules/rdf/tests/src/Unit/RdfMappingConfigEntityUnitTest.php +++ b/core/modules/rdf/tests/src/Unit/RdfMappingConfigEntityUnitTest.php @@ -109,16 +109,9 @@ public function testCalculateDependenciesWithEntityBundle() { $bundle_id = $this->randomMachineName(10); $values = array('targetEntityType' => $target_entity_type_id , 'bundle' => $bundle_id); - $bundle_entity_type_id = $this->randomMachineName(17); - $bundle_entity = $this->getMock('\Drupal\Core\Config\Entity\ConfigEntityInterface'); - $bundle_entity - ->expects($this->once()) - ->method('getConfigDependencyName') - ->will($this->returnValue('test_module.type.' . $bundle_id)); - $target_entity_type->expects($this->any()) - ->method('getBundleEntityType') - ->will($this->returnValue($bundle_entity_type_id)); + ->method('getBundleConfigDependency') + ->will($this->returnValue(array('type' => 'config', 'name' => 'test_module.type.' . $bundle_id))); $this->entityManager->expects($this->at(0)) ->method('getDefinition') @@ -129,17 +122,6 @@ public function testCalculateDependenciesWithEntityBundle() { ->with($this->entityTypeId) ->will($this->returnValue($this->entityType)); - $storage = $this->getMock('Drupal\Core\Entity\EntityStorageInterface'); - $storage->expects($this->once()) - ->method('load') - ->with($bundle_id) - ->will($this->returnValue($bundle_entity)); - - $this->entityManager->expects($this->once()) - ->method('getStorage') - ->with($bundle_entity_type_id) - ->will($this->returnValue($storage)); - $entity = new RdfMapping($values, $this->entityTypeId); $dependencies = $entity->calculateDependencies(); $this->assertContains('test_module.type.' . $bundle_id, $dependencies['config']);