Commit 6c2ed3f1 authored by alexpott's avatar alexpott

Issue #2165155 by Berdir, tim.plunkett: Change $entity_type to $entity_type_id...

Issue #2165155 by Berdir, tim.plunkett: Change $entity_type to $entity_type_id and $entity_info to $entity_type/$entity_types.
parent 32742836
......@@ -79,8 +79,8 @@ function config($name) {
* Either the entity type name, or NULL if none match.
*/
function config_get_entity_type_by_name($name) {
$entities = array_filter(\Drupal::entityManager()->getDefinitions(), function (EntityTypeInterface $entity_info) use ($name) {
return ($config_prefix = $entity_info->getConfigPrefix()) && strpos($name, $config_prefix . '.') === 0;
$entities = array_filter(\Drupal::entityManager()->getDefinitions(), function (EntityTypeInterface $entity_type) use ($name) {
return ($config_prefix = $entity_type->getConfigPrefix()) && strpos($name, $config_prefix . '.') === 0;
});
return key($entities);
}
......
......@@ -250,7 +250,7 @@ function entity_revision_delete($entity_type, $revision_id) {
*
* Note that some entity types may not support UUIDs.
*
* @param string $entity_type
* @param string $entity_type_id
* The entity type to load; e.g., 'node' or 'user'.
* @param string $uuid
* The UUID of the entity to load.
......@@ -265,13 +265,13 @@ function entity_revision_delete($entity_type, $revision_id) {
*
* @see \Drupal\Core\Entity\EntityManagerInterface
*/
function entity_load_by_uuid($entity_type, $uuid, $reset = FALSE) {
$entity_info = \Drupal::entityManager()->getDefinition($entity_type);
if (!$uuid_key = $entity_info->getKey('uuid')) {
throw new EntityStorageException("Entity type $entity_type does not support UUIDs.");
function entity_load_by_uuid($entity_type_id, $uuid, $reset = FALSE) {
$entity_type = \Drupal::entityManager()->getDefinition($entity_type_id);
if (!$uuid_key = $entity_type->getKey('uuid')) {
throw new EntityStorageException("Entity type $entity_type_id does not support UUIDs.");
}
$controller = \Drupal::entityManager()->getStorageController($entity_type);
$controller = \Drupal::entityManager()->getStorageController($entity_type_id);
if ($reset) {
$controller->resetCache();
}
......
......@@ -82,8 +82,8 @@ class ConfigStorageController extends EntityStorageControllerBase implements Con
/**
* Constructs a ConfigStorageController object.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_info
* The entity info for the entity type.
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type definition.
* @param \Drupal\Core\Config\ConfigFactory $config_factory
* The config factory service.
* @param \Drupal\Core\Config\StorageInterface $config_storage
......@@ -93,8 +93,8 @@ class ConfigStorageController extends EntityStorageControllerBase implements Con
* @param \Drupal\Component\Uuid\UuidInterface $uuid_service
* The UUID service.
*/
public function __construct(EntityTypeInterface $entity_info, ConfigFactory $config_factory, StorageInterface $config_storage, QueryFactory $entity_query_factory, UuidInterface $uuid_service) {
parent::__construct($entity_info);
public function __construct(EntityTypeInterface $entity_type, ConfigFactory $config_factory, StorageInterface $config_storage, QueryFactory $entity_query_factory, UuidInterface $uuid_service) {
parent::__construct($entity_type);
$this->idKey = $this->entityType->getKey('id');
$this->statusKey = $this->entityType->getKey('status');
......@@ -108,9 +108,9 @@ public function __construct(EntityTypeInterface $entity_info, ConfigFactory $con
/**
* {@inheritdoc}
*/
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_info) {
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static(
$entity_info,
$entity_type,
$container->get('config.factory'),
$container->get('config.storage'),
$container->get('entity.query'),
......
......@@ -48,8 +48,8 @@ abstract class DraggableListController extends ConfigEntityListController implem
/**
* {@inheritdoc}
*/
public function __construct(EntityTypeInterface $entity_info, EntityStorageControllerInterface $storage) {
parent::__construct($entity_info, $storage);
public function __construct(EntityTypeInterface $entity_type, EntityStorageControllerInterface $storage) {
parent::__construct($entity_type, $storage);
// Check if the entity type supports weighting.
if ($this->entityType->hasKey('weight')) {
......
......@@ -124,15 +124,15 @@ public function execute() {
* Config records keyed by entity IDs.
*/
protected function loadRecords() {
$entity_info = $this->entityManager->getDefinition($this->getEntityType());
$prefix = $entity_info->getConfigPrefix() . '.';
$entity_type = $this->entityManager->getDefinition($this->getEntityType());
$prefix = $entity_type->getConfigPrefix() . '.';
$prefix_length = strlen($prefix);
// Search the conditions for restrictions on entity IDs.
$ids = array();
if ($this->condition->getConjunction() == 'AND') {
foreach ($this->condition->conditions() as $condition) {
if (is_string($condition['field']) && $condition['field'] == $entity_info->getKey('id')) {
if (is_string($condition['field']) && $condition['field'] == $entity_type->getKey('id')) {
$operator = $condition['operator'] ?: (is_array($condition['value']) ? 'IN' : '=');
if ($operator == '=') {
$ids = array($condition['value']);
......
......@@ -720,8 +720,8 @@ public function addTranslation($langcode, array $values = array()) {
// Instantiate a new empty entity so default values will be populated in the
// specified language.
$info = $this->getEntityType();
$default_values = array($info->getKey('bundle') => $this->bundle, 'langcode' => $langcode);
$entity_type = $this->getEntityType();
$default_values = array($entity_type->getKey('bundle') => $this->bundle, 'langcode' => $langcode);
$entity = \Drupal::entityManager()
->getStorageController($this->getEntityTypeId())
->create($default_values);
......@@ -906,18 +906,18 @@ public function createDuplicate() {
}
$duplicate = clone $this;
$entity_info = $this->getEntityType();
$duplicate->{$entity_info->getKey('id')}->value = NULL;
$entity_type = $this->getEntityType();
$duplicate->{$entity_type->getKey('id')}->value = NULL;
// Check if the entity type supports UUIDs and generate a new one if so.
if ($entity_info->hasKey('uuid')) {
if ($entity_type->hasKey('uuid')) {
// @todo Inject the UUID service into the Entity class once possible.
$duplicate->{$entity_info->getKey('uuid')}->value = \Drupal::service('uuid')->generate();
$duplicate->{$entity_type->getKey('uuid')}->value = \Drupal::service('uuid')->generate();
}
// Check whether the entity type supports revisions and initialize it if so.
if ($entity_info->hasKey('revision')) {
$duplicate->{$entity_info->getKey('revision')}->value = NULL;
if ($entity_type->hasKey('revision')) {
$duplicate->{$entity_type->getKey('revision')}->value = NULL;
}
return $duplicate;
......@@ -959,12 +959,12 @@ public function __clone() {
*/
public function label() {
$label = NULL;
$entity_info = $this->getEntityType();
$entity_type = $this->getEntityType();
// @todo Convert to is_callable() and call_user_func().
if (($label_callback = $entity_info->getLabelCallback()) && function_exists($label_callback)) {
if (($label_callback = $entity_type->getLabelCallback()) && function_exists($label_callback)) {
$label = $label_callback($this);
}
elseif (($label_key = $entity_info->getKey('label')) && isset($this->{$label_key})) {
elseif (($label_key = $entity_type->getKey('label')) && isset($this->{$label_key})) {
$label = $this->{$label_key}->value;
}
return $label;
......
......@@ -130,15 +130,15 @@ public function isDefaultFormLangcode(array $form_state) {
*/
public function buildEntity(array $form, array &$form_state) {
$entity = clone $this->entity;
$entity_type = $entity->getEntityTypeId();
$info = \Drupal::entityManager()->getDefinition($entity_type);
$entity_type_id = $entity->getEntityTypeId();
$entity_type = \Drupal::entityManager()->getDefinition($entity_type_id);
// @todo Exploit the Entity Field API to process the submitted field values.
// Copy top-level form values that are entity fields but not handled by
// field API without changing existing entity fields that are not being
// edited by this form. Values of fields handled by field API are copied
// by field_attach_extract_form_values() below.
$values_excluding_fields = $info->isFieldable() ? array_diff_key($form_state['values'], field_info_instances($entity_type, $entity->bundle())) : $form_state['values'];
$values_excluding_fields = $entity_type->isFieldable() ? array_diff_key($form_state['values'], field_info_instances($entity_type_id, $entity->bundle())) : $form_state['values'];
$definitions = $entity->getPropertyDefinitions();
foreach ($values_excluding_fields as $key => $value) {
if (isset($definitions[$key])) {
......@@ -149,12 +149,12 @@ public function buildEntity(array $form, array &$form_state) {
// Invoke all specified builders for copying form values to entity fields.
if (isset($form['#entity_builders'])) {
foreach ($form['#entity_builders'] as $function) {
call_user_func_array($function, array($entity_type, $entity, &$form, &$form_state));
call_user_func_array($function, array($entity_type_id, $entity, &$form, &$form_state));
}
}
// Invoke field API for copying field values.
if ($info->isFieldable()) {
if ($entity_type->isFieldable()) {
field_attach_extract_form_values($entity, $form, $form_state, array('langcode' => $this->getFormLangcode($form_state)));
}
return $entity;
......
......@@ -38,8 +38,6 @@ class DatabaseStorageController extends EntityStorageControllerBase {
/**
* Whether this entity type should use the static cache.
*
* Set by entity info.
*
* @var boolean
*/
protected $cache;
......@@ -61,9 +59,9 @@ class DatabaseStorageController extends EntityStorageControllerBase {
/**
* {@inheritdoc}
*/
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_info) {
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static(
$entity_info,
$entity_type,
$container->get('database'),
$container->get('uuid')
);
......@@ -72,15 +70,15 @@ public static function createInstance(ContainerInterface $container, EntityTypeI
/**
* Constructs a DatabaseStorageController object.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_info
* The entity info for the entity type.
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type definition.
* @param \Drupal\Core\Database\Connection $database
* The database connection to be used.
* @param \Drupal\Component\Uuid\UuidInterface $uuid_service
* The UUID service.
*/
public function __construct(EntityTypeInterface $entity_info, Connection $database, UuidInterface $uuid_service) {
parent::__construct($entity_info);
public function __construct(EntityTypeInterface $entity_type, Connection $database, UuidInterface $uuid_service) {
parent::__construct($entity_type);
$this->database = $database;
$this->uuidService = $uuid_service;
......
......@@ -107,12 +107,12 @@ public function bundle() {
*/
public function label() {
$label = NULL;
$entity_info = $this->getEntityType();
$entity_type = $this->getEntityType();
// @todo Convert to is_callable() and call_user_func().
if (($label_callback = $entity_info->getLabelCallback()) && function_exists($label_callback)) {
if (($label_callback = $entity_type->getLabelCallback()) && function_exists($label_callback)) {
$label = $label_callback($this);
}
elseif (($label_key = $entity_info->getKey('label')) && isset($this->{$label_key})) {
elseif (($label_key = $entity_type->getKey('label')) && isset($this->{$label_key})) {
$label = $this->{$label_key};
}
return $label;
......@@ -291,13 +291,13 @@ public function delete() {
*/
public function createDuplicate() {
$duplicate = clone $this;
$entity_info = $this->getEntityType();
$duplicate->{$entity_info->getKey('id')} = NULL;
$entity_type = $this->getEntityType();
$duplicate->{$entity_type->getKey('id')} = NULL;
// Check if the entity type supports UUIDs and generate a new one if so.
if ($entity_info->hasKey('uuid')) {
if ($entity_type->hasKey('uuid')) {
// @todo Inject the UUID service into the Entity class once possible.
$duplicate->{$entity_info->getKey('uuid')} = \Drupal::service('uuid')->generate();
$duplicate->{$entity_type->getKey('uuid')} = \Drupal::service('uuid')->generate();
}
return $duplicate;
}
......
......@@ -43,12 +43,12 @@ class EntityAccessController extends EntityControllerBase implements EntityAcces
/**
* Constructs an access controller instance.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_info
* The entity info for the entity type.
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type definition.
*/
public function __construct(EntityTypeInterface $entity_info) {
$this->entityTypeId = $entity_info->id();
$this->entityType = $entity_info;
public function __construct(EntityTypeInterface $entity_type) {
$this->entityTypeId = $entity_type->id();
$this->entityType = $entity_type;
}
/**
......
......@@ -31,12 +31,12 @@ interface EntityControllerInterface {
*
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
* The service container this object should use.
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_info
* The entity info for the entity type.
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type definition.
*
* @return static
* A new instance of the entity controller.
*/
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_info);
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type);
}
......@@ -41,25 +41,25 @@ class EntityListController extends EntityControllerBase implements EntityListCon
/**
* {@inheritdoc}
*/
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_info) {
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static(
$entity_info,
$container->get('entity.manager')->getStorageController($entity_info->id())
$entity_type,
$container->get('entity.manager')->getStorageController($entity_type->id())
);
}
/**
* Constructs a new EntityListController object.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_info
* The entity info for the entity type.
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type definition.
* @param \Drupal\Core\Entity\EntityStorageControllerInterface $storage
* The entity storage controller class.
*/
public function __construct(EntityTypeInterface $entity_info, EntityStorageControllerInterface $storage) {
$this->entityTypeId = $entity_info->id();
public function __construct(EntityTypeInterface $entity_type, EntityStorageControllerInterface $storage) {
$this->entityTypeId = $entity_type->id();
$this->storage = $storage;
$this->entityType = $entity_info;
$this->entityType = $entity_type;
}
/**
......
......@@ -282,12 +282,12 @@ public function getController($entity_type, $controller_type, $controller_class_
/**
* {@inheritdoc}
*/
public function getAdminRouteInfo($entity_type, $bundle) {
if (($entity_info = $this->getDefinition($entity_type)) && $admin_form = $entity_info->getLinkTemplate('admin-form')) {
public function getAdminRouteInfo($entity_type_id, $bundle) {
if (($entity_type = $this->getDefinition($entity_type_id)) && $admin_form = $entity_type->getLinkTemplate('admin-form')) {
return array(
'route_name' => $admin_form,
'route_parameters' => array(
$entity_info->getBundleEntityType() => $bundle,
$entity_type->getBundleEntityType() => $bundle,
),
);
}
......@@ -296,21 +296,21 @@ public function getAdminRouteInfo($entity_type, $bundle) {
/**
* {@inheritdoc}
*/
public function getFieldDefinitions($entity_type, $bundle = NULL) {
if (!isset($this->entityFieldInfo[$entity_type])) {
public function getFieldDefinitions($entity_type_id, $bundle = NULL) {
if (!isset($this->entityFieldInfo[$entity_type_id])) {
// First, try to load from cache.
$cid = 'entity_field_definitions:' . $entity_type . ':' . $this->languageManager->getCurrentLanguage()->id;
$cid = 'entity_field_definitions:' . $entity_type_id . ':' . $this->languageManager->getCurrentLanguage()->id;
if ($cache = $this->cache->get($cid)) {
$this->entityFieldInfo[$entity_type] = $cache->data;
$this->entityFieldInfo[$entity_type_id] = $cache->data;
}
else {
// @todo: Refactor to allow for per-bundle overrides.
// See https://drupal.org/node/2114707.
$entity_info = $this->getDefinition($entity_type);
$class = $entity_info->getClass();
$entity_type = $this->getDefinition($entity_type_id);
$class = $entity_type->getClass();
$this->entityFieldInfo[$entity_type] = array(
'definitions' => $class::baseFieldDefinitions($entity_type),
$this->entityFieldInfo[$entity_type_id] = array(
'definitions' => $class::baseFieldDefinitions($entity_type_id),
// Contains definitions of optional (per-bundle) fields.
'optional' => array(),
// An array keyed by bundle name containing the optional fields added
......@@ -319,14 +319,14 @@ public function getFieldDefinitions($entity_type, $bundle = NULL) {
);
// Invoke hooks.
$result = $this->moduleHandler->invokeAll($entity_type . '_field_info');
$this->entityFieldInfo[$entity_type] = NestedArray::mergeDeep($this->entityFieldInfo[$entity_type], $result);
$result = $this->moduleHandler->invokeAll('entity_field_info', array($entity_type));
$this->entityFieldInfo[$entity_type] = NestedArray::mergeDeep($this->entityFieldInfo[$entity_type], $result);
$result = $this->moduleHandler->invokeAll($entity_type_id . '_field_info');
$this->entityFieldInfo[$entity_type_id] = NestedArray::mergeDeep($this->entityFieldInfo[$entity_type_id], $result);
$result = $this->moduleHandler->invokeAll('entity_field_info', array($entity_type_id));
$this->entityFieldInfo[$entity_type_id] = NestedArray::mergeDeep($this->entityFieldInfo[$entity_type_id], $result);
// Automatically set the field name for non-configurable fields.
foreach (array('definitions', 'optional') as $key) {
foreach ($this->entityFieldInfo[$entity_type][$key] as $field_name => &$definition) {
foreach ($this->entityFieldInfo[$entity_type_id][$key] as $field_name => &$definition) {
if ($definition instanceof FieldDefinition) {
$definition->setName($field_name);
}
......@@ -334,36 +334,36 @@ public function getFieldDefinitions($entity_type, $bundle = NULL) {
}
// Invoke alter hooks.
$hooks = array('entity_field_info', $entity_type . '_field_info');
$this->moduleHandler->alter($hooks, $this->entityFieldInfo[$entity_type], $entity_type);
$hooks = array('entity_field_info', $entity_type_id . '_field_info');
$this->moduleHandler->alter($hooks, $this->entityFieldInfo[$entity_type_id], $entity_type_id);
// Ensure all basic fields are not defined as translatable.
$keys = array_intersect_key(array_filter($entity_info->getKeys()), array_flip(array('id', 'revision', 'uuid', 'bundle')));
$keys = array_intersect_key(array_filter($entity_type->getKeys()), array_flip(array('id', 'revision', 'uuid', 'bundle')));
$untranslatable_fields = array_flip(array('langcode') + $keys);
foreach (array('definitions', 'optional') as $key) {
foreach ($this->entityFieldInfo[$entity_type][$key] as $field_name => &$definition) {
foreach ($this->entityFieldInfo[$entity_type_id][$key] as $field_name => &$definition) {
if (isset($untranslatable_fields[$field_name]) && $definition->isTranslatable()) {
throw new \LogicException(String::format('The @field field cannot be translatable.', array('@field' => $definition->getLabel())));
}
}
}
$this->cache->set($cid, $this->entityFieldInfo[$entity_type], Cache::PERMANENT, array('entity_info' => TRUE, 'entity_field_info' => TRUE));
$this->cache->set($cid, $this->entityFieldInfo[$entity_type_id], Cache::PERMANENT, array('entity_info' => TRUE, 'entity_field_info' => TRUE));
}
}
if (!$bundle) {
return $this->entityFieldInfo[$entity_type]['definitions'];
return $this->entityFieldInfo[$entity_type_id]['definitions'];
}
else {
// Add in per-bundle fields.
if (!isset($this->fieldDefinitions[$entity_type][$bundle])) {
$this->fieldDefinitions[$entity_type][$bundle] = $this->entityFieldInfo[$entity_type]['definitions'];
if (isset($this->entityFieldInfo[$entity_type]['bundle map'][$bundle])) {
$this->fieldDefinitions[$entity_type][$bundle] += array_intersect_key($this->entityFieldInfo[$entity_type]['optional'], array_flip($this->entityFieldInfo[$entity_type]['bundle map'][$bundle]));
if (!isset($this->fieldDefinitions[$entity_type_id][$bundle])) {
$this->fieldDefinitions[$entity_type_id][$bundle] = $this->entityFieldInfo[$entity_type_id]['definitions'];
if (isset($this->entityFieldInfo[$entity_type_id]['bundle map'][$bundle])) {
$this->fieldDefinitions[$entity_type_id][$bundle] += array_intersect_key($this->entityFieldInfo[$entity_type_id]['optional'], array_flip($this->entityFieldInfo[$entity_type_id]['bundle map'][$bundle]));
}
}
return $this->fieldDefinitions[$entity_type][$bundle];
return $this->fieldDefinitions[$entity_type_id][$bundle];
}
}
......@@ -404,9 +404,9 @@ public function getAllBundleInfo() {
else {
$this->bundleInfo = $this->moduleHandler->invokeAll('entity_bundle_info');
// If no bundles are provided, use the entity type name and label.
foreach ($this->getDefinitions() as $type => $entity_info) {
foreach ($this->getDefinitions() as $type => $entity_type) {
if (!isset($this->bundleInfo[$type])) {
$this->bundleInfo[$type][$type]['label'] = $entity_info->getLabel();
$this->bundleInfo[$type][$type]['label'] = $entity_type->getLabel();
}
}
$this->moduleHandler->alter('entity_bundle_info', $this->bundleInfo);
......
......@@ -27,7 +27,7 @@ public function getEntityTypeLabels();
*
* If a bundle is passed, fields specific to this bundle are included.
*
* @param string $entity_type
* @param string $entity_type_id
* The entity type to get field definitions for. Only entity types that
* implement \Drupal\Core\Entity\ContentEntityInterface are supported.
* @param string $bundle
......@@ -40,7 +40,7 @@ public function getEntityTypeLabels();
* @see \Drupal\Core\TypedData\TypedDataManager::create()
* @see \Drupal\Core\Entity\EntityManager::getFieldDefinitionsByConstraints()
*/
public function getFieldDefinitions($entity_type, $bundle = NULL);
public function getFieldDefinitions($entity_type_id, $bundle = NULL);
/**
* Creates a new access controller instance.
......@@ -56,7 +56,7 @@ public function getAccessController($entity_type);
/**
* Returns the route information for an entity type's bundle.
*
* @param string $entity_type
* @param string $entity_type_id
* The entity type.
* @param string $bundle
* The name of the bundle.
......@@ -67,7 +67,7 @@ public function getAccessController($entity_type);
* - route_parameters: (optional) An associative array of parameter names
* and values.
*/
public function getAdminRouteInfo($entity_type, $bundle);
public function getAdminRouteInfo($entity_type_id, $bundle);
/**
* Gets an array of entity field definitions based on validation constraints.
......
......@@ -61,12 +61,12 @@ abstract class EntityStorageControllerBase extends EntityControllerBase implemen
/**
* Constructs an EntityStorageControllerBase instance.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_info
* The entity info for the entity type.
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type definition.
*/
public function __construct(EntityTypeInterface $entity_info) {
$this->entityTypeId = $entity_info->id();
$this->entityType = $entity_info;
public function __construct(EntityTypeInterface $entity_type) {
$this->entityTypeId = $entity_type->id();
$this->entityType = $entity_type;
// Check if the entity type supports static caching of loaded entities.
$this->cache = $this->entityType->isStaticallyCacheable();
}
......
......@@ -60,16 +60,16 @@ class EntityViewBuilder extends EntityControllerBase implements EntityController
/**
* Constructs a new EntityViewBuilder.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_info
* The entity information array.
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type definition.
* @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager
* The entity manager service.
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
* The language manager.
*/
public function __construct(EntityTypeInterface $entity_info, EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager) {
$this->entityTypeId = $entity_info->id();
$this->entityType = $entity_info;
public function __construct(EntityTypeInterface $entity_type, EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager) {
$this->entityTypeId = $entity_type->id();
$this->entityType = $entity_type;
$this->entityManager = $entity_manager;
$this->languageManager = $language_manager;
}
......@@ -77,9 +77,9 @@ public function __construct(EntityTypeInterface $entity_info, EntityManagerInter
/**
* {@inheritdoc}
*/
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_info) {
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static(
$entity_info,
$entity_type,
$container->get('entity.manager'),
$container->get('language_manager')
);
......
......@@ -63,8 +63,6 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
/**
* Whether this entity type should use the static cache.
*
* Set by entity info.
*
* @var boolean
*/
protected $cache;
......@@ -86,9 +84,9 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
/**
* {@inheritdoc}
*/
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_info) {
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static(
$entity_info,
$entity_type,
$container->get('database'),
$container->get('field.info')
);
......@@ -97,15 +95,15 @@ public static function createInstance(ContainerInterface $container, EntityTypeI
/**
* Constructs a DatabaseStorageController object.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_info
* The entity info for the entity type.
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type definition.
* @param \Drupal\Core\Database\Connection $database
* The database connection to be used.
* @param \Drupal\field\FieldInfo $field_info
* The field info service.
*/
public function __construct(EntityTypeInterface $entity_info, Connection $database, FieldInfo $field_info) {
parent::__construct($entity_info);
public function __construct(EntityTypeInterface $entity_type, Connection $database, FieldInfo $field_info) {
parent::__construct($entity_type);
$this->database = $database;
$this->fieldInfo = $field_info;
......@@ -1187,13 +1185,13 @@ public static function _fieldSqlSchema(FieldInterface $field, array $schema = NU
$description_revision = "Revision archive storage for {$field->entity_type} field {$field->getName()}.";
}
$entity_type = $field->entity_type;
$entity_type_id = $field->entity_type;
$entity_manager = \Drupal::entityManager();
$info = $entity_manager->getDefinition($entity_type);
$definitions = $entity_manager->getFieldDefinitions($entity_type);
$entity_type = $entity_manager->getDefinition($entity_type_id);
$definitions = $entity_manager->getFieldDefinitions($entity_type_id);
// Define the entity ID schema based on the field definitions.
$id_definition = $definitions[$info->getKey('id')];
$id_definition = $definitions[$entity_type->getKey('id')];
if ($id_definition->getType() == 'integer') {
$id_schema = array(
'type' => 'int',
......@@ -1213,7 +1211,7 @@ public static function _fieldSqlSchema(FieldInterface $field, array $schema = NU
// Define the revision ID schema, default to integer if there is no revision
// ID.
$revision_id_definition = $info->hasKey('revision_id') ? $definitions[$info->getKey('revision_id')] : NULL;
$revision_id_definition = $entity_type->hasKey('revision_id') ? $definitions[$entity_type->getKey('revision_id')] : NULL;
if (!$revision_id_definition || $revision_id_definition->getType() == 'integer') {
$revision_id_schema = array(
'type' => 'int',
......
......@@ -33,11 +33,11 @@ abstract class FieldableEntityStorageControllerBase extends EntityStorageControl
/**
* Constructs a FieldableEntityStorageControllerBase object.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_info
* The entity info for the entity type.
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type definition.
*/