diff --git a/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php index c65b159fe0..0a7fa593a3 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php @@ -35,13 +35,6 @@ protected $cacheBackend; /** - * The entity type bundle information object. - * - * @var \Drupal\Core\Entity\EntityTypeBundleInfoInterface - */ - protected $entityTypeBundleInfo; - - /** * Constructs a ContentEntityStorageBase object. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type @@ -50,15 +43,12 @@ * The entity manager. * @param \Drupal\Core\Cache\CacheBackendInterface $cache * The cache backend to be used. - * @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info - * The entity type bundle information object. */ - public function __construct(EntityTypeInterface $entity_type, EntityManagerInterface $entity_manager, CacheBackendInterface $cache, EntityTypeBundleInfoInterface $entity_type_bundle_info) { + public function __construct(EntityTypeInterface $entity_type, EntityManagerInterface $entity_manager, CacheBackendInterface $cache) { parent::__construct($entity_type); $this->bundleKey = $this->entityType->getKey('bundle'); $this->entityManager = $entity_manager; $this->cacheBackend = $cache; - $this->entityTypeBundleInfo = $entity_type_bundle_info; } /** @@ -68,8 +58,7 @@ public static function createInstance(ContainerInterface $container, EntityTypeI return new static( $entity_type, $container->get('entity.manager'), - $container->get('cache.entity'), - $container->get('entity_type.bundle.info') + $container->get('cache.entity') ); } @@ -115,7 +104,7 @@ public function createWithSampleValues($bundle = FALSE, array $values = []) { if (!$bundle) { throw new EntityStorageException("No entity bundle was specified"); } - if (!array_key_exists($bundle, $this->entityTypeBundleInfo->getBundleInfo($this->entityTypeId))) { + if (!array_key_exists($bundle, $this->entityManager->getBundleInfo($this->entityTypeId))) { throw new EntityStorageException(sprintf("Missing entity bundle. The \"%s\" bundle does not exist", $bundle)); } $values[$bundle_key] = $bundle; diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php index d19c1e184f..1172406e34 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php @@ -13,7 +13,6 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityStorageException; -use Drupal\Core\Entity\EntityTypeBundleInfoInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\Query\QueryInterface; use Drupal\Core\Entity\Schema\DynamicallyFieldableEntityStorageSchemaInterface; @@ -134,7 +133,6 @@ public static function createInstance(ContainerInterface $container, EntityTypeI $container->get('database'), $container->get('entity.manager'), $container->get('cache.entity'), - $container->get('entity_type.bundle.info'), $container->get('language_manager') ); } @@ -161,13 +159,11 @@ public function getFieldStorageDefinitions() { * The entity manager. * @param \Drupal\Core\Cache\CacheBackendInterface $cache * The cache backend to be used. - * @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info - * The entity type bundle information object. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * The language manager. */ - public function __construct(EntityTypeInterface $entity_type, Connection $database, EntityManagerInterface $entity_manager, CacheBackendInterface $cache, EntityTypeBundleInfoInterface $entity_type_bundle_info, LanguageManagerInterface $language_manager) { - parent::__construct($entity_type, $entity_manager, $cache, $entity_type_bundle_info); + public function __construct(EntityTypeInterface $entity_type, Connection $database, EntityManagerInterface $entity_manager, CacheBackendInterface $cache, LanguageManagerInterface $language_manager) { + parent::__construct($entity_type, $entity_manager, $cache); $this->database = $database; $this->languageManager = $language_manager; $this->initTableLayout(); diff --git a/core/modules/comment/src/CommentStorage.php b/core/modules/comment/src/CommentStorage.php index fe9c3b1d6a..d164d8ad9e 100644 --- a/core/modules/comment/src/CommentStorage.php +++ b/core/modules/comment/src/CommentStorage.php @@ -5,7 +5,6 @@ use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Database\Connection; use Drupal\Core\Entity\EntityManagerInterface; -use Drupal\Core\Entity\EntityTypeBundleInfoInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\FieldableEntityInterface; @@ -42,13 +41,11 @@ class CommentStorage extends SqlContentEntityStorage implements CommentStorageIn * The current user. * @param \Drupal\Core\Cache\CacheBackendInterface $cache * Cache backend instance to use. - * @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info - * The entity type bundle information object. * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * The language manager. */ - public function __construct(EntityTypeInterface $entity_info, Connection $database, EntityManagerInterface $entity_manager, AccountInterface $current_user, CacheBackendInterface $cache, EntityTypeBundleInfoInterface $entity_type_bundle_info, LanguageManagerInterface $language_manager) { - parent::__construct($entity_info, $database, $entity_manager, $cache, $entity_type_bundle_info, $language_manager); + public function __construct(EntityTypeInterface $entity_info, Connection $database, EntityManagerInterface $entity_manager, AccountInterface $current_user, CacheBackendInterface $cache, LanguageManagerInterface $language_manager) { + parent::__construct($entity_info, $database, $entity_manager, $cache, $language_manager); $this->currentUser = $current_user; } @@ -62,7 +59,6 @@ public static function createInstance(ContainerInterface $container, EntityTypeI $container->get('entity.manager'), $container->get('current_user'), $container->get('cache.entity'), - $container->get('entity_type.bundle.info'), $container->get('language_manager') ); } diff --git a/core/tests/Drupal/KernelTests/Core/Entity/Element/CreateSampleEntityTest.php b/core/tests/Drupal/KernelTests/Core/Entity/Element/CreateSampleEntityTest.php index 513266c3d1..05b9b4322f 100644 --- a/core/tests/Drupal/KernelTests/Core/Entity/Element/CreateSampleEntityTest.php +++ b/core/tests/Drupal/KernelTests/Core/Entity/Element/CreateSampleEntityTest.php @@ -8,7 +8,7 @@ use Drupal\taxonomy\Entity\Vocabulary; /** - * Tests the EntityGenerator API. + * Tests the ContentEntityStorageBase::createWithSampleValues method. * * @coversDefaultClass \Drupal\Core\Entity\ContentEntityStorageBase * @group Entity @@ -49,11 +49,11 @@ protected function setUp() { } /** - * Tests generation of all enabled content entity types. + * Tests sample value content entity creation of all types. * * * @covers ::createWithSampleValues */ - public function testGenerateContentEntity() { + public function testSampleValueContentEntity() { foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $definition) { if ($definition->entityClassImplements(FieldableEntityInterface::class)) { // Create sample entities with bundles. diff --git a/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php index 0d34ac6ac8..9f5408f546 100644 --- a/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/Sql/SqlContentEntityStorageTest.php @@ -118,7 +118,6 @@ protected function setUp() { $this->languageManager->expects($this->any()) ->method('getDefaultLanguage') ->will($this->returnValue(new Language(['langcode' => 'en']))); - $this->entityTypeBundleInfo = $this->getMock('Drupal\Core\Entity\EntityTypeBundleInfoInterface'); $this->connection = $this->getMockBuilder('Drupal\Core\Database\Connection') ->disableOriginalConstructor() ->getMock(); @@ -351,7 +350,7 @@ public function testOnEntityTypeCreate() { ->will($this->returnValue($schema_handler)); $storage = $this->getMockBuilder('Drupal\Core\Entity\Sql\SqlContentEntityStorage') - ->setConstructorArgs([$this->entityType, $this->connection, $this->entityManager, $this->cache, $this->entityTypeBundleInfo, $this->languageManager]) + ->setConstructorArgs([$this->entityType, $this->connection, $this->entityManager, $this->cache, $this->languageManager]) ->setMethods(['getStorageSchema']) ->getMock(); @@ -1113,7 +1112,7 @@ protected function setUpEntityStorage() { ->method('getBaseFieldDefinitions') ->will($this->returnValue($this->fieldDefinitions)); - $this->entityStorage = new SqlContentEntityStorage($this->entityType, $this->connection, $this->entityManager, $this->cache, $this->entityTypeBundleInfo, $this->languageManager); + $this->entityStorage = new SqlContentEntityStorage($this->entityType, $this->connection, $this->entityManager, $this->cache, $this->languageManager); } /** @@ -1190,7 +1189,7 @@ public function testLoadMultipleNoPersistentCache() { ->method('set'); $entity_storage = $this->getMockBuilder('Drupal\Core\Entity\Sql\SqlContentEntityStorage') - ->setConstructorArgs([$this->entityType, $this->connection, $this->entityManager, $this->cache, $this->entityTypeBundleInfo, $this->languageManager]) + ->setConstructorArgs([$this->entityType, $this->connection, $this->entityManager, $this->cache, $this->languageManager]) ->setMethods(['getFromStorage', 'invokeStorageLoadHook']) ->getMock(); $entity_storage->method('invokeStorageLoadHook') @@ -1242,7 +1241,7 @@ public function testLoadMultiplePersistentCacheMiss() { ->with($key, $entity, CacheBackendInterface::CACHE_PERMANENT, [$this->entityTypeId . '_values', 'entity_field_info']); $entity_storage = $this->getMockBuilder('Drupal\Core\Entity\Sql\SqlContentEntityStorage') - ->setConstructorArgs([$this->entityType, $this->connection, $this->entityManager, $this->cache, $this->entityTypeBundleInfo, $this->languageManager]) + ->setConstructorArgs([$this->entityType, $this->connection, $this->entityManager, $this->cache, $this->languageManager]) ->setMethods(['getFromStorage', 'invokeStorageLoadHook']) ->getMock(); $entity_storage->method('invokeStorageLoadHook') @@ -1297,7 +1296,7 @@ public function testHasData() { ->method('getBaseFieldDefinitions') ->will($this->returnValue($this->fieldDefinitions)); - $this->entityStorage = new SqlContentEntityStorage($this->entityType, $database, $this->entityManager, $this->cache, $this->entityTypeBundleInfo, $this->languageManager); + $this->entityStorage = new SqlContentEntityStorage($this->entityType, $database, $this->entityManager, $this->cache, $this->languageManager); $result = $this->entityStorage->hasData();