Issue #2164827 by Berdir, Xano, tim.plunkett: Rename the entityInfo() and entityType() methods on EntityInterface and EntityStorageControllerInterface.
parent
aa03c3dd54
commit
20315e1de7
|
@ -501,7 +501,7 @@ function entity_list_controller($entity_type) {
|
|||
* A render array for the entity.
|
||||
*/
|
||||
function entity_view(EntityInterface $entity, $view_mode, $langcode = NULL, $reset = FALSE) {
|
||||
$render_controller = \Drupal::entityManager()->getViewBuilder($entity->entityType());
|
||||
$render_controller = \Drupal::entityManager()->getViewBuilder($entity->getEntityTypeId());
|
||||
if ($reset) {
|
||||
$render_controller->resetCache(array($entity->id()));
|
||||
}
|
||||
|
@ -511,7 +511,7 @@ function entity_view(EntityInterface $entity, $view_mode, $langcode = NULL, $res
|
|||
/**
|
||||
* Returns the render array for the provided entities.
|
||||
*
|
||||
* @param array $entities
|
||||
* @param \Drupal\Core\Entity\EntityInterface[] $entities
|
||||
* The entities to be rendered, must be of the same type.
|
||||
* @param string $view_mode
|
||||
* The view mode that should be used to display the entity.
|
||||
|
@ -527,7 +527,7 @@ function entity_view(EntityInterface $entity, $view_mode, $langcode = NULL, $res
|
|||
* entities array passed in $entities.
|
||||
*/
|
||||
function entity_view_multiple(array $entities, $view_mode, $langcode = NULL, $reset = FALSE) {
|
||||
$render_controller = \Drupal::entityManager()->getViewBuilder(reset($entities)->entityType());
|
||||
$render_controller = \Drupal::entityManager()->getViewBuilder(reset($entities)->getEntityTypeId());
|
||||
if ($reset) {
|
||||
$render_controller->resetCache(array_keys($entities));
|
||||
}
|
||||
|
@ -619,7 +619,7 @@ function entity_get_display($entity_type, $bundle, $view_mode) {
|
|||
* @see entity_get_display().
|
||||
*/
|
||||
function entity_get_render_display(EntityInterface $entity, $view_mode) {
|
||||
$entity_type = $entity->entityType();
|
||||
$entity_type = $entity->getEntityTypeId();
|
||||
$bundle = $entity->bundle();
|
||||
$render_view_mode = 'default';
|
||||
|
||||
|
@ -727,7 +727,7 @@ function entity_get_form_display($entity_type, $bundle, $form_mode) {
|
|||
* @see entity_get_form_display().
|
||||
*/
|
||||
function entity_get_render_form_display(EntityInterface $entity, $form_mode) {
|
||||
$entity_type = $entity->entityType();
|
||||
$entity_type = $entity->getEntityTypeId();
|
||||
$bundle = $entity->bundle();
|
||||
$render_form_mode = 'default';
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ class ConfigEntityListController extends EntityListController {
|
|||
|
||||
// Sort the entities using the entity class's sort() method.
|
||||
// See \Drupal\Core\Config\Entity\ConfigEntityBase::sort().
|
||||
uasort($entities, array($this->entityInfo->getClass(), 'sort'));
|
||||
uasort($entities, array($this->entityType->getClass(), 'sort'));
|
||||
return $entities;
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ class ConfigEntityListController extends EntityListController {
|
|||
$operations['edit']['href'] = $uri['path'];
|
||||
}
|
||||
|
||||
if ($this->entityInfo->hasKey('status')) {
|
||||
if ($this->entityType->hasKey('status')) {
|
||||
if (!$entity->status()) {
|
||||
$operations['enable'] = array(
|
||||
'title' => t('Enable'),
|
||||
|
|
|
@ -96,8 +96,8 @@ class ConfigStorageController extends EntityStorageControllerBase implements Con
|
|||
public function __construct(EntityTypeInterface $entity_info, ConfigFactory $config_factory, StorageInterface $config_storage, QueryFactory $entity_query_factory, UuidInterface $uuid_service) {
|
||||
parent::__construct($entity_info);
|
||||
|
||||
$this->idKey = $this->entityInfo->getKey('id');
|
||||
$this->statusKey = $this->entityInfo->getKey('status');
|
||||
$this->idKey = $this->entityType->getKey('id');
|
||||
$this->statusKey = $this->entityType->getKey('status');
|
||||
|
||||
$this->configFactory = $config_factory;
|
||||
$this->configStorage = $config_storage;
|
||||
|
@ -183,14 +183,14 @@ class ConfigStorageController extends EntityStorageControllerBase implements Con
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getQuery($conjunction = 'AND') {
|
||||
return $this->entityQueryFactory->get($this->entityType, $conjunction);
|
||||
return $this->entityQueryFactory->get($this->entityTypeId, $conjunction);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getConfigPrefix() {
|
||||
return $this->entityInfo->getConfigPrefix() . '.';
|
||||
return $this->entityType->getConfigPrefix() . '.';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -222,7 +222,7 @@ class ConfigStorageController extends EntityStorageControllerBase implements Con
|
|||
* A SelectQuery object for loading the entity.
|
||||
*/
|
||||
protected function buildQuery($ids, $revision_id = FALSE) {
|
||||
$config_class = $this->entityInfo->getClass();
|
||||
$config_class = $this->entityType->getClass();
|
||||
$prefix = $this->getConfigPrefix();
|
||||
|
||||
// Get the names of the configuration entities we are going to load.
|
||||
|
@ -240,7 +240,7 @@ class ConfigStorageController extends EntityStorageControllerBase implements Con
|
|||
// Load all of the configuration entities.
|
||||
$result = array();
|
||||
foreach ($this->configFactory->loadMultiple($names) as $config) {
|
||||
$result[$config->get($this->idKey)] = new $config_class($config->get(), $this->entityType);
|
||||
$result[$config->get($this->idKey)] = new $config_class($config->get(), $this->entityTypeId);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
@ -249,13 +249,13 @@ class ConfigStorageController extends EntityStorageControllerBase implements Con
|
|||
* Implements Drupal\Core\Entity\EntityStorageControllerInterface::create().
|
||||
*/
|
||||
public function create(array $values) {
|
||||
$class = $this->entityInfo->getClass();
|
||||
$class = $this->entityType->getClass();
|
||||
$class::preCreate($this, $values);
|
||||
|
||||
// Set default language to site default if not provided.
|
||||
$values += array('langcode' => language_default()->id);
|
||||
|
||||
$entity = new $class($values, $this->entityType);
|
||||
$entity = new $class($values, $this->entityTypeId);
|
||||
// Mark this entity as new, so isNew() returns TRUE. This does not check
|
||||
// whether a configuration entity with the same ID (if any) already exists.
|
||||
$entity->enforceIsNew();
|
||||
|
@ -287,7 +287,7 @@ class ConfigStorageController extends EntityStorageControllerBase implements Con
|
|||
return;
|
||||
}
|
||||
|
||||
$entity_class = $this->entityInfo->getClass();
|
||||
$entity_class = $this->entityType->getClass();
|
||||
$entity_class::preDelete($this, $entities);
|
||||
foreach ($entities as $entity) {
|
||||
$this->invokeHook('predelete', $entity);
|
||||
|
@ -328,7 +328,7 @@ class ConfigStorageController extends EntityStorageControllerBase implements Con
|
|||
|
||||
// Prevent overwriting an existing configuration file if the entity is new.
|
||||
if ($entity->isNew() && !$config->isNew()) {
|
||||
throw new EntityStorageException(String::format('@type entity with ID @id already exists.', array('@type' => $this->entityType, '@id' => $id)));
|
||||
throw new EntityStorageException(String::format('@type entity with ID @id already exists.', array('@type' => $this->entityTypeId, '@id' => $id)));
|
||||
}
|
||||
|
||||
if (!$config->isNew() && !isset($entity->original)) {
|
||||
|
@ -389,9 +389,9 @@ class ConfigStorageController extends EntityStorageControllerBase implements Con
|
|||
*/
|
||||
protected function invokeHook($hook, EntityInterface $entity) {
|
||||
// Invoke the hook.
|
||||
module_invoke_all($this->entityType . '_' . $hook, $entity);
|
||||
module_invoke_all($this->entityTypeId . '_' . $hook, $entity);
|
||||
// Invoke the respective entity-level hook.
|
||||
module_invoke_all('entity_' . $hook, $entity, $this->entityType);
|
||||
module_invoke_all('entity_' . $hook, $entity, $this->entityTypeId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -415,7 +415,7 @@ class ConfigStorageController extends EntityStorageControllerBase implements Con
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function importUpdate($name, Config $new_config, Config $old_config) {
|
||||
$id = static::getIDFromConfigName($name, $this->entityInfo->getConfigPrefix());
|
||||
$id = static::getIDFromConfigName($name, $this->entityType->getConfigPrefix());
|
||||
$entity = $this->load($id);
|
||||
$entity->setSyncing(TRUE);
|
||||
$entity->original = clone $entity;
|
||||
|
@ -436,7 +436,7 @@ class ConfigStorageController extends EntityStorageControllerBase implements Con
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function importDelete($name, Config $new_config, Config $old_config) {
|
||||
$id = static::getIDFromConfigName($name, $this->entityInfo->getConfigPrefix());
|
||||
$id = static::getIDFromConfigName($name, $this->entityType->getConfigPrefix());
|
||||
$entity = $this->load($id);
|
||||
$entity->setSyncing(TRUE);
|
||||
$entity->delete();
|
||||
|
|
|
@ -52,8 +52,8 @@ abstract class DraggableListController extends ConfigEntityListController implem
|
|||
parent::__construct($entity_info, $storage);
|
||||
|
||||
// Check if the entity type supports weighting.
|
||||
if ($this->entityInfo->hasKey('weight')) {
|
||||
$this->weightKey = $this->entityInfo->getKey('weight');
|
||||
if ($this->entityType->hasKey('weight')) {
|
||||
$this->weightKey = $this->entityType->getKey('weight');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ abstract class DraggableListController extends ConfigEntityListController implem
|
|||
$form[$this->entitiesKey] = array(
|
||||
'#type' => 'table',
|
||||
'#header' => $this->buildHeader(),
|
||||
'#empty' => t('There is no @label yet.', array('@label' => $this->entityInfo->getLabel())),
|
||||
'#empty' => t('There is no @label yet.', array('@label' => $this->entityType->getLabel())),
|
||||
'#tabledrag' => array(
|
||||
array(
|
||||
'action' => 'order',
|
||||
|
|
|
@ -132,8 +132,8 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
|
|||
* Overrides Entity::__construct().
|
||||
*/
|
||||
public function __construct(array $values, $entity_type, $bundle = FALSE, $translations = array()) {
|
||||
$this->entityType = $entity_type;
|
||||
$this->bundle = $bundle ? $bundle : $this->entityType;
|
||||
$this->entityTypeId = $entity_type;
|
||||
$this->bundle = $bundle ? $bundle : $this->entityTypeId;
|
||||
$this->languages = language_list(Language::STATE_ALL);
|
||||
|
||||
foreach ($values as $key => $value) {
|
||||
|
@ -172,7 +172,7 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function isNewRevision() {
|
||||
return $this->newRevision || ($this->entityInfo()->hasKey('revision') && !$this->getRevisionId());
|
||||
return $this->newRevision || ($this->getEntityType()->hasKey('revision') && !$this->getRevisionId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -198,7 +198,7 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
|
|||
*/
|
||||
public function isTranslatable() {
|
||||
// @todo Inject the entity manager and retrieve bundle info from it.
|
||||
$bundles = entity_get_bundles($this->entityType);
|
||||
$bundles = entity_get_bundles($this->entityTypeId);
|
||||
return !empty($bundles[$this->bundle()]['translatable']);
|
||||
}
|
||||
|
||||
|
@ -214,11 +214,11 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
|
|||
public function getDefinition() {
|
||||
// @todo: This does not make much sense, so remove once TypedDataInterface
|
||||
// is removed. See https://drupal.org/node/2002138.
|
||||
if ($this->bundle() != $this->entityType()) {
|
||||
$type = 'entity:' . $this->entityType() . ':' . $this->bundle();
|
||||
if ($this->bundle() != $this->getEntityTypeId()) {
|
||||
$type = 'entity:' . $this->getEntityTypeId() . ':' . $this->bundle();
|
||||
}
|
||||
else {
|
||||
$type = 'entity:' . $this->entityType();
|
||||
$type = 'entity:' . $this->getEntityTypeId();
|
||||
}
|
||||
return DataDefinition::create($type);
|
||||
}
|
||||
|
@ -485,8 +485,8 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
|
|||
*/
|
||||
public function getPropertyDefinitions() {
|
||||
if (!isset($this->fieldDefinitions)) {
|
||||
$bundle = $this->bundle != $this->entityType ? $this->bundle : NULL;
|
||||
$this->fieldDefinitions = \Drupal::entityManager()->getFieldDefinitions($this->entityType, $bundle);
|
||||
$bundle = $this->bundle != $this->entityTypeId ? $this->bundle : NULL;
|
||||
$this->fieldDefinitions = \Drupal::entityManager()->getFieldDefinitions($this->entityTypeId, $bundle);
|
||||
}
|
||||
return $this->fieldDefinitions;
|
||||
}
|
||||
|
@ -532,11 +532,11 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
|
|||
public function access($operation = 'view', AccountInterface $account = NULL) {
|
||||
if ($operation == 'create') {
|
||||
return \Drupal::entityManager()
|
||||
->getAccessController($this->entityType)
|
||||
->getAccessController($this->entityTypeId)
|
||||
->createAccess($this->bundle(), $account);
|
||||
}
|
||||
return \Drupal::entityManager()
|
||||
->getAccessController($this->entityType)
|
||||
->getAccessController($this->entityTypeId)
|
||||
->access($this, $operation, $this->activeLangcode, $account);
|
||||
}
|
||||
|
||||
|
@ -716,10 +716,10 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
|
|||
|
||||
// Instantiate a new empty entity so default values will be populated in the
|
||||
// specified language.
|
||||
$info = $this->entityInfo();
|
||||
$info = $this->getEntityType();
|
||||
$default_values = array($info->getKey('bundle') => $this->bundle, 'langcode' => $langcode);
|
||||
$entity = \Drupal::entityManager()
|
||||
->getStorageController($this->entityType())
|
||||
->getStorageController($this->getEntityTypeId())
|
||||
->create($default_values);
|
||||
|
||||
foreach ($entity as $name => $field) {
|
||||
|
@ -902,7 +902,7 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
|
|||
}
|
||||
|
||||
$duplicate = clone $this;
|
||||
$entity_info = $this->entityInfo();
|
||||
$entity_info = $this->getEntityType();
|
||||
$duplicate->{$entity_info->getKey('id')}->value = NULL;
|
||||
|
||||
// Check if the entity type supports UUIDs and generate a new one if so.
|
||||
|
@ -955,7 +955,7 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
|
|||
*/
|
||||
public function label() {
|
||||
$label = NULL;
|
||||
$entity_info = $this->entityInfo();
|
||||
$entity_info = $this->getEntityType();
|
||||
// @todo Convert to is_callable() and call_user_func().
|
||||
if (($label_callback = $entity_info->getLabelCallback()) && function_exists($label_callback)) {
|
||||
$label = $label_callback($this);
|
||||
|
|
|
@ -19,7 +19,7 @@ abstract class ContentEntityConfirmFormBase extends ContentEntityFormController
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getBaseFormID() {
|
||||
return $this->entity->entityType() . '_confirm_form';
|
||||
return $this->entity->getEntityTypeId() . '_confirm_form';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -50,7 +50,7 @@ class ContentEntityFormController extends EntityFormController {
|
|||
$entity = $this->entity;
|
||||
// @todo Exploit the Field API to generate the default widgets for the
|
||||
// entity fields.
|
||||
if ($entity->entityInfo()->isFieldable()) {
|
||||
if ($entity->getEntityType()->isFieldable()) {
|
||||
field_attach_form($entity, $form, $form_state, $this->getFormLangcode($form_state));
|
||||
}
|
||||
|
||||
|
@ -66,7 +66,7 @@ class ContentEntityFormController extends EntityFormController {
|
|||
public function validate(array $form, array &$form_state) {
|
||||
$this->updateFormLangcode($form_state);
|
||||
$entity = $this->buildEntity($form, $form_state);
|
||||
$entity_type = $entity->entityType();
|
||||
$entity_type = $entity->getEntityTypeId();
|
||||
$entity_langcode = $entity->language()->id;
|
||||
|
||||
$violations = array();
|
||||
|
@ -130,7 +130,7 @@ class ContentEntityFormController extends EntityFormController {
|
|||
*/
|
||||
public function buildEntity(array $form, array &$form_state) {
|
||||
$entity = clone $this->entity;
|
||||
$entity_type = $entity->entityType();
|
||||
$entity_type = $entity->getEntityTypeId();
|
||||
$info = \Drupal::entityManager()->getDefinition($entity_type);
|
||||
|
||||
// @todo Exploit the Entity Field API to process the submitted field values.
|
||||
|
|
|
@ -62,7 +62,7 @@ class EntityViewController implements ContainerInjectionInterface {
|
|||
*/
|
||||
public function view(EntityInterface $_entity, $view_mode = 'full', $langcode = NULL) {
|
||||
return $this->entityManager
|
||||
->getViewBuilder($_entity->entityType())
|
||||
->getViewBuilder($_entity->getEntityTypeId())
|
||||
->view($_entity, $view_mode, $langcode);
|
||||
}
|
||||
|
||||
|
|
|
@ -86,10 +86,10 @@ class DatabaseStorageController extends EntityStorageControllerBase {
|
|||
$this->uuidService = $uuid_service;
|
||||
|
||||
// Check if the entity type supports IDs.
|
||||
$this->idKey = $this->entityInfo->getKey('id');
|
||||
$this->idKey = $this->entityType->getKey('id');
|
||||
|
||||
// Check if the entity type supports UUIDs.
|
||||
$this->uuidKey = $this->entityInfo->getKey('uuid');
|
||||
$this->uuidKey = $this->entityType->getKey('uuid');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -121,11 +121,11 @@ class DatabaseStorageController extends EntityStorageControllerBase {
|
|||
// Build and execute the query.
|
||||
$query_result = $this->buildQuery($ids)->execute();
|
||||
|
||||
if ($class = $this->entityInfo->getClass()) {
|
||||
if ($class = $this->entityType->getClass()) {
|
||||
// We provide the necessary arguments for PDO to create objects of the
|
||||
// specified entity class.
|
||||
// @see \Drupal\Core\Entity\EntityInterface::__construct()
|
||||
$query_result->setFetchMode(\PDO::FETCH_CLASS, $class, array(array(), $this->entityType));
|
||||
$query_result->setFetchMode(\PDO::FETCH_CLASS, $class, array(array(), $this->entityTypeId));
|
||||
}
|
||||
$queried_entities = $query_result->fetchAllAssoc($this->idKey);
|
||||
}
|
||||
|
@ -186,7 +186,7 @@ class DatabaseStorageController extends EntityStorageControllerBase {
|
|||
*/
|
||||
public function loadByProperties(array $values = array()) {
|
||||
// Build a query to fetch the entity IDs.
|
||||
$entity_query = \Drupal::entityQuery($this->entityType);
|
||||
$entity_query = \Drupal::entityQuery($this->entityTypeId);
|
||||
$this->buildPropertyQuery($entity_query, $values);
|
||||
$result = $entity_query->execute();
|
||||
return $result ? $this->loadMultiple($result) : array();
|
||||
|
@ -217,12 +217,12 @@ class DatabaseStorageController extends EntityStorageControllerBase {
|
|||
* A SelectQuery object for loading the entity.
|
||||
*/
|
||||
protected function buildQuery($ids, $revision_id = FALSE) {
|
||||
$query = $this->database->select($this->entityInfo->getBaseTable(), 'base');
|
||||
$query = $this->database->select($this->entityType->getBaseTable(), 'base');
|
||||
|
||||
$query->addTag($this->entityType . '_load_multiple');
|
||||
$query->addTag($this->entityTypeId . '_load_multiple');
|
||||
|
||||
// Add fields from the {entity} table.
|
||||
$entity_fields = drupal_schema_fields_sql($this->entityInfo->getBaseTable());
|
||||
$entity_fields = drupal_schema_fields_sql($this->entityType->getBaseTable());
|
||||
$query->fields('base', $entity_fields);
|
||||
|
||||
if ($ids) {
|
||||
|
@ -236,10 +236,10 @@ class DatabaseStorageController extends EntityStorageControllerBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function create(array $values) {
|
||||
$entity_class = $this->entityInfo->getClass();
|
||||
$entity_class = $this->entityType->getClass();
|
||||
$entity_class::preCreate($this, $values);
|
||||
|
||||
$entity = new $entity_class($values, $this->entityType);
|
||||
$entity = new $entity_class($values, $this->entityTypeId);
|
||||
|
||||
// Assign a new UUID if there is none yet.
|
||||
if ($this->uuidKey && !isset($entity->{$this->uuidKey})) {
|
||||
|
@ -265,14 +265,14 @@ class DatabaseStorageController extends EntityStorageControllerBase {
|
|||
$transaction = $this->database->startTransaction();
|
||||
|
||||
try {
|
||||
$entity_class = $this->entityInfo->getClass();
|
||||
$entity_class = $this->entityType->getClass();
|
||||
$entity_class::preDelete($this, $entities);
|
||||
foreach ($entities as $entity) {
|
||||
$this->invokeHook('predelete', $entity);
|
||||
}
|
||||
$ids = array_keys($entities);
|
||||
|
||||
$this->database->delete($this->entityInfo->getBaseTable())
|
||||
$this->database->delete($this->entityType->getBaseTable())
|
||||
->condition($this->idKey, $ids, 'IN')
|
||||
->execute();
|
||||
|
||||
|
@ -288,7 +288,7 @@ class DatabaseStorageController extends EntityStorageControllerBase {
|
|||
}
|
||||
catch (\Exception $e) {
|
||||
$transaction->rollback();
|
||||
watchdog_exception($this->entityType, $e);
|
||||
watchdog_exception($this->entityTypeId, $e);
|
||||
throw new EntityStorageException($e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
|
@ -301,20 +301,20 @@ class DatabaseStorageController extends EntityStorageControllerBase {
|
|||
try {
|
||||
// Load the stored entity, if any.
|
||||
if (!$entity->isNew() && !isset($entity->original)) {
|
||||
$entity->original = entity_load_unchanged($this->entityType, $entity->id());
|
||||
$entity->original = entity_load_unchanged($this->entityTypeId, $entity->id());
|
||||
}
|
||||
|
||||
$entity->preSave($this);
|
||||
$this->invokeHook('presave', $entity);
|
||||
|
||||
if (!$entity->isNew()) {
|
||||
$return = drupal_write_record($this->entityInfo->getBaseTable(), $entity, $this->idKey);
|
||||
$return = drupal_write_record($this->entityType->getBaseTable(), $entity, $this->idKey);
|
||||
$this->resetCache(array($entity->id()));
|
||||
$entity->postSave($this, TRUE);
|
||||
$this->invokeHook('update', $entity);
|
||||
}
|
||||
else {
|
||||
$return = drupal_write_record($this->entityInfo->getBaseTable(), $entity);
|
||||
$return = drupal_write_record($this->entityType->getBaseTable(), $entity);
|
||||
// Reset general caches, but keep caches specific to certain entities.
|
||||
$this->resetCache(array());
|
||||
|
||||
|
@ -331,7 +331,7 @@ class DatabaseStorageController extends EntityStorageControllerBase {
|
|||
}
|
||||
catch (\Exception $e) {
|
||||
$transaction->rollback();
|
||||
watchdog_exception($this->entityType, $e);
|
||||
watchdog_exception($this->entityTypeId, $e);
|
||||
throw new EntityStorageException($e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ abstract class Entity implements EntityInterface {
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $entityType;
|
||||
protected $entityTypeId;
|
||||
|
||||
/**
|
||||
* Boolean indicating whether the entity should be forced to be new.
|
||||
|
@ -61,7 +61,7 @@ abstract class Entity implements EntityInterface {
|
|||
* The type of the entity to create.
|
||||
*/
|
||||
public function __construct(array $values, $entity_type) {
|
||||
$this->entityType = $entity_type;
|
||||
$this->entityTypeId = $entity_type;
|
||||
// Set initial values.
|
||||
foreach ($values as $key => $value) {
|
||||
$this->$key = $value;
|
||||
|
@ -99,15 +99,15 @@ abstract class Entity implements EntityInterface {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function entityType() {
|
||||
return $this->entityType;
|
||||
public function getEntityTypeId() {
|
||||
return $this->entityTypeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function bundle() {
|
||||
return $this->entityType;
|
||||
return $this->entityTypeId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -115,7 +115,7 @@ abstract class Entity implements EntityInterface {
|
|||
*/
|
||||
public function label() {
|
||||
$label = NULL;
|
||||
$entity_info = $this->entityInfo();
|
||||
$entity_info = $this->getEntityType();
|
||||
// @todo Convert to is_callable() and call_user_func().
|
||||
if (($label_callback = $entity_info->getLabelCallback()) && function_exists($label_callback)) {
|
||||
$label = $label_callback($this);
|
||||
|
@ -155,7 +155,7 @@ abstract class Entity implements EntityInterface {
|
|||
* of the entity, and matching the signature of url().
|
||||
*/
|
||||
public function uri($rel = 'canonical') {
|
||||
$entity_info = $this->entityInfo();
|
||||
$entity_info = $this->getEntityType();
|
||||
|
||||
// The links array might contain URI templates set in annotations.
|
||||
$link_templates = $this->linkTemplates();
|
||||
|
@ -181,7 +181,7 @@ abstract class Entity implements EntityInterface {
|
|||
|
||||
// Pass the entity data to url() so that alter functions do not need to
|
||||
// look up this entity again.
|
||||
$uri['options']['entity_type'] = $this->entityType;
|
||||
$uri['options']['entity_type'] = $this->entityTypeId;
|
||||
$uri['options']['entity'] = $this;
|
||||
return $uri;
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ abstract class Entity implements EntityInterface {
|
|||
$bundle = $this->bundle();
|
||||
// A bundle-specific callback takes precedence over the generic one for
|
||||
// the entity type.
|
||||
$bundles = entity_get_bundles($this->entityType);
|
||||
$bundles = entity_get_bundles($this->entityTypeId);
|
||||
if (isset($bundles[$bundle]['uri_callback'])) {
|
||||
$uri_callback = $bundles[$bundle]['uri_callback'];
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ abstract class Entity implements EntityInterface {
|
|||
// Other relationship types are not supported by this logic.
|
||||
elseif ($rel == 'canonical') {
|
||||
$uri = array(
|
||||
'path' => 'entity/' . $this->entityType . '/' . $this->id(),
|
||||
'path' => 'entity/' . $this->entityTypeId . '/' . $this->id(),
|
||||
);
|
||||
}
|
||||
else {
|
||||
|
@ -227,7 +227,7 @@ abstract class Entity implements EntityInterface {
|
|||
* An array of link templates containing route names.
|
||||
*/
|
||||
protected function linkTemplates() {
|
||||
return $this->entityInfo()->getLinkTemplates();
|
||||
return $this->getEntityType()->getLinkTemplates();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -243,11 +243,11 @@ abstract class Entity implements EntityInterface {
|
|||
protected function uriPlaceholderReplacements() {
|
||||
if (empty($this->uriPlaceholderReplacements)) {
|
||||
$this->uriPlaceholderReplacements = array(
|
||||
'{entityType}' => $this->entityType(),
|
||||
'{entityType}' => $this->getEntityTypeId(),
|
||||
'{bundle}' => $this->bundle(),
|
||||
'{id}' => $this->id(),
|
||||
'{uuid}' => $this->uuid(),
|
||||
'{' . $this->entityType() . '}' => $this->id(),
|
||||
'{' . $this->getEntityTypeId() . '}' => $this->id(),
|
||||
);
|
||||
}
|
||||
return $this->uriPlaceholderReplacements;
|
||||
|
@ -271,11 +271,11 @@ abstract class Entity implements EntityInterface {
|
|||
public function access($operation = 'view', AccountInterface $account = NULL) {
|
||||
if ($operation == 'create') {
|
||||
return \Drupal::entityManager()
|
||||
->getAccessController($this->entityType)
|
||||
->getAccessController($this->entityTypeId)
|
||||
->createAccess($this->bundle(), $account);
|
||||
}
|
||||
return \Drupal::entityManager()
|
||||
->getAccessController($this->entityType)
|
||||
->getAccessController($this->entityTypeId)
|
||||
->access($this, $operation, Language::LANGCODE_DEFAULT, $account);
|
||||
}
|
||||
|
||||
|
@ -295,7 +295,7 @@ abstract class Entity implements EntityInterface {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function save() {
|
||||
return \Drupal::entityManager()->getStorageController($this->entityType)->save($this);
|
||||
return \Drupal::entityManager()->getStorageController($this->entityTypeId)->save($this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -303,7 +303,7 @@ abstract class Entity implements EntityInterface {
|
|||
*/
|
||||
public function delete() {
|
||||
if (!$this->isNew()) {
|
||||
\Drupal::entityManager()->getStorageController($this->entityType)->delete(array($this->id() => $this));
|
||||
\Drupal::entityManager()->getStorageController($this->entityTypeId)->delete(array($this->id() => $this));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -312,7 +312,7 @@ abstract class Entity implements EntityInterface {
|
|||
*/
|
||||
public function createDuplicate() {
|
||||
$duplicate = clone $this;
|
||||
$entity_info = $this->entityInfo();
|
||||
$entity_info = $this->getEntityType();
|
||||
$duplicate->{$entity_info->getKey('id')} = NULL;
|
||||
|
||||
// Check if the entity type supports UUIDs and generate a new one if so.
|
||||
|
@ -326,8 +326,8 @@ abstract class Entity implements EntityInterface {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function entityInfo() {
|
||||
return \Drupal::entityManager()->getDefinition($this->entityType());
|
||||
public function getEntityType() {
|
||||
return \Drupal::entityManager()->getDefinition($this->getEntityTypeId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -388,11 +388,11 @@ abstract class Entity implements EntityInterface {
|
|||
*/
|
||||
protected function onSaveOrDelete() {
|
||||
$referenced_entities = array(
|
||||
$this->entityType() => array($this->id() => $this),
|
||||
$this->getEntityTypeId() => array($this->id() => $this),
|
||||
);
|
||||
|
||||
foreach ($this->referencedEntities() as $referenced_entity) {
|
||||
$referenced_entities[$referenced_entity->entityType()][$referenced_entity->id()] = $referenced_entity;
|
||||
$referenced_entities[$referenced_entity->getEntityTypeId()][$referenced_entity->id()] = $referenced_entity;
|
||||
}
|
||||
|
||||
foreach ($referenced_entities as $entity_type => $entities) {
|
||||
|
|
|
@ -27,18 +27,18 @@ class EntityAccessController extends EntityControllerBase implements EntityAcces
|
|||
protected $accessCache = array();
|
||||
|
||||
/**
|
||||
* The entity type of the access controller instance.
|
||||
* The entity type ID of the access controller instance.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $entityType;
|
||||
protected $entityTypeId;
|
||||
|
||||
/**
|
||||
* The entity info array.
|
||||
* Information about the entity type.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityTypeInterface
|
||||
*/
|
||||
protected $entityInfo;
|
||||
protected $entityType;
|
||||
|
||||
/**
|
||||
* Constructs an access controller instance.
|
||||
|
@ -47,8 +47,8 @@ class EntityAccessController extends EntityControllerBase implements EntityAcces
|
|||
* The entity info for the entity type.
|
||||
*/
|
||||
public function __construct(EntityTypeInterface $entity_info) {
|
||||
$this->entityType = $entity_info->id();
|
||||
$this->entityInfo = $entity_info;
|
||||
$this->entityTypeId = $entity_info->id();
|
||||
$this->entityType = $entity_info;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -73,7 +73,7 @@ class EntityAccessController extends EntityControllerBase implements EntityAcces
|
|||
// - At least one module says to grant access.
|
||||
$access = array_merge(
|
||||
$this->moduleHandler()->invokeAll('entity_access', array($entity, $operation, $account, $langcode)),
|
||||
$this->moduleHandler()->invokeAll($entity->entityType() . '_access', array($entity, $operation, $account, $langcode))
|
||||
$this->moduleHandler()->invokeAll($entity->getEntityTypeId() . '_access', array($entity, $operation, $account, $langcode))
|
||||
);
|
||||
|
||||
if (($return = $this->processAccessHookResults($access)) === NULL) {
|
||||
|
@ -129,7 +129,7 @@ class EntityAccessController extends EntityControllerBase implements EntityAcces
|
|||
* could not be determined.
|
||||
*/
|
||||
protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) {
|
||||
if ($admin_permission = $this->entityInfo->getAdminPermission()) {
|
||||
if ($admin_permission = $this->entityType->getAdminPermission()) {
|
||||
return $account->hasPermission($admin_permission);
|
||||
}
|
||||
else {
|
||||
|
@ -220,7 +220,7 @@ class EntityAccessController extends EntityControllerBase implements EntityAcces
|
|||
// - At least one module says to grant access.
|
||||
$access = array_merge(
|
||||
$this->moduleHandler()->invokeAll('entity_create_access', array($account, $context['langcode'])),
|
||||
$this->moduleHandler()->invokeAll($this->entityType . '_create_access', array($account, $context['langcode']))
|
||||
$this->moduleHandler()->invokeAll($this->entityTypeId . '_create_access', array($account, $context['langcode']))
|
||||
);
|
||||
|
||||
if (($return = $this->processAccessHookResults($access)) === NULL) {
|
||||
|
@ -250,7 +250,7 @@ class EntityAccessController extends EntityControllerBase implements EntityAcces
|
|||
* could not be determined.
|
||||
*/
|
||||
protected function checkCreateAccess(AccountInterface $account, array $context, $entity_bundle = NULL) {
|
||||
if ($admin_permission = $this->entityInfo->getAdminPermission()) {
|
||||
if ($admin_permission = $this->entityType->getAdminPermission()) {
|
||||
return $account->hasPermission($admin_permission);
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -20,7 +20,7 @@ abstract class EntityConfirmFormBase extends EntityFormController implements Con
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getBaseFormID() {
|
||||
return $this->entity->entityType() . '_confirm_form';
|
||||
return $this->entity->getEntityTypeId() . '_confirm_form';
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -59,7 +59,7 @@ class EntityFormController extends FormBase implements EntityFormControllerInter
|
|||
// hook_form_alter(), #validate, #submit, and #theme callbacks, but only if
|
||||
// it is different from the actual form ID, since callbacks would be invoked
|
||||
// twice otherwise.
|
||||
$base_form_id = $this->entity->entityType() . '_form';
|
||||
$base_form_id = $this->entity->getEntityTypeId() . '_form';
|
||||
if ($base_form_id == $this->getFormId()) {
|
||||
$base_form_id = NULL;
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ class EntityFormController extends FormBase implements EntityFormControllerInter
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFormId() {
|
||||
$entity_type = $this->entity->entityType();
|
||||
$entity_type = $this->entity->getEntityTypeId();
|
||||
$bundle = $this->entity->bundle();
|
||||
$form_id = $entity_type;
|
||||
if ($bundle != $entity_type) {
|
||||
|
@ -126,7 +126,7 @@ class EntityFormController extends FormBase implements EntityFormControllerInter
|
|||
|
||||
// Invoke the prepare form hooks.
|
||||
$this->prepareInvokeAll('entity_prepare_form', $form_state);
|
||||
$this->prepareInvokeAll($this->entity->entityType() . '_prepare_form', $form_state);
|
||||
$this->prepareInvokeAll($this->entity->getEntityTypeId() . '_prepare_form', $form_state);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -138,7 +138,7 @@ class EntityFormController extends FormBase implements EntityFormControllerInter
|
|||
$entity = $this->entity;
|
||||
// @todo Exploit the Field API to generate the default widgets for the
|
||||
// entity properties.
|
||||
if ($entity->entityInfo()->isFieldable()) {
|
||||
if ($entity->getEntityType()->isFieldable()) {
|
||||
field_attach_form($entity, $form, $form_state, $this->getFormLangcode($form_state));
|
||||
}
|
||||
|
||||
|
@ -175,7 +175,7 @@ class EntityFormController extends FormBase implements EntityFormControllerInter
|
|||
}
|
||||
|
||||
// Hide or assign weights for extra fields.
|
||||
$extra_fields = field_info_extra_fields($this->entity->entityType(), $this->entity->bundle(), 'form');
|
||||
$extra_fields = field_info_extra_fields($this->entity->getEntityTypeId(), $this->entity->bundle(), 'form');
|
||||
foreach ($extra_fields as $extra_field => $info) {
|
||||
$component = $this->getFormDisplay($form_state)->getComponent($extra_field);
|
||||
if (!$component) {
|
||||
|
@ -364,7 +364,7 @@ class EntityFormController extends FormBase implements EntityFormControllerInter
|
|||
// properties.
|
||||
if (isset($form['#entity_builders'])) {
|
||||
foreach ($form['#entity_builders'] as $function) {
|
||||
call_user_func_array($function, array($entity->entityType(), $entity, &$form, &$form_state));
|
||||
call_user_func_array($function, array($entity->getEntityTypeId(), $entity, &$form, &$form_state));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -72,17 +72,17 @@ interface EntityInterface extends AccessibleInterface {
|
|||
/**
|
||||
* Returns the type of the entity.
|
||||
*
|
||||
* @return
|
||||
* The type of the entity.
|
||||
* @return string
|
||||
* The entity type ID.
|
||||
*/
|
||||
public function entityType();
|
||||
public function getEntityTypeId();
|
||||
|
||||
/**
|
||||
* Returns the bundle of the entity.
|
||||
*
|
||||
* @return
|
||||
* The bundle of the entity. Defaults to the entity type if the entity type
|
||||
* does not make use of different bundles.
|
||||
* The bundle of the entity. Defaults to the entity type ID if the entity
|
||||
* type does not make use of different bundles.
|
||||
*/
|
||||
public function bundle();
|
||||
|
||||
|
@ -221,11 +221,12 @@ interface EntityInterface extends AccessibleInterface {
|
|||
public function createDuplicate();
|
||||
|
||||
/**
|
||||
* Returns the info of the type of the entity.
|
||||
* Returns the entity type definition.
|
||||
*
|
||||
* @return \Drupal\Core\Entity\EntityTypeInterface
|
||||
* Entity type definition.
|
||||
*/
|
||||
public function entityInfo();
|
||||
public function getEntityType();
|
||||
|
||||
/**
|
||||
* Returns a list of entities referenced by this entity.
|
||||
|
|
|
@ -25,18 +25,18 @@ class EntityListController extends EntityControllerBase implements EntityListCon
|
|||
protected $storage;
|
||||
|
||||
/**
|
||||
* The entity type name.
|
||||
* The entity type ID.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $entityType;
|
||||
protected $entityTypeId;
|
||||
|
||||
/**
|
||||
* The entity info array.
|
||||
* Information about the entity type.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityTypeInterface
|
||||
*/
|
||||
protected $entityInfo;
|
||||
protected $entityType;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -57,9 +57,9 @@ class EntityListController extends EntityControllerBase implements EntityListCon
|
|||
* The entity storage controller class.
|
||||
*/
|
||||
public function __construct(EntityTypeInterface $entity_info, EntityStorageControllerInterface $storage) {
|
||||
$this->entityType = $entity_info->id();
|
||||
$this->entityTypeId = $entity_info->id();
|
||||
$this->storage = $storage;
|
||||
$this->entityInfo = $entity_info;
|
||||
$this->entityType = $entity_info;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -181,7 +181,7 @@ class EntityListController extends EntityControllerBase implements EntityListCon
|
|||
'#header' => $this->buildHeader(),
|
||||
'#title' => $this->getTitle(),
|
||||
'#rows' => array(),
|
||||
'#empty' => $this->t('There is no @label yet.', array('@label' => $this->entityInfo->getLabel())),
|
||||
'#empty' => $this->t('There is no @label yet.', array('@label' => $this->entityType->getLabel())),
|
||||
);
|
||||
foreach ($this->load() as $entity) {
|
||||
if ($row = $this->buildRow($entity)) {
|
||||
|
|
|
@ -284,7 +284,7 @@ class EntityManager extends PluginManagerBase implements EntityManagerInterface
|
|||
*/
|
||||
public function getForm(EntityInterface $entity, $operation = 'default', array $form_state = array()) {
|
||||
$form_state['build_info'] = isset($form_state['build_info']) ? $form_state['build_info'] : array();
|
||||
$controller = $this->getFormController($entity->entityType(), $operation);
|
||||
$controller = $this->getFormController($entity->getEntityTypeId(), $operation);
|
||||
$controller->setEntity($entity);
|
||||
$form_state['build_info'] += array(
|
||||
'callback_object' => $controller,
|
||||
|
|
|
@ -24,25 +24,23 @@ abstract class EntityStorageControllerBase extends EntityControllerBase implemen
|
|||
/**
|
||||
* Whether this entity type should use the static cache.
|
||||
*
|
||||
* Set by entity info.
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $cache;
|
||||
|
||||
/**
|
||||
* Entity type for this controller instance.
|
||||
* Entity type ID for this controller instance.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $entityType;
|
||||
protected $entityTypeId;
|
||||
|
||||
/**
|
||||
* Array of information about the entity.
|
||||
* Information about the entity type.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityTypeInterface
|
||||
*/
|
||||
protected $entityInfo;
|
||||
protected $entityType;
|
||||
|
||||
/**
|
||||
* Name of the entity's ID field in the entity database table.
|
||||
|
@ -67,26 +65,26 @@ abstract class EntityStorageControllerBase extends EntityControllerBase implemen
|
|||
* The entity info for the entity type.
|
||||
*/
|
||||
public function __construct(EntityTypeInterface $entity_info) {
|
||||
$this->entityType = $entity_info->id();
|
||||
$this->entityInfo = $entity_info;
|
||||
$this->entityTypeId = $entity_info->id();
|
||||
$this->entityType = $entity_info;
|
||||
// Check if the entity type supports static caching of loaded entities.
|
||||
$this->cache = $this->entityInfo->isStaticallyCacheable();
|
||||
$this->cache = $this->entityType->isStaticallyCacheable();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function entityType() {
|
||||
public function getEntityTypeId() {
|
||||
return $this->entityTypeId;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getEntityType() {
|
||||
return $this->entityType;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function entityInfo() {
|
||||
return $this->entityInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -150,9 +148,9 @@ abstract class EntityStorageControllerBase extends EntityControllerBase implemen
|
|||
*/
|
||||
protected function invokeHook($hook, EntityInterface $entity) {
|
||||
// Invoke the hook.
|
||||
$this->moduleHandler()->invokeAll($this->entityType . '_' . $hook, array($entity));
|
||||
$this->moduleHandler()->invokeAll($this->entityTypeId . '_' . $hook, array($entity));
|
||||
// Invoke the respective entity-level hook.
|
||||
$this->moduleHandler()->invokeAll('entity_' . $hook, array($entity, $this->entityType));
|
||||
$this->moduleHandler()->invokeAll('entity_' . $hook, array($entity, $this->entityTypeId));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -162,16 +160,16 @@ abstract class EntityStorageControllerBase extends EntityControllerBase implemen
|
|||
* Associative array of query results, keyed on the entity ID.
|
||||
*/
|
||||
protected function postLoad(array &$queried_entities) {
|
||||
$entity_class = $this->entityInfo->getClass();
|
||||
$entity_class = $this->entityType->getClass();
|
||||
$entity_class::postLoad($this, $queried_entities);
|
||||
// Call hook_entity_load().
|
||||
foreach ($this->moduleHandler()->getImplementations('entity_load') as $module) {
|
||||
$function = $module . '_entity_load';
|
||||
$function($queried_entities, $this->entityType);
|
||||
$function($queried_entities, $this->entityTypeId);
|
||||
}
|
||||
// Call hook_TYPE_load().
|
||||
foreach ($this->moduleHandler()->getImplementations($this->entityType . '_load') as $module) {
|
||||
$function = $module . '_' . $this->entityType . '_load';
|
||||
foreach ($this->moduleHandler()->getImplementations($this->entityTypeId . '_load') as $module) {
|
||||
$function = $module . '_' . $this->entityTypeId . '_load';
|
||||
$function($queried_entities);
|
||||
}
|
||||
}
|
||||
|
@ -196,7 +194,7 @@ abstract class EntityStorageControllerBase extends EntityControllerBase implemen
|
|||
*/
|
||||
public function loadByProperties(array $values = array()) {
|
||||
// Build a query to fetch the entity IDs.
|
||||
$entity_query = \Drupal::entityQuery($this->entityType);
|
||||
$entity_query = \Drupal::entityQuery($this->entityTypeId);
|
||||
$this->buildPropertyQuery($entity_query, $values);
|
||||
$result = $entity_query->execute();
|
||||
return $result ? $this->loadMultiple($result) : array();
|
||||
|
|
|
@ -155,19 +155,19 @@ interface EntityStorageControllerInterface {
|
|||
public function getQueryServicename();
|
||||
|
||||
/**
|
||||
* Returns the entity type.
|
||||
* Returns the entity type ID.
|
||||
*
|
||||
* @return string
|
||||
* The entity type.
|
||||
* The entity type ID.
|
||||
*/
|
||||
public function entityType();
|
||||
public function getEntityTypeId();
|
||||
|
||||
/**
|
||||
* Returns the entity info.
|
||||
* Returns the entity type definition.
|
||||
*
|
||||
* @return string
|
||||
* The entity info.
|
||||
* @return \Drupal\Core\Entity\EntityTypeInterface
|
||||
* Entity type definition.
|
||||
*/
|
||||
public function entityInfo();
|
||||
public function getEntityType();
|
||||
|
||||
}
|
||||
|
|
|
@ -24,14 +24,14 @@ class EntityViewBuilder extends EntityControllerBase implements EntityController
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $entityType;
|
||||
protected $entityTypeId;
|
||||
|
||||
/**
|
||||
* The entity info array.
|
||||
* Information about the entity type.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityTypeInterface
|
||||
*/
|
||||
protected $entityInfo;
|
||||
protected $entityType;
|
||||
|
||||
/**
|
||||
* The entity manager service.
|
||||
|
@ -68,8 +68,8 @@ class EntityViewBuilder extends EntityControllerBase implements EntityController
|
|||
* The language manager.
|
||||
*/
|
||||
public function __construct(EntityTypeInterface $entity_info, EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager) {
|
||||
$this->entityType = $entity_info->id();
|
||||
$this->entityInfo = $entity_info;
|
||||
$this->entityTypeId = $entity_info->id();
|
||||
$this->entityType = $entity_info;
|
||||
$this->entityManager = $entity_manager;
|
||||
$this->languageManager = $language_manager;
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ class EntityViewBuilder extends EntityControllerBase implements EntityController
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildContent(array $entities, array $displays, $view_mode, $langcode = NULL) {
|
||||
field_attach_prepare_view($this->entityType, $entities, $displays, $langcode);
|
||||
field_attach_prepare_view($this->entityTypeId, $entities, $displays, $langcode);
|
||||
|
||||
// Initialize the field item attributes for the fields set to be displayed.
|
||||
foreach ($entities as $entity) {
|
||||
|
@ -108,7 +108,7 @@ class EntityViewBuilder extends EntityControllerBase implements EntityController
|
|||
}
|
||||
}
|
||||
|
||||
module_invoke_all('entity_prepare_view', $this->entityType, $entities, $displays, $view_mode);
|
||||
module_invoke_all('entity_prepare_view', $this->entityTypeId, $entities, $displays, $view_mode);
|
||||
|
||||
foreach ($entities as $entity) {
|
||||
// Remove previously built content, if exists.
|
||||
|
@ -134,22 +134,22 @@ class EntityViewBuilder extends EntityControllerBase implements EntityController
|
|||
*/
|
||||
protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langcode) {
|
||||
$return = array(
|
||||
'#theme' => $this->entityType,
|
||||
"#{$this->entityType}" => $entity,
|
||||
'#theme' => $this->entityTypeId,
|
||||
"#{$this->entityTypeId}" => $entity,
|
||||
'#view_mode' => $view_mode,
|
||||
'#langcode' => $langcode,
|
||||
);
|
||||
|
||||
// Cache the rendered output if permitted by the view mode and global entity
|
||||
// type configuration.
|
||||
if ($this->isViewModeCacheable($view_mode) && !$entity->isNew() && !isset($entity->in_preview) && $this->entityInfo->isRenderCacheable()) {
|
||||
if ($this->isViewModeCacheable($view_mode) && !$entity->isNew() && !isset($entity->in_preview) && $this->entityType->isRenderCacheable()) {
|
||||
$return['#cache'] = array(
|
||||
'keys' => array('entity_view', $this->entityType, $entity->id(), $view_mode),
|
||||
'keys' => array('entity_view', $this->entityTypeId, $entity->id(), $view_mode),
|
||||
'granularity' => DRUPAL_CACHE_PER_ROLE,
|
||||
'bin' => $this->cacheBin,
|
||||
'tags' => array(
|
||||
$this->entityType . '_view' => TRUE,
|
||||
$this->entityType => array($entity->id()),
|
||||
$this->entityTypeId . '_view' => TRUE,
|
||||
$this->entityTypeId => array($entity->id()),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ class EntityViewBuilder extends EntityControllerBase implements EntityController
|
|||
$this->buildContent($view_mode_entities, $displays[$mode], $mode, $langcode);
|
||||
}
|
||||
|
||||
$view_hook = "{$this->entityType}_view";
|
||||
$view_hook = "{$this->entityTypeId}_view";
|
||||
$build = array('#sorted' => TRUE);
|
||||
$weight = 0;
|
||||
foreach ($entities as $key => $entity) {
|
||||
|
@ -259,13 +259,13 @@ class EntityViewBuilder extends EntityControllerBase implements EntityController
|
|||
$tags = array();
|
||||
foreach ($entities as $entity) {
|
||||
$id = $entity->id();
|
||||
$tags[$this->entityType][$id] = $id;
|
||||
$tags[$this->entityType . '_view_' . $entity->bundle()] = TRUE;
|
||||
$tags[$this->entityTypeId][$id] = $id;
|
||||
$tags[$this->entityTypeId . '_view_' . $entity->bundle()] = TRUE;
|
||||
}
|
||||
Cache::deleteTags($tags);
|
||||
}
|
||||
else {
|
||||
Cache::deleteTags(array($this->entityType . '_view' => TRUE));
|
||||
Cache::deleteTags(array($this->entityTypeId . '_view' => TRUE));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -283,7 +283,7 @@ class EntityViewBuilder extends EntityControllerBase implements EntityController
|
|||
// The 'default' is not an actual view mode.
|
||||
return TRUE;
|
||||
}
|
||||
$view_modes_info = entity_get_view_modes($this->entityType);
|
||||
$view_modes_info = entity_get_view_modes($this->entityTypeId);
|
||||
return !empty($view_modes_info[$view_mode]['cache']);
|
||||
}
|
||||
|
||||
|
|
|
@ -111,25 +111,25 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
|
|||
$this->fieldInfo = $field_info;
|
||||
|
||||
// Check if the entity type supports IDs.
|
||||
if ($this->entityInfo->hasKey('id')) {
|
||||
$this->idKey = $this->entityInfo->getKey('id');
|
||||
if ($this->entityType->hasKey('id')) {
|
||||
$this->idKey = $this->entityType->getKey('id');
|
||||
}
|
||||
|
||||
// Check if the entity type supports UUIDs.
|
||||
$this->uuidKey = $this->entityInfo->getKey('uuid');
|
||||
$this->uuidKey = $this->entityType->getKey('uuid');
|
||||
|
||||
// Check if the entity type supports revisions.
|
||||
if ($this->entityInfo->hasKey('revision')) {
|
||||
$this->revisionKey = $this->entityInfo->getKey('revision');
|
||||
$this->revisionTable = $this->entityInfo->getRevisionTable();
|
||||
if ($this->entityType->hasKey('revision')) {
|
||||
$this->revisionKey = $this->entityType->getKey('revision');
|
||||
$this->revisionTable = $this->entityType->getRevisionTable();
|
||||
}
|
||||
|
||||
// Check if the entity type has a dedicated table for fields.
|
||||
if ($data_table = $this->entityInfo->getDataTable()) {
|
||||
if ($data_table = $this->entityType->getDataTable()) {
|
||||
$this->dataTable = $data_table;
|
||||
// Entity types having both revision and translation support should always
|
||||
// define a revision data table.
|
||||
if ($this->revisionTable && $revision_data_table = $this->entityInfo->getRevisionDataTable()) {
|
||||
if ($this->revisionTable && $revision_data_table = $this->entityType->getRevisionDataTable()) {
|
||||
$this->revisionDataTable = $revision_data_table;
|
||||
}
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
|
|||
if (!$this->dataTable) {
|
||||
$bundle = $this->bundleKey ? $record->{$this->bundleKey} : FALSE;
|
||||
// Turn the record into an entity class.
|
||||
$entities[$id] = new $this->entityClass($entities[$id], $this->entityType, $bundle);
|
||||
$entities[$id] = new $this->entityClass($entities[$id], $this->entityTypeId, $bundle);
|
||||
}
|
||||
}
|
||||
$this->attachPropertyData($entities);
|
||||
|
@ -270,13 +270,13 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
|
|||
}
|
||||
|
||||
$data = $query->execute();
|
||||
$field_definitions = \Drupal::entityManager()->getFieldDefinitions($this->entityType);
|
||||
$field_definitions = \Drupal::entityManager()->getFieldDefinitions($this->entityTypeId);
|
||||
$translations = array();
|
||||
if ($this->revisionDataTable) {
|
||||
$data_column_names = array_flip(array_diff(drupal_schema_fields_sql($this->entityInfo->getRevisionDataTable()), drupal_schema_fields_sql($this->entityInfo->getBaseTable())));
|
||||
$data_column_names = array_flip(array_diff(drupal_schema_fields_sql($this->entityType->getRevisionDataTable()), drupal_schema_fields_sql($this->entityType->getBaseTable())));
|
||||
}
|
||||
else {
|
||||
$data_column_names = array_flip(drupal_schema_fields_sql($this->entityInfo->getDataTable()));
|
||||
$data_column_names = array_flip(drupal_schema_fields_sql($this->entityType->getDataTable()));
|
||||
}
|
||||
|
||||
foreach ($data as $values) {
|
||||
|
@ -312,7 +312,7 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
|
|||
foreach ($entities as $id => $values) {
|
||||
$bundle = $this->bundleKey ? $values[$this->bundleKey][Language::LANGCODE_DEFAULT] : FALSE;
|
||||
// Turn the record into an entity class.
|
||||
$entities[$id] = new $this->entityClass($values, $this->entityType, $bundle, array_keys($translations[$id]));
|
||||
$entities[$id] = new $this->entityClass($values, $this->entityTypeId, $bundle, array_keys($translations[$id]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -396,9 +396,9 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
|
|||
* A SelectQuery object for loading the entity.
|
||||
*/
|
||||
protected function buildQuery($ids, $revision_id = FALSE) {
|
||||
$query = $this->database->select($this->entityInfo->getBaseTable(), 'base');
|
||||
$query = $this->database->select($this->entityType->getBaseTable(), 'base');
|
||||
|
||||
$query->addTag($this->entityType . '_load_multiple');
|
||||
$query->addTag($this->entityTypeId . '_load_multiple');
|
||||
|
||||
if ($revision_id) {
|
||||
$query->join($this->revisionTable, 'revision', "revision.{$this->idKey} = base.{$this->idKey} AND revision.{$this->revisionKey} = :revisionId", array(':revisionId' => $revision_id));
|
||||
|
@ -408,11 +408,11 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
|
|||
}
|
||||
|
||||
// Add fields from the {entity} table.
|
||||
$entity_fields = drupal_schema_fields_sql($this->entityInfo->getBaseTable());
|
||||
$entity_fields = drupal_schema_fields_sql($this->entityType->getBaseTable());
|
||||
|
||||
if ($this->revisionTable) {
|
||||
// Add all fields from the {entity_revision} table.
|
||||
$entity_revision_fields = drupal_map_assoc(drupal_schema_fields_sql($this->entityInfo->getRevisionTable()));
|
||||
$entity_revision_fields = drupal_map_assoc(drupal_schema_fields_sql($this->entityType->getRevisionTable()));
|
||||
// The ID field is provided by entity, so remove it.
|
||||
unset($entity_revision_fields[$this->idKey]);
|
||||
|
||||
|
@ -459,7 +459,7 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
|
|||
$queried_entities = $this->mapFromStorageRecords($queried_entities);
|
||||
|
||||
// Attach field values.
|
||||
if ($this->entityInfo->isFieldable()) {
|
||||
if ($this->entityType->isFieldable()) {
|
||||
$this->loadFieldItems($queried_entities);
|
||||
}
|
||||
|
||||
|
@ -485,7 +485,7 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
|
|||
}
|
||||
$ids = array_keys($entities);
|
||||
|
||||
$this->database->delete($this->entityInfo->getBaseTable())
|
||||
$this->database->delete($this->entityType->getBaseTable())
|
||||
->condition($this->idKey, $ids)
|
||||
->execute();
|
||||
|
||||
|
@ -524,7 +524,7 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
|
|||
}
|
||||
catch (\Exception $e) {
|
||||
$transaction->rollback();
|
||||
watchdog_exception($this->entityType, $e);
|
||||
watchdog_exception($this->entityTypeId, $e);
|
||||
throw new EntityStorageException($e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
|
@ -540,7 +540,7 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
|
|||
|
||||
// Load the stored entity, if any.
|
||||
if (!$entity->isNew() && !isset($entity->original)) {
|
||||
$entity->original = entity_load_unchanged($this->entityType, $entity->id());
|
||||
$entity->original = entity_load_unchanged($this->entityTypeId, $entity->id());
|
||||
}
|
||||
|
||||
$entity->preSave($this);
|
||||
|
@ -552,7 +552,7 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
|
|||
|
||||
if (!$entity->isNew()) {
|
||||
if ($entity->isDefaultRevision()) {
|
||||
$return = drupal_write_record($this->entityInfo->getBaseTable(), $record, $this->idKey);
|
||||
$return = drupal_write_record($this->entityType->getBaseTable(), $record, $this->idKey);
|
||||
}
|
||||
else {
|
||||
// @todo, should a different value be returned when saving an entity
|
||||
|
@ -582,7 +582,7 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
|
|||
// Ensure the entity is still seen as new after assigning it an id,
|
||||
// while storing its data.
|
||||
$entity->enforceIsNew();
|
||||
$return = drupal_write_record($this->entityInfo->getBaseTable(), $record);
|
||||
$return = drupal_write_record($this->entityType->getBaseTable(), $record);
|
||||
$entity->{$this->idKey}->value = (string) $record->{$this->idKey};
|
||||
if ($this->revisionTable) {
|
||||
$entity->setNewRevision();
|
||||
|
@ -613,7 +613,7 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
|
|||
}
|
||||
catch (\Exception $e) {
|
||||
$transaction->rollback();
|
||||
watchdog_exception($this->entityType, $e);
|
||||
watchdog_exception($this->entityTypeId, $e);
|
||||
throw new EntityStorageException($e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
|
@ -628,7 +628,7 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
|
|||
* 'data_table'.
|
||||
*/
|
||||
protected function savePropertyData(EntityInterface $entity, $table_key = 'data_table') {
|
||||
$table_name = $this->entityInfo->get($table_key);
|
||||
$table_name = $this->entityType->get($table_key);
|
||||
$revision = $table_key != 'data_table';
|
||||
|
||||
if (!$revision || !$entity->isNewRevision()) {
|
||||
|
@ -670,11 +670,11 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
|
|||
$record = new \stdClass();
|
||||
$values = array();
|
||||
$definitions = $entity->getPropertyDefinitions();
|
||||
$schema = drupal_get_schema($this->entityInfo->get($table_key));
|
||||
$schema = drupal_get_schema($this->entityType->get($table_key));
|
||||
$is_new = $entity->isNew();
|
||||
|
||||
$multi_column_fields = array();
|
||||
foreach (drupal_schema_fields_sql($this->entityInfo->get($table_key)) as $name) {
|
||||
foreach (drupal_schema_fields_sql($this->entityType->get($table_key)) as $name) {
|
||||
// Check for fields which store data in multiple columns and process them
|
||||
// separately.
|
||||
if ($field = strstr($name, '__', TRUE)) {
|
||||
|
@ -751,7 +751,7 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
|
|||
if ($entity->isNewRevision()) {
|
||||
drupal_write_record($this->revisionTable, $record);
|
||||
if ($entity->isDefaultRevision()) {
|
||||
$this->database->update($this->entityInfo->getBaseTable())
|
||||
$this->database->update($this->entityType->getBaseTable())
|
||||
->fields(array($this->revisionKey => $record->{$this->revisionKey}))
|
||||
->condition($this->idKey, $record->{$this->idKey})
|
||||
->execute();
|
||||
|
@ -793,7 +793,7 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
|
|||
// Collect impacted fields.
|
||||
$fields = array();
|
||||
foreach ($bundles as $bundle => $v) {
|
||||
foreach ($this->fieldInfo->getBundleInstances($this->entityType, $bundle) as $field_name => $instance) {
|
||||
foreach ($this->fieldInfo->getBundleInstances($this->entityTypeId, $bundle) as $field_name => $instance) {
|
||||
$fields[$field_name] = $instance->getField();
|
||||
}
|
||||
}
|
||||
|
@ -850,7 +850,7 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
|
|||
$vid = $entity->getRevisionId();
|
||||
$id = $entity->id();
|
||||
$bundle = $entity->bundle();
|
||||
$entity_type = $entity->entityType();
|
||||
$entity_type = $entity->getEntityTypeId();
|
||||
$default_langcode = $entity->getUntranslated()->language()->id;
|
||||
$translation_langcodes = array_keys($entity->getTranslationLanguages());
|
||||
|
||||
|
@ -932,7 +932,7 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
protected function doDeleteFieldItems(EntityInterface $entity) {
|
||||
foreach ($this->fieldInfo->getBundleInstances($entity->entityType(), $entity->bundle()) as $instance) {
|
||||
foreach ($this->fieldInfo->getBundleInstances($entity->getEntityTypeId(), $entity->bundle()) as $instance) {
|
||||
$field = $instance->getField();
|
||||
$table_name = static::_fieldTableName($field);
|
||||
$revision_name = static::_fieldRevisionTableName($field);
|
||||
|
@ -951,7 +951,7 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
|
|||
protected function doDeleteFieldItemsRevision(EntityInterface $entity) {
|
||||
$vid = $entity->getRevisionId();
|
||||
if (isset($vid)) {
|
||||
foreach ($this->fieldInfo->getBundleInstances($entity->entityType(), $entity->bundle()) as $instance) {
|
||||
foreach ($this->fieldInfo->getBundleInstances($entity->getEntityTypeId(), $entity->bundle()) as $instance) {
|
||||
$revision_name = static::_fieldRevisionTableName($instance->getField());
|
||||
$this->database->delete($revision_name)
|
||||
->condition('entity_id', $entity->id())
|
||||
|
@ -1103,7 +1103,7 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
|
|||
// We need to account for deleted fields and instances. The method runs
|
||||
// before the instance definitions are updated, so we need to fetch them
|
||||
// using the old bundle name.
|
||||
$instances = entity_load_multiple_by_properties('field_instance', array('entity_type' => $this->entityType, 'bundle' => $bundle, 'include_deleted' => TRUE));
|
||||
$instances = entity_load_multiple_by_properties('field_instance', array('entity_type' => $this->entityTypeId, 'bundle' => $bundle, 'include_deleted' => TRUE));
|
||||
foreach ($instances as $instance) {
|
||||
$field = $instance->getField();
|
||||
$table_name = static::_fieldTableName($field);
|
||||
|
|
|
@ -39,8 +39,8 @@ abstract class FieldableEntityStorageControllerBase extends EntityStorageControl
|
|||
public function __construct(EntityTypeInterface $entity_info) {
|
||||
parent::__construct($entity_info);
|
||||
|
||||
$this->bundleKey = $this->entityInfo->getKey('bundle');
|
||||
$this->entityClass = $this->entityInfo->getClass();
|
||||
$this->bundleKey = $this->entityType->getKey('bundle');
|
||||
$this->entityClass = $this->entityType->getClass();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -56,18 +56,18 @@ abstract class FieldableEntityStorageControllerBase extends EntityStorageControl
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function create(array $values) {
|
||||
$entity_class = $this->entityInfo->getClass();
|
||||
$entity_class = $this->entityType->getClass();
|
||||
$entity_class::preCreate($this, $values);
|
||||
|
||||
// We have to determine the bundle first.
|
||||
$bundle = FALSE;
|
||||
if ($this->bundleKey) {
|
||||
if (!isset($values[$this->bundleKey])) {
|
||||
throw new EntityStorageException(String::format('Missing bundle for entity type @type', array('@type' => $this->entityType)));
|
||||
throw new EntityStorageException(String::format('Missing bundle for entity type @type', array('@type' => $this->entityTypeId)));
|
||||
}
|
||||
$bundle = $values[$this->bundleKey];
|
||||
}
|
||||
$entity = new $entity_class(array(), $this->entityType, $bundle);
|
||||
$entity = new $entity_class(array(), $this->entityTypeId, $bundle);
|
||||
|
||||
foreach ($entity as $name => $field) {
|
||||
if (isset($values[$name])) {
|
||||
|
@ -121,7 +121,7 @@ abstract class FieldableEntityStorageControllerBase extends EntityStorageControl
|
|||
// Only the most current revision of non-deleted fields for cacheable entity
|
||||
// types can be cached.
|
||||
$load_current = $age == static::FIELD_LOAD_CURRENT;
|
||||
$use_cache = $load_current && $this->entityInfo->isFieldDataCacheable();
|
||||
$use_cache = $load_current && $this->entityType->isFieldDataCacheable();
|
||||
|
||||
// Assume all entities will need to be queried. Entities found in the cache
|
||||
// will be removed from the list.
|
||||
|
@ -132,13 +132,13 @@ abstract class FieldableEntityStorageControllerBase extends EntityStorageControl
|
|||
// Build the list of cache entries to retrieve.
|
||||
$cids = array();
|
||||
foreach ($entities as $id => $entity) {
|
||||
$cids[] = "field:{$this->entityType}:$id";
|
||||
$cids[] = "field:{$this->entityTypeId}:$id";
|
||||
}
|
||||
$cache = cache('field')->getMultiple($cids);
|
||||
// Put the cached field values back into the entities and remove them from
|
||||
// the list of entities to query.
|
||||
foreach ($entities as $id => $entity) {
|
||||
$cid = "field:{$this->entityType}:$id";
|
||||
$cid = "field:{$this->entityTypeId}:$id";
|
||||
if (isset($cache[$cid])) {
|
||||
unset($queried_entities[$id]);
|
||||
foreach ($cache[$cid]->data as $langcode => $values) {
|
||||
|
@ -182,7 +182,7 @@ abstract class FieldableEntityStorageControllerBase extends EntityStorageControl
|
|||
}
|
||||
}
|
||||
}
|
||||
$cid = "field:{$this->entityType}:$id";
|
||||
$cid = "field:{$this->entityTypeId}:$id";
|
||||
cache('field')->set($cid, $data);
|
||||
}
|
||||
}
|
||||
|
@ -205,9 +205,9 @@ abstract class FieldableEntityStorageControllerBase extends EntityStorageControl
|
|||
$this->doSaveFieldItems($entity, $update);
|
||||
|
||||
if ($update) {
|
||||
$entity_info = $entity->entityInfo();
|
||||
$entity_info = $entity->getEntityType();
|
||||
if ($entity_info->isFieldDataCacheable()) {
|
||||
cache('field')->delete('field:' . $entity->entityType() . ':' . $entity->id());
|
||||
cache('field')->delete('field:' . $entity->getEntityTypeId() . ':' . $entity->id());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -225,9 +225,9 @@ abstract class FieldableEntityStorageControllerBase extends EntityStorageControl
|
|||
protected function deleteFieldItems(EntityInterface $entity) {
|
||||
$this->doDeleteFieldItems($entity);
|
||||
|
||||
$entity_info = $entity->entityInfo();
|
||||
$entity_info = $entity->getEntityType();
|
||||
if ($entity_info->isFieldDataCacheable()) {
|
||||
cache('field')->delete('field:' . $entity->entityType() . ':' . $entity->id());
|
||||
cache('field')->delete('field:' . $entity->getEntityTypeId() . ':' . $entity->id());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -21,9 +21,10 @@ class EntityChangedConstraintValidator extends ConstraintValidator {
|
|||
*/
|
||||
public function validate($value, Constraint $constraint) {
|
||||
if (isset($value)) {
|
||||
/** @var $entity \Drupal\Core\Entity\EntityInterface */
|
||||
$entity = $this->context->getMetadata()->getTypedData()->getEntity();
|
||||
if (!$entity->isNew()) {
|
||||
$saved_entity = \Drupal::entityManager()->getStorageController($entity->entityType())->loadUnchanged($entity->id());
|
||||
$saved_entity = \Drupal::entityManager()->getStorageController($entity->getEntityTypeId())->loadUnchanged($entity->id());
|
||||
|
||||
if ($saved_entity && ($saved_entity instanceof EntityChangedInterface) && ($saved_entity->getChangedTime() > $value)) {
|
||||
$this->context->addViolation($constraint->message);
|
||||
|
|
|
@ -21,7 +21,8 @@ class EntityTypeConstraintValidator extends ConstraintValidator {
|
|||
*/
|
||||
public function validate($entity, Constraint $constraint) {
|
||||
|
||||
if (!empty($entity) && $entity->entityType() != $constraint->type) {
|
||||
/** @var $entity \Drupal\Core\Entity\EntityInterface */
|
||||
if (!empty($entity) && $entity->getEntityTypeId() != $constraint->type) {
|
||||
$this->context->addViolation($constraint->message, array('%type' => $constraint->type));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ abstract class QueryBase {
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $entityType;
|
||||
protected $entityTypeId;
|
||||
|
||||
/**
|
||||
* The list of sorts.
|
||||
|
@ -129,7 +129,7 @@ abstract class QueryBase {
|
|||
* Constructs this object.
|
||||
*/
|
||||
public function __construct($entity_type, $conjunction, array $namespaces) {
|
||||
$this->entityType = $entity_type;
|
||||
$this->entityTypeId = $entity_type;
|
||||
$this->conjunction = $conjunction;
|
||||
$this->namespaces = $namespaces;
|
||||
$this->condition = $this->conditionGroupFactory($conjunction);
|
||||
|
@ -142,7 +142,7 @@ abstract class QueryBase {
|
|||
* Implements \Drupal\Core\Entity\Query\QueryInterface::getEntityType().
|
||||
*/
|
||||
public function getEntityType() {
|
||||
return $this->entityType;
|
||||
return $this->entityTypeId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,7 +24,7 @@ class Query extends QueryBase implements QueryInterface {
|
|||
*
|
||||
* @var \Drupal\Core\Entity\EntityTypeInterface
|
||||
*/
|
||||
protected $entityInfo;
|
||||
protected $entityType;
|
||||
|
||||
/**
|
||||
* The build sql select query.
|
||||
|
@ -107,20 +107,20 @@ class Query extends QueryBase implements QueryInterface {
|
|||
* Returns the called object.
|
||||
*/
|
||||
protected function prepare() {
|
||||
$entity_type = $this->entityType;
|
||||
$this->entityInfo = $this->entityManager->getDefinition($entity_type);
|
||||
if (!$base_table = $this->entityInfo->getBaseTable()) {
|
||||
$entity_type = $this->entityTypeId;
|
||||
$this->entityType = $this->entityManager->getDefinition($entity_type);
|
||||
if (!$base_table = $this->entityType->getBaseTable()) {
|
||||
throw new QueryException("No base table, invalid query.");
|
||||
}
|
||||
$simple_query = TRUE;
|
||||
if ($this->entityInfo->getDataTable()) {
|
||||
if ($this->entityType->getDataTable()) {
|
||||
$simple_query = FALSE;
|
||||
}
|
||||
$this->sqlQuery = $this->connection->select($base_table, 'base_table', array('conjunction' => $this->conjunction));
|
||||
$this->sqlQuery->addMetaData('entity_type', $entity_type);
|
||||
$id_field = $this->entityInfo->getKey('id');
|
||||
$id_field = $this->entityType->getKey('id');
|
||||
// Add the key field for fetchAllKeyed().
|
||||
if (!$revision_field = $this->entityInfo->getKey('revision')) {
|
||||
if (!$revision_field = $this->entityType->getKey('revision')) {
|
||||
// When there is no revision support, the key field is the entity key.
|
||||
$this->sqlFields["base_table.$id_field"] = array('base_table', $id_field);
|
||||
// Now add the value column for fetchAllKeyed(). This is always the
|
||||
|
@ -138,7 +138,7 @@ class Query extends QueryBase implements QueryInterface {
|
|||
$this->sqlQuery->addTag($entity_type . '_access');
|
||||
}
|
||||
$this->sqlQuery->addTag('entity_query');
|
||||
$this->sqlQuery->addTag('entity_query_' . $this->entityType);
|
||||
$this->sqlQuery->addTag('entity_query_' . $this->entityTypeId);
|
||||
|
||||
// Add further tags added.
|
||||
if (isset($this->alterTags)) {
|
||||
|
|
|
@ -44,7 +44,7 @@ class ConfigFieldItemList extends FieldItemList implements ConfigFieldItemListIn
|
|||
// see https://drupal.org/node/2114707.
|
||||
if (!isset($this->instance)) {
|
||||
$entity = $this->getEntity();
|
||||
$instances = Field::fieldInfo()->getBundleInstances($entity->entityType(), $entity->bundle());
|
||||
$instances = Field::fieldInfo()->getBundleInstances($entity->getEntityTypeId(), $entity->bundle());
|
||||
if (isset($instances[$this->getName()])) {
|
||||
$this->instance = $instances[$this->getName()];
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ class ConfigFieldItemList extends FieldItemList implements ConfigFieldItemListIn
|
|||
|
||||
// Use the widget currently configured for the 'default' form mode, or
|
||||
// fallback to the default widget for the field type.
|
||||
$entity_form_display = entity_get_form_display($entity->entityType(), $entity->bundle(), 'default');
|
||||
$entity_form_display = entity_get_form_display($entity->getEntityTypeId(), $entity->bundle(), 'default');
|
||||
$widget = $entity_form_display->getRenderer($this->getFieldDefinition()->getName());
|
||||
if (!$widget) {
|
||||
$widget = \Drupal::service('plugin.manager.field.widget')->getInstance(array('field_definition' => $this->getFieldDefinition()));
|
||||
|
|
|
@ -186,7 +186,7 @@ class FieldItemList extends ItemList implements FieldItemListInterface {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function access($operation = 'view', AccountInterface $account = NULL) {
|
||||
$access_controller = \Drupal::entityManager()->getAccessController($this->getParent()->entityType());
|
||||
$access_controller = \Drupal::entityManager()->getAccessController($this->getEntity()->getEntityTypeId());
|
||||
return $access_controller->fieldAccess($operation, $this->getFieldDefinition(), $account, $this);
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ abstract class FormatterBase extends PluginSettingsBase implements FormatterInte
|
|||
$elements = $this->viewElements($items);
|
||||
if ($elements) {
|
||||
$entity = $items->getEntity();
|
||||
$entity_type = $entity->entityType();
|
||||
$entity_type = $entity->getEntityTypeId();
|
||||
$field_name = $this->fieldDefinition->getName();
|
||||
$info = array(
|
||||
'#theme' => 'field',
|
||||
|
@ -101,8 +101,8 @@ abstract class FormatterBase extends PluginSettingsBase implements FormatterInte
|
|||
}
|
||||
|
||||
if (isset($item->entity)) {
|
||||
$info['#cache']['tags'][$item->entity->entityType()][] = $item->entity->id();
|
||||
$info['#cache']['tags'][$item->entity->entityType() . '_view'] = TRUE;
|
||||
$info['#cache']['tags'][$item->entity->getEntityTypeId()][] = $item->entity->id();
|
||||
$info['#cache']['tags'][$item->entity->getEntityTypeId() . '_view'] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -237,7 +237,7 @@ abstract class WidgetBase extends PluginSettingsBase implements WidgetInterface
|
|||
$entity = $items->getEntity();
|
||||
|
||||
$element += array(
|
||||
'#entity_type' => $entity->entityType(),
|
||||
'#entity_type' => $entity->getEntityTypeId(),
|
||||
'#bundle' => $entity->bundle(),
|
||||
'#entity' => $entity,
|
||||
'#field_name' => $this->fieldDefinition->getName(),
|
||||
|
|
|
@ -97,7 +97,7 @@ class BlockListController extends ConfigEntityListController implements FormInte
|
|||
$entities = _block_rehash($this->theme);
|
||||
|
||||
// Sort the blocks using \Drupal\block\Entity\Block::sort().
|
||||
uasort($entities, array($this->entityInfo->getClass(), 'sort'));
|
||||
uasort($entities, array($this->entityType->getClass(), 'sort'));
|
||||
return $entities;
|
||||
}
|
||||
|
||||
|
|
|
@ -293,8 +293,8 @@ function comment_field_instance_delete(FieldInstanceInterface $instance) {
|
|||
if ($instance->getType() == 'comment') {
|
||||
// Delete all comments that used by the entity bundle.
|
||||
$comments = db_query("SELECT cid FROM {comment} WHERE entity_type = :entity_type AND field_id = :field_id", array(
|
||||
':entity_type' => $instance->entityType(),
|
||||
':field_id' => $instance->entityType() . '__' . $instance->getName(),
|
||||
':entity_type' => $instance->getEntityTypeId(),
|
||||
':field_id' => $instance->getEntityTypeId() . '__' . $instance->getName(),
|
||||
))->fetchCol();
|
||||
entity_delete_multiple('comment', $comments);
|
||||
\Drupal::cache()->delete('comment_entity_info');
|
||||
|
@ -340,7 +340,7 @@ function comment_permission() {
|
|||
* An array "page=X" if the page number is greater than zero; NULL otherwise.
|
||||
*/
|
||||
function comment_new_page_count($num_comments, $new_replies, EntityInterface $entity, $field_name = 'comment') {
|
||||
$instance = \Drupal::service('field.info')->getInstance($entity->entityType(), $entity->bundle(), $field_name);
|
||||
$instance = \Drupal::service('field.info')->getInstance($entity->getEntityTypeId(), $entity->bundle(), $field_name);
|
||||
$mode = $instance->getSetting('default_mode');
|
||||
$comments_per_page = $instance->getSetting('per_page');
|
||||
$pagenum = NULL;
|
||||
|
@ -362,8 +362,8 @@ function comment_new_page_count($num_comments, $new_replies, EntityInterface $en
|
|||
$unread_threads_query = db_select('comment')
|
||||
->fields('comment', array('thread'))
|
||||
->condition('entity_id', $entity->id())
|
||||
->condition('entity_type', $entity->entityType())
|
||||
->condition('field_id', $entity->entityType() . '__' . $field_name)
|
||||
->condition('entity_type', $entity->getEntityTypeId())
|
||||
->condition('field_id', $entity->getEntityTypeId() . '__' . $field_name)
|
||||
->condition('status', CommentInterface::PUBLISHED)
|
||||
->orderBy('created', 'DESC')
|
||||
->orderBy('cid', 'DESC')
|
||||
|
@ -389,8 +389,8 @@ function comment_new_page_count($num_comments, $new_replies, EntityInterface $en
|
|||
AND status = :status AND SUBSTRING(thread, 1, (LENGTH(thread) - 1)) < :thread', array(
|
||||
':status' => CommentInterface::PUBLISHED,
|
||||
':entity_id' => $entity->id(),
|
||||
':field_id' => $entity->entityType() . '__' . $field_name,
|
||||
':entity_type' => $entity->entityType(),
|
||||
':field_id' => $entity->getEntityTypeId() . '__' . $field_name,
|
||||
':entity_type' => $entity->getEntityTypeId(),
|
||||
':thread' => $first_thread,
|
||||
))->fetchField();
|
||||
|
||||
|
@ -425,7 +425,7 @@ function comment_entity_view_alter(&$build, EntityInterface $entity, EntityViewD
|
|||
* Implements hook_entity_view().
|
||||
*/
|
||||
function comment_entity_view(EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode, $langcode) {
|
||||
if ($entity->entityType() != 'node') {
|
||||
if ($entity->getEntityTypeId() != 'node') {
|
||||
// Comment links are only added to node entity type for backwards
|
||||
// compatibility. Should you require comment links for other entity types
|
||||
// you can do-so by implementing a new field formatter.
|
||||
|
@ -495,7 +495,7 @@ function comment_entity_view(EntityInterface $entity, EntityViewDisplayInterface
|
|||
'fragment' => 'comment-form',
|
||||
);
|
||||
if ($comment_form_location == COMMENT_FORM_SEPARATE_PAGE) {
|
||||
$links['comment-add']['href'] = 'comment/reply/'. $entity->entityType() . '/' . $entity->id() .'/' . $field_name;
|
||||
$links['comment-add']['href'] = 'comment/reply/'. $entity->getEntityTypeId() . '/' . $entity->id() .'/' . $field_name;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -524,7 +524,7 @@ function comment_entity_view(EntityInterface $entity, EntityViewDisplayInterface
|
|||
'fragment' => 'comment-form',
|
||||
);
|
||||
if ($comment_form_location == COMMENT_FORM_SEPARATE_PAGE) {
|
||||
$links['comment-add']['href'] = 'comment/reply/'. $entity->entityType() . '/' . $entity->id() .'/' . $field_name;
|
||||
$links['comment-add']['href'] = 'comment/reply/'. $entity->getEntityTypeId() . '/' . $entity->id() .'/' . $field_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -551,7 +551,7 @@ function comment_entity_view(EntityInterface $entity, EntityViewDisplayInterface
|
|||
array('node_id' => $entity->id()),
|
||||
);
|
||||
$entity->content['links']['#post_render_cache']['Drupal\comment\CommentViewBuilder::attachNewCommentsLinkMetadata'] = array(
|
||||
array('entity_type' => $entity->entityType(), 'entity_id' => $entity->id(), 'field_name' => $field_name),
|
||||
array('entity_type' => $entity->getEntityTypeId(), 'entity_id' => $entity->id(), 'field_name' => $field_name),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -582,9 +582,9 @@ function comment_node_view_alter(&$build, EntityInterface $node, EntityViewDispl
|
|||
*/
|
||||
function comment_add(EntityInterface $entity, $field_name = 'comment', $pid = NULL) {
|
||||
$values = array(
|
||||
'entity_type' => $entity->entityType(),
|
||||
'entity_type' => $entity->getEntityTypeId(),
|
||||
'entity_id' => $entity->id(),
|
||||
'field_id' => $entity->entityType() . '__' . $field_name,
|
||||
'field_id' => $entity->getEntityTypeId() . '__' . $field_name,
|
||||
'pid' => $pid,
|
||||
);
|
||||
$comment = entity_create('comment', $values);
|
||||
|
@ -672,8 +672,8 @@ function comment_get_thread(EntityInterface $entity, $field_name, $mode, $commen
|
|||
$query->addField('c', 'cid');
|
||||
$query
|
||||
->condition('c.entity_id', $entity->id())
|
||||
->condition('c.entity_type', $entity->entityType())
|
||||
->condition('c.field_id', $entity->entityType() . '__' . $field_name)
|
||||
->condition('c.entity_type', $entity->getEntityTypeId())
|
||||
->condition('c.field_id', $entity->getEntityTypeId() . '__' . $field_name)
|
||||
->addTag('entity_access')
|
||||
->addTag('comment_filter')
|
||||
->addMetaData('base_table', 'comment')
|
||||
|
@ -685,8 +685,8 @@ function comment_get_thread(EntityInterface $entity, $field_name, $mode, $commen
|
|||
$count_query->addExpression('COUNT(*)');
|
||||
$count_query
|
||||
->condition('c.entity_id', $entity->id())
|
||||
->condition('c.entity_type', $entity->entityType())
|
||||
->condition('c.field_id', $entity->entityType() . '__' . $field_name)
|
||||
->condition('c.entity_type', $entity->getEntityTypeId())
|
||||
->condition('c.field_id', $entity->getEntityTypeId() . '__' . $field_name)
|
||||
->addTag('entity_access')
|
||||
->addTag('comment_filter')
|
||||
->addMetaData('base_table', 'comment')
|
||||
|
@ -905,7 +905,7 @@ function comment_entity_insert(EntityInterface $entity) {
|
|||
// Allow bulk updates and inserts to temporarily disable the
|
||||
// maintenance of the {comment_entity_statistics} table.
|
||||
if (\Drupal::state()->get('comment.maintain_entity_statistics') &&
|
||||
$fields = \Drupal::service('comment.manager')->getFields($entity->entityType())) {
|
||||
$fields = \Drupal::service('comment.manager')->getFields($entity->getEntityTypeId())) {
|
||||
$query = db_insert('comment_entity_statistics')
|
||||
->fields(array(
|
||||
'entity_id',
|
||||
|
@ -938,8 +938,8 @@ function comment_entity_insert(EntityInterface $entity) {
|
|||
}
|
||||
$query->values(array(
|
||||
'entity_id' => $entity->id(),
|
||||
'entity_type' => $entity->entityType(),
|
||||
'field_id' => $entity->entityType() . '__' . $field_name,
|
||||
'entity_type' => $entity->getEntityTypeId(),
|
||||
'field_id' => $entity->getEntityTypeId() . '__' . $field_name,
|
||||
'cid' => 0,
|
||||
'last_comment_timestamp' => $last_comment_timestamp,
|
||||
'last_comment_name' => NULL,
|
||||
|
@ -958,13 +958,13 @@ function comment_entity_predelete(EntityInterface $entity) {
|
|||
$cids = db_select('comment', 'c')
|
||||
->fields('c', array('cid'))
|
||||
->condition('entity_id', $entity->id())
|
||||
->condition('entity_type', $entity->entityType())
|
||||
->condition('entity_type', $entity->getEntityTypeId())
|
||||
->execute()
|
||||
->fetchCol();
|
||||
entity_delete_multiple('comment', $cids);
|
||||
db_delete('comment_entity_statistics')
|
||||
->condition('entity_id', $entity->id())
|
||||
->condition('entity_type', $entity->entityType())
|
||||
->condition('entity_type', $entity->getEntityTypeId())
|
||||
->execute();
|
||||
}
|
||||
|
||||
|
@ -1465,7 +1465,7 @@ function template_preprocess_comment(&$variables) {
|
|||
else {
|
||||
// @todo Use $entity->getAuthorId() after https://drupal.org/node/2078387
|
||||
if ($commented_entity->hasField('uid') && $comment->uid->target_id == $commented_entity->get('uid')->value) {
|
||||
$variables['attributes']['class'][] = 'by-' . $commented_entity->entityType() . '-author';
|
||||
$variables['attributes']['class'][] = 'by-' . $commented_entity->getEntityTypeId() . '-author';
|
||||
}
|
||||
}
|
||||
// Add clearfix class.
|
||||
|
@ -1566,7 +1566,7 @@ function comment_ranking() {
|
|||
* Implements hook_file_download_access().
|
||||
*/
|
||||
function comment_file_download_access($field, EntityInterface $entity, FileInterface $file) {
|
||||
if ($entity->entityType() == 'comment') {
|
||||
if ($entity->getEntityTypeId() == 'comment') {
|
||||
if (user_access('access comments') && $entity->status->value == CommentInterface::PUBLISHED || user_access('administer comments')) {
|
||||
$commented_entity = entity_load($entity->entity_type->value, $entity->entity_id->value);
|
||||
// Check access to parent entity.
|
||||
|
|
|
@ -250,13 +250,14 @@ function comment_tokens($type, $tokens, array $data = array(), array $options =
|
|||
}
|
||||
elseif (($type == 'entity' & !empty($data['entity'])) ||
|
||||
($type == 'node' & !empty($data['node']))) {
|
||||
/** @var $entity \Drupal\Core\Entity\ContentEntityInterface */
|
||||
$entity = !empty($data['entity']) ? $data['entity'] : $data['node'];
|
||||
|
||||
foreach ($tokens as $name => $original) {
|
||||
switch($name) {
|
||||
case 'comment-count':
|
||||
$count = 0;
|
||||
$fields = array_keys(\Drupal::service('comment.manager')->getFields($entity->entityType()));
|
||||
$fields = array_keys(\Drupal::service('comment.manager')->getFields($entity->getEntityTypeId()));
|
||||
$definitions = array_keys($entity->getPropertyDefinitions());
|
||||
$valid_fields = array_intersect($fields, $definitions);
|
||||
foreach ($valid_fields as $field_name) {
|
||||
|
@ -266,7 +267,7 @@ function comment_tokens($type, $tokens, array $data = array(), array $options =
|
|||
break;
|
||||
|
||||
case 'comment-count-new':
|
||||
$replacements[$original] = comment_num_new($entity->id(), $entity->entityType());
|
||||
$replacements[$original] = comment_num_new($entity->id(), $entity->getEntityTypeId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -80,11 +80,11 @@ class CommentFormController extends ContentEntityFormController {
|
|||
$comment = $this->entity;
|
||||
$entity = $this->entityManager->getStorageController($comment->entity_type->value)->load($comment->entity_id->value);
|
||||
$field_name = $comment->field_name->value;
|
||||
$instance = $this->fieldInfo->getInstance($entity->entityType(), $entity->bundle(), $field_name);
|
||||
$instance = $this->fieldInfo->getInstance($entity->getEntityTypeId(), $entity->bundle(), $field_name);
|
||||
|
||||
// Use #comment-form as unique jump target, regardless of entity type.
|
||||
$form['#id'] = drupal_html_id('comment_form');
|
||||
$form['#theme'] = array('comment_form__' . $entity->entityType() . '__' . $entity->bundle() . '__' . $field_name, 'comment_form');
|
||||
$form['#theme'] = array('comment_form__' . $entity->getEntityTypeId() . '__' . $entity->bundle() . '__' . $field_name, 'comment_form');
|
||||
|
||||
$anonymous_contact = $instance->getSetting('anonymous');
|
||||
$is_admin = $comment->id() && $this->currentUser->hasPermission('administer comments');
|
||||
|
@ -97,7 +97,7 @@ class CommentFormController extends ContentEntityFormController {
|
|||
// If not replying to a comment, use our dedicated page callback for new
|
||||
// Comments on entities.
|
||||
if (!$comment->id() && empty($comment->pid->target_id)) {
|
||||
$form['#action'] = url('comment/reply/' . $entity->entityType() . '/' . $entity->id() . '/' . $field_name);
|
||||
$form['#action'] = url('comment/reply/' . $entity->getEntityTypeId() . '/' . $entity->id() . '/' . $field_name);
|
||||
}
|
||||
|
||||
if (isset($form_state['comment_preview'])) {
|
||||
|
@ -393,7 +393,7 @@ class CommentFormController extends ContentEntityFormController {
|
|||
}
|
||||
$query = array();
|
||||
// Find the current display page for this comment.
|
||||
$instance = $this->fieldInfo->getInstance($entity->entityType(), $entity->bundle(), $field_name);
|
||||
$instance = $this->fieldInfo->getInstance($entity->getEntityTypeId(), $entity->bundle(), $field_name);
|
||||
$page = comment_get_display_page($comment->id(), $instance);
|
||||
if ($page > 0) {
|
||||
$query['page'] = $page;
|
||||
|
@ -411,6 +411,6 @@ class CommentFormController extends ContentEntityFormController {
|
|||
// Clear the block and page caches so that anonymous users see the comment
|
||||
// they have posted.
|
||||
Cache::invalidateTags(array('content' => TRUE));
|
||||
$this->entityManager->getViewBuilder($entity->entityType())->resetCache(array($entity));
|
||||
$this->entityManager->getViewBuilder($entity->getEntityTypeId())->resetCache(array($entity));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -270,7 +270,7 @@ class CommentManager implements CommentManagerInterface {
|
|||
// We cannot use drupal_get_destination() because these links
|
||||
// sometimes appear on /node and taxonomy listing pages.
|
||||
if ($entity->get($field_name)->getFieldDefinition()->getSetting('form_location') == COMMENT_FORM_SEPARATE_PAGE) {
|
||||
$destination = array('destination' => 'comment/reply/' . $entity->entityType() . '/' . $entity->id() . '/' . $field_name . '#comment-form');
|
||||
$destination = array('destination' => 'comment/reply/' . $entity->getEntityTypeId() . '/' . $entity->id() . '/' . $field_name . '#comment-form');
|
||||
}
|
||||
else {
|
||||
$uri = $entity->uri();
|
||||
|
|
|
@ -128,7 +128,7 @@ class CommentViewBuilder extends EntityViewBuilder {
|
|||
'comment_entity_id' => $entity->id(),
|
||||
'view_mode' => $view_mode,
|
||||
'langcode' => $langcode,
|
||||
'commented_entity_type' => $commented_entity->entityType(),
|
||||
'commented_entity_type' => $commented_entity->getEntityTypeId(),
|
||||
'commented_entity_id' => $commented_entity->id(),
|
||||
'in_preview' => !empty($entity->in_preview),
|
||||
),
|
||||
|
@ -271,7 +271,7 @@ class CommentViewBuilder extends EntityViewBuilder {
|
|||
if (empty($comment->in_preview)) {
|
||||
$prefix = '';
|
||||
$commented_entity = $this->entityManager->getStorageController($comment->entity_type->value)->load($comment->entity_id->value);
|
||||
$instance = $this->fieldInfo->getInstance($commented_entity->entityType(), $commented_entity->bundle(), $comment->field_name->value);
|
||||
$instance = $this->fieldInfo->getInstance($commented_entity->getEntityTypeId(), $commented_entity->bundle(), $comment->field_name->value);
|
||||
$is_threaded = isset($comment->divs)
|
||||
&& $instance->getSetting('default_mode') == COMMENT_MODE_THREADED;
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ class CommentController extends ControllerBase implements ContainerInjectionInte
|
|||
if (!$entity->access('view')) {
|
||||
throw new AccessDeniedHttpException();
|
||||
}
|
||||
$instance = $this->fieldInfo->getInstance($entity->entityType(), $entity->bundle(), $comment->field_name->value);
|
||||
$instance = $this->fieldInfo->getInstance($entity->getEntityTypeId(), $entity->bundle(), $comment->field_name->value);
|
||||
|
||||
// Find the current display page for this comment.
|
||||
$page = comment_get_display_page($comment->id(), $instance);
|
||||
|
@ -251,7 +251,7 @@ class CommentController extends ControllerBase implements ContainerInjectionInte
|
|||
// redirect loop.
|
||||
$entity->{$field_name}->status = COMMENT_HIDDEN;
|
||||
// Render array of the entity full view mode.
|
||||
$build['commented_entity'] = $this->entityManager()->getViewBuilder($entity->entityType())->view($entity, 'full');
|
||||
$build['commented_entity'] = $this->entityManager()->getViewBuilder($entity->getEntityTypeId())->view($entity, 'full');
|
||||
unset($build['commented_entity']['#cache']);
|
||||
$entity->{$field_name}->status = $status;
|
||||
}
|
||||
|
@ -264,8 +264,8 @@ class CommentController extends ControllerBase implements ContainerInjectionInte
|
|||
$comment = $this->entityManager()->getStorageController('comment')->create(array(
|
||||
'entity_id' => $entity->id(),
|
||||
'pid' => $pid,
|
||||
'entity_type' => $entity->entityType(),
|
||||
'field_id' => $entity->entityType() . '__' . $field_name,
|
||||
'entity_type' => $entity->getEntityTypeId(),
|
||||
'field_id' => $entity->getEntityTypeId() . '__' . $field_name,
|
||||
));
|
||||
$build['comment_form'] = $this->entityManager()->getForm($comment);
|
||||
|
||||
|
|
|
@ -159,7 +159,7 @@ class CommentDefaultFormatter extends FormatterBase implements ContainerFactoryP
|
|||
'#type' => 'render_cache_placeholder',
|
||||
'#callback' => '\Drupal\comment\Plugin\Field\FieldFormatter\CommentDefaultFormatter::renderForm',
|
||||
'#context' => array(
|
||||
'entity_type' => $entity->entityType(),
|
||||
'entity_type' => $entity->getEntityTypeId(),
|
||||
'entity_id' => $entity->id(),
|
||||
'field_name' => $field_name,
|
||||
),
|
||||
|
@ -169,7 +169,7 @@ class CommentDefaultFormatter extends FormatterBase implements ContainerFactoryP
|
|||
}
|
||||
|
||||
$elements[] = $output + array(
|
||||
'#theme' => 'comment_wrapper__' . $entity->entityType() . '__' . $entity->bundle() . '__' . $field_name,
|
||||
'#theme' => 'comment_wrapper__' . $entity->getEntityTypeId() . '__' . $entity->bundle() . '__' . $field_name,
|
||||
'#entity' => $entity,
|
||||
'#display_mode' => $this->getFieldSetting('default_mode'),
|
||||
'comments' => array(),
|
||||
|
|
|
@ -94,7 +94,7 @@ class CommentItem extends ConfigFieldItemBase {
|
|||
|
||||
$settings = $this->getFieldSettings();
|
||||
|
||||
$entity_type = $this->getEntity()->entityType();
|
||||
$entity_type = $this->getEntity()->getEntityTypeId();
|
||||
$field_name = $this->getFieldDefinition()->getName();
|
||||
|
||||
$element['comment'] = array(
|
||||
|
|
|
@ -237,7 +237,7 @@ class ConfigSingleImportForm extends ConfirmFormBase {
|
|||
->getStorageController($this->data['config_type'])
|
||||
->create($this->data['import']);
|
||||
$entity->save();
|
||||
drupal_set_message($this->t('The @entity_type %label was imported.', array('@entity_type' => $entity->entityType(), '%label' => $entity->label())));
|
||||
drupal_set_message($this->t('The @entity_type %label was imported.', array('@entity_type' => $entity->getEntityTypeId(), '%label' => $entity->label())));
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
drupal_set_message($e->getMessage(), 'error');
|
||||
|
|
|
@ -60,7 +60,7 @@ class ConfigEntityTest extends WebTestBase {
|
|||
$this->assertIdentical($empty->get('langcode'), $default_langcode);
|
||||
|
||||
// Verify Entity properties/methods on the newly created empty entity.
|
||||
$this->assertIdentical($empty->entityType(), 'config_test');
|
||||
$this->assertIdentical($empty->getEntityTypeId(), 'config_test');
|
||||
$uri = $empty->uri();
|
||||
$this->assertIdentical($uri['path'], 'admin/structure/config_test/manage');
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ class ConfigTranslationOverviewTest extends WebTestBase {
|
|||
$this->assertLinkByHref($base_url . '/translate');
|
||||
$this->assertText(String::checkPlain($test_entity->label()));
|
||||
|
||||
$entity_info = \Drupal::entityManager()->getDefinition($test_entity->entityType());
|
||||
$entity_info = \Drupal::entityManager()->getDefinition($test_entity->getEntityTypeId());
|
||||
$this->drupalGet($base_url . '/translate');
|
||||
|
||||
$title = t('!label !entity_type', array('!label' => $test_entity->label(), '!entity_type' => $entity_info->getLowercaseLabel()));
|
||||
|
|
|
@ -356,8 +356,8 @@ function content_translation_translate_access(EntityInterface $entity) {
|
|||
* the current user.
|
||||
*/
|
||||
function content_translation_view_access(EntityInterface $entity, $langcode, AccountInterface $account = NULL) {
|
||||
$entity_type = $entity->entityType();
|
||||
$info = $entity->entityInfo();
|
||||
$entity_type = $entity->getEntityTypeId();
|
||||
$info = $entity->getEntityType();
|
||||
$permission = "translate $entity_type";
|
||||
if ($info->getPermissionGranularity() == 'bundle') {
|
||||
$permission = "translate {$entity->bundle()} $entity_type";
|
||||
|
@ -584,7 +584,7 @@ function content_translation_form_controller(array $form_state) {
|
|||
* @todo Move to \Drupal\content_translation\ContentTranslationManager.
|
||||
*/
|
||||
function content_translation_access(EntityInterface $entity, $op) {
|
||||
return content_translation_controller($entity->entityType())->getTranslationAccess($entity, $op) ;
|
||||
return content_translation_controller($entity->getEntityTypeId())->getTranslationAccess($entity, $op) ;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -650,7 +650,7 @@ function content_translation_form_alter(array &$form, array &$form_state) {
|
|||
$entity = $form_controller ? $form_controller->getEntity() : NULL;
|
||||
|
||||
if ($entity instanceof ContentEntityInterface && $entity->isTranslatable() && count($entity->getTranslationLanguages()) > 1) {
|
||||
$controller = content_translation_controller($entity->entityType());
|
||||
$controller = content_translation_controller($entity->getEntityTypeId());
|
||||
$controller->entityFormAlter($form, $form_state, $entity);
|
||||
|
||||
// @todo Move the following lines to the code generating the property form
|
||||
|
@ -755,7 +755,7 @@ function content_translation_entity_insert(EntityInterface $entity) {
|
|||
'changed' => REQUEST_TIME,
|
||||
);
|
||||
|
||||
$translation['entity_type'] = $entity->entityType();
|
||||
$translation['entity_type'] = $entity->getEntityTypeId();
|
||||
$translation['entity_id'] = $entity->id();
|
||||
$translation['langcode'] = $langcode;
|
||||
|
||||
|
@ -781,7 +781,7 @@ function content_translation_entity_delete(EntityInterface $entity) {
|
|||
}
|
||||
|
||||
db_delete('content_translation')
|
||||
->condition('entity_type', $entity->entityType())
|
||||
->condition('entity_type', $entity->getEntityTypeId())
|
||||
->condition('entity_id', $entity->id())
|
||||
->execute();
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ use Drupal\Core\Entity\ContentEntityInterface;
|
|||
* @deprecated Use \Drupal\content_translation\Controller\ContentTranslationController::overview()
|
||||
*/
|
||||
function content_translation_overview(EntityInterface $entity) {
|
||||
$controller = content_translation_controller($entity->entityType());
|
||||
$controller = content_translation_controller($entity->getEntityTypeId());
|
||||
$entity_manager = \Drupal::entityManager();
|
||||
$languages = language_list();
|
||||
$original = $entity->getUntranslated()->language()->id;
|
||||
|
@ -42,7 +42,7 @@ function content_translation_overview(EntityInterface $entity) {
|
|||
|
||||
// Determine whether the current entity is translatable.
|
||||
$translatable = FALSE;
|
||||
foreach (field_info_instances($entity->entityType(), $entity->bundle()) as $instance) {
|
||||
foreach (field_info_instances($entity->getEntityTypeId(), $entity->bundle()) as $instance) {
|
||||
if ($instance->isTranslatable()) {
|
||||
$translatable = TRUE;
|
||||
break;
|
||||
|
|
|
@ -41,6 +41,7 @@ class ContentTranslationManageAccessCheck implements AccessInterface {
|
|||
*/
|
||||
public function access(Route $route, Request $request, AccountInterface $account) {
|
||||
$entity_type = $request->attributes->get('_entity_type');
|
||||
/** @var $entity \Drupal\Core\Entity\EntityInterface */
|
||||
if ($entity = $request->attributes->get($entity_type)) {
|
||||
$route_requirements = $route->getRequirements();
|
||||
$operation = $route_requirements['_access_content_translation_manage'];
|
||||
|
|
|
@ -20,14 +20,14 @@ class ContentTranslationController implements ContentTranslationControllerInterf
|
|||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $entityType;
|
||||
protected $entityTypeId;
|
||||
|
||||
/**
|
||||
* The entity info of the entity being translated.
|
||||
* Information about the entity type.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityTypeInterface
|
||||
*/
|
||||
protected $entityInfo;
|
||||
protected $entityType;
|
||||
|
||||
/**
|
||||
* Initializes an instance of the content translation controller.
|
||||
|
@ -36,8 +36,8 @@ class ContentTranslationController implements ContentTranslationControllerInterf
|
|||
* The info array of the given entity type.
|
||||
*/
|
||||
public function __construct($entity_info) {
|
||||
$this->entityType = $entity_info->id();
|
||||
$this->entityInfo = $entity_info;
|
||||
$this->entityTypeId = $entity_info->id();
|
||||
$this->entityType = $entity_info;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -57,12 +57,12 @@ class ContentTranslationController implements ContentTranslationControllerInterf
|
|||
public function getTranslationAccess(EntityInterface $entity, $op) {
|
||||
// @todo Move this logic into a translation access controller checking also
|
||||
// the translation language and the given account.
|
||||
$info = $entity->entityInfo();
|
||||
$info = $entity->getEntityType();
|
||||
$translate_permission = TRUE;
|
||||
// If no permission granularity is defined this entity type does not need an
|
||||
// explicit translate permission.
|
||||
if (!user_access('translate any entity') && $permission_granularity = $info->getPermissionGranularity()) {
|
||||
$translate_permission = user_access($permission_granularity == 'bundle' ? "translate {$entity->bundle()} {$entity->entityType()}" : "translate {$entity->entityType()}");
|
||||
$translate_permission = user_access($permission_granularity == 'bundle' ? "translate {$entity->bundle()} {$entity->getEntityTypeId()}" : "translate {$entity->getEntityTypeId()}");
|
||||
}
|
||||
return $translate_permission && user_access("$op content translations");
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ class FieldTranslationSynchronizer implements FieldTranslationSynchronizerInterf
|
|||
}
|
||||
|
||||
// If the entity language is being changed there is nothing to synchronize.
|
||||
$entity_type = $entity->entityType();
|
||||
$entity_type = $entity->getEntityTypeId();
|
||||
$entity_unchanged = isset($entity->original) ? $entity->original : $this->entityManager->getStorageController($entity_type)->loadUnchanged($entity->id());
|
||||
if ($entity->getUntranslated()->language()->id != $entity_unchanged->getUntranslated()->language()->id) {
|
||||
return;
|
||||
|
|
|
@ -64,9 +64,9 @@ class ContentTranslationDeleteForm extends ConfirmFormBase {
|
|||
*/
|
||||
public function getCancelRoute() {
|
||||
return array(
|
||||
'route_name' => $this->entity->entityInfo()->getLinkTemplate('drupal:content-translation-overview'),
|
||||
'route_name' => $this->entity->getEntityType()->getLinkTemplate('drupal:content-translation-overview'),
|
||||
'route_parameters' => array(
|
||||
$this->entity->entityType() => $this->entity->id(),
|
||||
$this->entity->getEntityTypeId() => $this->entity->id(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -160,6 +160,7 @@ function edit_field_formatter_info_alter(&$info) {
|
|||
*/
|
||||
function edit_preprocess_field(&$variables) {
|
||||
$element = $variables['element'];
|
||||
/** @var $entity \Drupal\Core\Entity\EntityInterface */
|
||||
$entity = $element['#object'];
|
||||
|
||||
// Edit module only supports view modes, not dynamically defined "display
|
||||
|
@ -174,7 +175,7 @@ function edit_preprocess_field(&$variables) {
|
|||
// fields") and computed fields are not editable.
|
||||
$definition = $entity->getPropertyDefinition($element['#field_name']);
|
||||
if ($definition && !$definition->isComputed()) {
|
||||
$variables['attributes']['data-edit-field-id'] = $entity->entityType() . '/' . $entity->id() . '/' . $element['#field_name'] . '/' . $element['#language'] . '/' . $element['#view_mode'];
|
||||
$variables['attributes']['data-edit-field-id'] = $entity->getEntityTypeId() . '/' . $entity->id() . '/' . $element['#field_name'] . '/' . $element['#language'] . '/' . $element['#view_mode'];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -182,7 +183,7 @@ function edit_preprocess_field(&$variables) {
|
|||
* Implements hook_entity_view_alter().
|
||||
*/
|
||||
function edit_entity_view_alter(&$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
|
||||
$build['#attributes']['data-edit-entity-id'] = $entity->entityType() . '/' . $entity->id();
|
||||
$build['#attributes']['data-edit-entity-id'] = $entity->getEntityTypeId() . '/' . $entity->id();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -164,7 +164,7 @@ class EditController implements ContainerInjectionInterface {
|
|||
$entity = $entity->getTranslation($langcode);
|
||||
|
||||
// If the entity information for this field is requested, include it.
|
||||
$entity_id = $entity->entityType() . '/' . $entity_id;
|
||||
$entity_id = $entity->getEntityTypeId() . '/' . $entity_id;
|
||||
if (is_array($entities) && in_array($entity_id, $entities) && !isset($metadata[$entity_id])) {
|
||||
$metadata[$entity_id] = $this->metadataGenerator->generateEntityMetadata($entity);
|
||||
}
|
||||
|
@ -314,7 +314,7 @@ class EditController implements ContainerInjectionInterface {
|
|||
* "public" instead of "protected".
|
||||
*/
|
||||
public function renderField(EntityInterface $entity, $field_name, $langcode, $view_mode_id) {
|
||||
$entity_view_mode_ids = array_keys(entity_get_view_modes($entity->entityType()));
|
||||
$entity_view_mode_ids = array_keys(entity_get_view_modes($entity->getEntityTypeId()));
|
||||
if (in_array($view_mode_id, $entity_view_mode_ids)) {
|
||||
$output = field_view_field($entity, $field_name, $view_mode_id, $langcode);
|
||||
}
|
||||
|
@ -349,7 +349,7 @@ class EditController implements ContainerInjectionInterface {
|
|||
// Return information about the entity that allows a front end application
|
||||
// to identify it.
|
||||
$output = array(
|
||||
'entity_type' => $entity->entityType(),
|
||||
'entity_type' => $entity->getEntityTypeId(),
|
||||
'entity_id' => $entity->id()
|
||||
);
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ class EditFieldForm extends FormBase {
|
|||
protected function init(array &$form_state, EntityInterface $entity, $field_name) {
|
||||
// @todo Rather than special-casing $node->revision, invoke prepareEdit()
|
||||
// once http://drupal.org/node/1863258 lands.
|
||||
if ($entity->entityType() == 'node') {
|
||||
if ($entity->getEntityTypeId() == 'node') {
|
||||
$node_type_settings = $this->nodeTypeStorage->load($entity->bundle())->getModuleSettings('node');
|
||||
$options = (isset($node_type_settings['options'])) ? $node_type_settings['options'] : array();
|
||||
$entity->setNewRevision(!empty($options['revision']));
|
||||
|
@ -168,6 +168,7 @@ class EditFieldForm extends FormBase {
|
|||
* it back to the form state and save it.
|
||||
*/
|
||||
protected function buildEntity(array $form, array &$form_state) {
|
||||
/** @var $entity \Drupal\Core\Entity\EntityInterface */
|
||||
$entity = clone $form_state['entity'];
|
||||
$field_name = $form_state['field_name'];
|
||||
|
||||
|
@ -175,7 +176,7 @@ class EditFieldForm extends FormBase {
|
|||
|
||||
// @todo Refine automated log messages and abstract them to all entity
|
||||
// types: http://drupal.org/node/1678002.
|
||||
if ($entity->entityType() == 'node' && $entity->isNewRevision() && !isset($entity->log)) {
|
||||
if ($entity->getEntityTypeId() == 'node' && $entity->isNewRevision() && !isset($entity->log)) {
|
||||
$entity->log = t('Updated the %field-name field through in-place editing.', array('%field-name' => $entity->get($field_name)->getFieldDefinition()->getLabel()));
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ class MetadataGenerator implements MetadataGeneratorInterface {
|
|||
'label' => check_plain($label),
|
||||
'access' => TRUE,
|
||||
'editor' => $editor_id,
|
||||
'aria' => t('Entity @type @id, field @field', array('@type' => $entity->entityType(), '@id' => $entity->id(), '@field' => $label)),
|
||||
'aria' => t('Entity @type @id, field @field', array('@type' => $entity->getEntityTypeId(), '@id' => $entity->id(), '@field' => $label)),
|
||||
);
|
||||
$custom_metadata = $editor->getMetadata($items);
|
||||
if (count($custom_metadata)) {
|
||||
|
|
|
@ -13,13 +13,13 @@ use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
|
|||
* Implements hook_entity_view_alter().
|
||||
*/
|
||||
function edit_test_entity_view_alter(&$build, EntityInterface $entity, EntityViewDisplayInterface $display) {
|
||||
if ($entity->entityType() == 'node' && $entity->bundle() == 'article') {
|
||||
if ($entity->getEntityTypeId() == 'node' && $entity->bundle() == 'article') {
|
||||
$build['pseudo'] = array(
|
||||
'#theme' => 'field',
|
||||
'#title' => 'My pseudo field',
|
||||
'#field_name' => 'edit_test_pseudo_field',
|
||||
'#label_display' => 'Label',
|
||||
'#entity_type' => $entity->entityType(),
|
||||
'#entity_type' => $entity->getEntityTypeId(),
|
||||
'#bundle' => $entity->bundle(),
|
||||
'#language' => Language::LANGCODE_NOT_SPECIFIED,
|
||||
'#field_type' => 'pseudo',
|
||||
|
|
|
@ -480,7 +480,7 @@ function _editor_record_file_usage(array $uuids, EntityInterface $entity) {
|
|||
$file->status = FILE_STATUS_PERMANENT;
|
||||
$file->save();
|
||||
}
|
||||
\Drupal::service('file.usage')->add($file, 'editor', $entity->entityType(), $entity->id());
|
||||
\Drupal::service('file.usage')->add($file, 'editor', $entity->getEntityTypeId(), $entity->id());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -500,7 +500,7 @@ function _editor_record_file_usage(array $uuids, EntityInterface $entity) {
|
|||
function _editor_delete_file_usage(array $uuids, EntityInterface $entity, $count) {
|
||||
foreach ($uuids as $uuid) {
|
||||
$file = entity_load_by_uuid('file', $uuid);
|
||||
\Drupal::service('file.usage')->delete($file, 'editor', $entity->entityType(), $entity->id(), $count);
|
||||
\Drupal::service('file.usage')->delete($file, 'editor', $entity->getEntityTypeId(), $entity->id(), $count);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -551,7 +551,7 @@ function _editor_get_processed_text_fields(ContentEntityInterface $entity) {
|
|||
// Only return fields that have text processing enabled.
|
||||
return array_filter($configurable_fields, function ($field) use ($entity) {
|
||||
$settings = Field::fieldInfo()
|
||||
->getInstance($entity->entityType(), $entity->bundle(), $field)
|
||||
->getInstance($entity->getEntityTypeId(), $entity->bundle(), $field)
|
||||
->getSettings();
|
||||
return isset($settings['text_processing']) && $settings['text_processing'] === TRUE;
|
||||
});
|
||||
|
|
|
@ -110,7 +110,7 @@ class EmailFieldTest extends WebTestBase {
|
|||
|
||||
// Verify that a mailto link is displayed.
|
||||
$entity = entity_load('entity_test', $id);
|
||||
$display = entity_get_display($entity->entityType(), $entity->bundle(), 'full');
|
||||
$display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), 'full');
|
||||
$entity->content = field_attach_view($entity, $display);
|
||||
$this->drupalSetContent(drupal_render($entity->content));
|
||||
$this->assertLinkByHref('mailto:test@example.com');
|
||||
|
|
|
@ -76,7 +76,7 @@ class EntityFormDisplay extends EntityDisplayBase implements EntityFormDisplayIn
|
|||
*/
|
||||
public function serialize() {
|
||||
// Only store the definition, not external objects or derived data.
|
||||
$data = $this->getExportProperties() + array('entityType' => $this->entityType());
|
||||
$data = $this->getExportProperties() + array('entityType' => $this->getEntityTypeId());
|
||||
return serialize($data);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,11 +19,11 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
|||
class EntityDisplayModeListController extends ConfigEntityListController {
|
||||
|
||||
/**
|
||||
* The entity info for all entity types.
|
||||
* All entity types.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityTypeInterface[]
|
||||
*/
|
||||
protected $entityInfoComplete;
|
||||
protected $entityTypes;
|
||||
|
||||
/**
|
||||
* Constructs a new EntityListController object.
|
||||
|
@ -38,7 +38,7 @@ class EntityDisplayModeListController extends ConfigEntityListController {
|
|||
public function __construct(EntityTypeInterface $entity_info, EntityStorageControllerInterface $storage, array $entity_info_complete) {
|
||||
parent::__construct($entity_info, $storage);
|
||||
|
||||
$this->entityInfoComplete = $entity_info_complete;
|
||||
$this->entityTypes = $entity_info_complete;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -86,17 +86,17 @@ class EntityDisplayModeListController extends ConfigEntityListController {
|
|||
public function render() {
|
||||
$build = array();
|
||||
foreach ($this->load() as $entity_type => $entities) {
|
||||
if (!isset($this->entityInfoComplete[$entity_type])) {
|
||||
if (!isset($this->entityTypes[$entity_type])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Filter entities
|
||||
if ($this->entityInfoComplete[$entity_type]->isFieldable() && !$this->isValidEntity($entity_type)) {
|
||||
if ($this->entityTypes[$entity_type]->isFieldable() && !$this->isValidEntity($entity_type)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$table = array(
|
||||
'#prefix' => '<h2>' . $this->entityInfoComplete[$entity_type]->getLabel() . '</h2>',
|
||||
'#prefix' => '<h2>' . $this->entityTypes[$entity_type]->getLabel() . '</h2>',
|
||||
'#type' => 'table',
|
||||
'#header' => $this->buildHeader(),
|
||||
'#rows' => array(),
|
||||
|
@ -112,12 +112,12 @@ class EntityDisplayModeListController extends ConfigEntityListController {
|
|||
$table['#weight'] = -10;
|
||||
}
|
||||
|
||||
$short_type = str_replace('_mode', '', $this->entityType);
|
||||
$short_type = str_replace('_mode', '', $this->entityTypeId);
|
||||
$table['#rows']['_add_new'][] = array(
|
||||
'data' => array(
|
||||
'#type' => 'link',
|
||||
'#href' => "admin/structure/display-modes/$short_type/add/$entity_type",
|
||||
'#title' => t('Add new %label @entity-type', array('%label' => $this->entityInfoComplete[$entity_type]->getLabel(), '@entity-type' => $this->entityInfo->getLowercaseLabel())),
|
||||
'#title' => t('Add new %label @entity-type', array('%label' => $this->entityTypes[$entity_type]->getLabel(), '@entity-type' => $this->entityType->getLowercaseLabel())),
|
||||
'#options' => array(
|
||||
'html' => TRUE,
|
||||
),
|
||||
|
@ -140,7 +140,7 @@ class EntityDisplayModeListController extends ConfigEntityListController {
|
|||
* doesn't has the correct controller.
|
||||
*/
|
||||
protected function isValidEntity($entity_type) {
|
||||
return $this->entityInfoComplete[$entity_type]->hasViewBuilderClass();
|
||||
return $this->entityTypes[$entity_type]->hasViewBuilderClass();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ class EntityFormModeListController extends EntityDisplayModeListController {
|
|||
* TRUE if the entity has any form controllers, FALSE otherwise.
|
||||
*/
|
||||
protected function isValidEntity($entity_type) {
|
||||
return $this->entityInfoComplete[$entity_type]->hasFormClasses();
|
||||
return $this->entityTypes[$entity_type]->hasFormClasses();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,18 +15,20 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
|||
class EntityDisplayModeAddForm extends EntityDisplayModeFormBase {
|
||||
|
||||
/**
|
||||
* The entity type for which the display mode is being created.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $entityType;
|
||||
protected $targetEntityTypeId;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(array $form, array &$form_state, $entity_type = NULL) {
|
||||
$this->entityType = $entity_type;
|
||||
$this->targetEntityTypeId = $entity_type;
|
||||
$form = parent::buildForm($form, $form_state);
|
||||
$definition = $this->entityManager->getDefinition($this->entityType);
|
||||
$form['#title'] = $this->t('Add new %label @entity-type', array('%label' => $definition->getLabel(), '@entity-type' => $this->entityInfo->getLowercaseLabel()));
|
||||
$definition = $this->entityManager->getDefinition($this->targetEntityTypeId);
|
||||
$form['#title'] = $this->t('Add new %label @entity-type', array('%label' => $definition->getLabel(), '@entity-type' => $this->entityType->getLowercaseLabel()));
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
@ -36,19 +38,19 @@ class EntityDisplayModeAddForm extends EntityDisplayModeFormBase {
|
|||
public function validate(array $form, array &$form_state) {
|
||||
parent::validate($form, $form_state);
|
||||
|
||||
form_set_value($form['id'], $this->entityType . '.' . $form_state['values']['id'], $form_state);
|
||||
form_set_value($form['id'], $this->targetEntityTypeId . '.' . $form_state['values']['id'], $form_state);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function prepareEntity() {
|
||||
$definition = $this->entityManager->getDefinition($this->entityType);
|
||||
$definition = $this->entityManager->getDefinition($this->targetEntityTypeId);
|
||||
if (!$definition->isFieldable() || !$definition->hasViewBuilderClass()) {
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
$this->entity->targetEntityType = $this->entityType;
|
||||
$this->entity->targetEntityType = $this->targetEntityTypeId;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ class EntityDisplayModeDeleteForm extends EntityConfirmFormBase {
|
|||
*/
|
||||
public function getCancelRoute() {
|
||||
return array(
|
||||
'route_name' => 'entity.' . $this->entity->entityType() . '_list',
|
||||
'route_name' => 'entity.' . $this->entity->getEntityTypeId() . '_list',
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ class EntityDisplayModeDeleteForm extends EntityConfirmFormBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getQuestion() {
|
||||
$entity_info = $this->entity->entityInfo();
|
||||
$entity_info = $this->entity->getEntityType();
|
||||
return t('Are you sure you want to delete the %label @entity-type?', array('%label' => $this->entity->label(), '@entity-type' => $entity_info->getLowercaseLabel()));
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ class EntityDisplayModeDeleteForm extends EntityConfirmFormBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDescription() {
|
||||
$entity_info = $this->entity->entityInfo();
|
||||
$entity_info = $this->entity->getEntityType();
|
||||
return t('Deleting a @entity-type will cause any output still requesting to use that @entity-type to use the default display settings.', array('@entity-type' => $entity_info->getLowercaseLabel()));
|
||||
}
|
||||
|
||||
|
@ -52,11 +52,11 @@ class EntityDisplayModeDeleteForm extends EntityConfirmFormBase {
|
|||
public function submit(array $form, array &$form_state) {
|
||||
parent::submit($form, $form_state);
|
||||
|
||||
$entity_info = $this->entity->entityInfo();
|
||||
$entity_info = $this->entity->getEntityType();
|
||||
drupal_set_message(t('Deleted the %label @entity-type.', array('%label' => $this->entity->label(), '@entity-type' => $entity_info->getLowercaseLabel())));
|
||||
$this->entity->delete();
|
||||
entity_info_cache_clear();
|
||||
$form_state['redirect_route']['route_name'] = 'entity.' . $this->entity->entityType() . '_list';
|
||||
$form_state['redirect_route']['route_name'] = 'entity.' . $this->entity->getEntityTypeId() . '_list';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ class EntityDisplayModeEditForm extends EntityDisplayModeFormBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function delete(array $form, array &$form_state) {
|
||||
$entity_type = $this->entity->entityType();
|
||||
$entity_type = $this->entity->getEntityTypeId();
|
||||
$form_state['redirect_route'] = array(
|
||||
'route_name' => 'entity.' . $entity_type . '_delete',
|
||||
'route_parameters' => array(
|
||||
|
|
|
@ -29,7 +29,7 @@ abstract class EntityDisplayModeFormBase extends EntityFormController {
|
|||
*
|
||||
* @var \Drupal\Core\Entity\EntityTypeInterface
|
||||
*/
|
||||
protected $entityInfo;
|
||||
protected $entityType;
|
||||
|
||||
/**
|
||||
* The entity manager.
|
||||
|
@ -66,7 +66,7 @@ abstract class EntityDisplayModeFormBase extends EntityFormController {
|
|||
*/
|
||||
protected function init(array &$form_state) {
|
||||
parent::init($form_state);
|
||||
$this->entityInfo = $this->entityManager->getDefinition($this->entity->entityType());
|
||||
$this->entityType = $this->entityManager->getDefinition($this->entity->getEntityTypeId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -114,7 +114,7 @@ abstract class EntityDisplayModeFormBase extends EntityFormController {
|
|||
return TRUE;
|
||||
}
|
||||
return (bool) $this->queryFactory
|
||||
->get($this->entity->entityType())
|
||||
->get($this->entity->getEntityTypeId())
|
||||
->condition('id', $element['#field_prefix'] . $entity_id)
|
||||
->execute();
|
||||
}
|
||||
|
@ -123,10 +123,10 @@ abstract class EntityDisplayModeFormBase extends EntityFormController {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function save(array $form, array &$form_state) {
|
||||
drupal_set_message(t('Saved the %label @entity-type.', array('%label' => $this->entity->label(), '@entity-type' => $this->entityInfo->getLowercaseLabel())));
|
||||
drupal_set_message(t('Saved the %label @entity-type.', array('%label' => $this->entity->label(), '@entity-type' => $this->entityType->getLowercaseLabel())));
|
||||
$this->entity->save();
|
||||
entity_info_cache_clear();
|
||||
$form_state['redirect_route']['route_name'] = 'entity.' . $this->entity->entityType() . '_list';
|
||||
$form_state['redirect_route']['route_name'] = 'entity.' . $this->entity->getEntityTypeId() . '_list';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,12 +18,12 @@ class EntityFormModeAddForm extends EntityDisplayModeAddForm {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
protected function prepareEntity() {
|
||||
$definition = $this->entityManager->getDefinition($this->entityType);
|
||||
$definition = $this->entityManager->getDefinition($this->targetEntityTypeId);
|
||||
if (!$definition->isFieldable() || !$definition->hasFormClasses()) {
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
$this->entity->targetEntityType = $this->entityType;
|
||||
$this->entity->targetEntityType = $this->targetEntityTypeId;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ class EntityReferenceEntityFormatter extends EntityReferenceFormatterBase {
|
|||
static $depth = 0;
|
||||
$depth++;
|
||||
if ($depth > 20) {
|
||||
throw new RecursiveRenderingException(format_string('Recursive rendering detected when rendering entity @entity_type(@entity_id). Aborting rendering.', array('@entity_type' => $item->entity->entityType(), '@entity_id' => $item->target_id)));
|
||||
throw new RecursiveRenderingException(format_string('Recursive rendering detected when rendering entity @entity_type(@entity_id). Aborting rendering.', array('@entity_type' => $item->entity->getEntityTypeId(), '@entity_id' => $item->target_id)));
|
||||
}
|
||||
|
||||
if (!empty($item->target_id)) {
|
||||
|
|
|
@ -77,7 +77,7 @@ abstract class AutocompleteWidgetBase extends WidgetBase {
|
|||
$autocomplete_route_parameters = array(
|
||||
'type' => $this->getSetting('autocomplete_type'),
|
||||
'field_name' => $this->fieldDefinition->getName(),
|
||||
'entity_type' => $entity->entityType(),
|
||||
'entity_type' => $entity->getEntityTypeId(),
|
||||
'bundle_name' => $entity->bundle(),
|
||||
);
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ use Drupal\entity\Entity\EntityFormDisplay;
|
|||
* An array of returned values.
|
||||
*/
|
||||
function field_invoke_method($method, $target_function, EntityInterface $entity, &$a = NULL, &$b = NULL, array $options = array()) {
|
||||
$entity_type = $entity->entityType();
|
||||
$entity_type = $entity->getEntityTypeId();
|
||||
|
||||
// Determine the list of fields to iterate on.
|
||||
$field_definitions = _field_invoke_get_field_definitions($entity_type, $entity->bundle(), $options);
|
||||
|
@ -127,7 +127,7 @@ function field_invoke_method($method, $target_function, EntityInterface $entity,
|
|||
* @param callable $target_function
|
||||
* A function that receives a FieldDefinitionInterface object and a bundle
|
||||
* name and returns the object on which the method should be invoked.
|
||||
* @param array $entities
|
||||
* @param \Drupal\Core\Entity\EntityInterface[] $entities
|
||||
* An array of entities, keyed by entity ID.
|
||||
* @param mixed $a
|
||||
* (optional) A parameter for the invoked method. Defaults to NULL.
|
||||
|
@ -153,7 +153,7 @@ function field_invoke_method_multiple($method, $target_function, array $entities
|
|||
// Go through the entities and collect the instances on which the method
|
||||
// should be called.
|
||||
foreach ($entities as $entity) {
|
||||
$entity_type = $entity->entityType();
|
||||
$entity_type = $entity->getEntityTypeId();
|
||||
$bundle = $entity->bundle();
|
||||
$id = $entity->id();
|
||||
|
||||
|
|
|
@ -287,7 +287,7 @@ function field_attach_form(EntityInterface $entity, &$form, &$form_state, $langc
|
|||
|
||||
$form += (array) field_invoke_method('form', _field_invoke_widget_target($form_display), $entity, $form, $form_state, $options);
|
||||
|
||||
$form['#entity_type'] = $entity->entityType();
|
||||
$form['#entity_type'] = $entity->getEntityTypeId();
|
||||
$form['#bundle'] = $entity->bundle();
|
||||
|
||||
// Let other modules make changes to the form.
|
||||
|
|
|
@ -344,7 +344,7 @@ function _field_filter_xss_display_allowed_tags() {
|
|||
function field_view_value(EntityInterface $entity, $field_name, $item, $display = array(), $langcode = NULL) {
|
||||
$output = array();
|
||||
|
||||
if ($field = field_info_field($entity->entityType(), $field_name)) {
|
||||
if ($field = field_info_field($entity->getEntityTypeId(), $field_name)) {
|
||||
// Clone the entity since we are going to modify field values.
|
||||
$clone = clone $entity;
|
||||
|
||||
|
|
|
@ -107,18 +107,18 @@ class FieldInstanceStorageController extends ConfigStorageController {
|
|||
if (isset($conditions['entity_type']) && isset($conditions['bundle']) && isset($conditions['field_name'])) {
|
||||
// Optimize for the most frequent case where we do have a specific ID.
|
||||
$id = $conditions['entity_type'] . '.' . $conditions['bundle'] . '.' . $conditions['field_name'];
|
||||
$instances = $this->entityManager->getStorageController($this->entityType)->loadMultiple(array($id));
|
||||
$instances = $this->entityManager->getStorageController($this->entityTypeId)->loadMultiple(array($id));
|
||||
}
|
||||
else {
|
||||
// No specific ID, we need to examine all existing instances.
|
||||
$instances = $this->entityManager->getStorageController($this->entityType)->loadMultiple();
|
||||
$instances = $this->entityManager->getStorageController($this->entityTypeId)->loadMultiple();
|
||||
}
|
||||
|
||||
// Merge deleted instances (stored in state) if needed.
|
||||
if ($include_deleted) {
|
||||
$deleted_instances = $this->state->get('field.instance.deleted') ?: array();
|
||||
foreach ($deleted_instances as $id => $config) {
|
||||
$instances[$id] = $this->entityManager->getStorageController($this->entityType)->create($config);
|
||||
$instances[$id] = $this->entityManager->getStorageController($this->entityTypeId)->create($config);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -100,18 +100,18 @@ class FieldStorageController extends ConfigStorageController {
|
|||
if (isset($conditions['entity_type']) && isset($conditions['field_name'])) {
|
||||
// Optimize for the most frequent case where we do have a specific ID.
|
||||
$id = $conditions['entity_type'] . $conditions['field_name'];
|
||||
$fields = $this->entityManager->getStorageController($this->entityType)->loadMultiple(array($id));
|
||||
$fields = $this->entityManager->getStorageController($this->entityTypeId)->loadMultiple(array($id));
|
||||
}
|
||||
else {
|
||||
// No specific ID, we need to examine all existing fields.
|
||||
$fields = $this->entityManager->getStorageController($this->entityType)->loadMultiple();
|
||||
$fields = $this->entityManager->getStorageController($this->entityTypeId)->loadMultiple();
|
||||
}
|
||||
|
||||
// Merge deleted fields (stored in state) if needed.
|
||||
if ($include_deleted) {
|
||||
$deleted_fields = $this->state->get('field.field.deleted') ?: array();
|
||||
foreach ($deleted_fields as $id => $config) {
|
||||
$fields[$id] = $this->entityManager->getStorageController($this->entityType)->create($config);
|
||||
$fields[$id] = $this->entityManager->getStorageController($this->entityTypeId)->create($config);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -261,7 +261,7 @@ class FieldAttachOtherTest extends FieldUnitTestBase {
|
|||
$this->assertFalse(cache('field')->get($cid), 'Cached: no cache entry on insert');
|
||||
|
||||
// Load, and check that a cache entry is present with the expected values.
|
||||
$controller = $this->container->get('entity.manager')->getStorageController($entity->entityType());
|
||||
$controller = $this->container->get('entity.manager')->getStorageController($entity->getEntityTypeId());
|
||||
$controller->resetCache();
|
||||
$controller->load($entity->id());
|
||||
$cache = cache('field')->get($cid);
|
||||
|
|
|
@ -156,7 +156,7 @@ class FieldAttachStorageTest extends FieldUnitTestBase {
|
|||
}
|
||||
|
||||
// Check that a single load correctly loads field values for both entities.
|
||||
$controller = $this->container->get('entity.manager')->getStorageController($entity->entityType());
|
||||
$controller = \Drupal::entityManager()->getStorageController($entity->getEntityTypeId());
|
||||
$controller->resetCache();
|
||||
$entities = $controller->loadMultiple();
|
||||
foreach ($entities as $index => $entity) {
|
||||
|
@ -267,7 +267,7 @@ class FieldAttachStorageTest extends FieldUnitTestBase {
|
|||
$entity->setNewRevision();
|
||||
$entity->save();
|
||||
$vids[] = $entity->getRevisionId();
|
||||
$controller = $this->container->get('entity.manager')->getStorageController($entity->entityType());
|
||||
$controller = $this->container->get('entity.manager')->getStorageController($entity->getEntityTypeId());
|
||||
$controller->resetCache();
|
||||
|
||||
// Confirm each revision loads
|
||||
|
@ -334,7 +334,7 @@ class FieldAttachStorageTest extends FieldUnitTestBase {
|
|||
$this->assertIdentical($this->instance->bundle, $new_bundle, "Bundle name has been updated in the instance.");
|
||||
|
||||
// Verify the field data is present on load.
|
||||
$controller = $this->container->get('entity.manager')->getStorageController($entity->entityType());
|
||||
$controller = $this->container->get('entity.manager')->getStorageController($entity->getEntityTypeId());
|
||||
$controller->resetCache();
|
||||
$entity = $controller->load($entity->id());
|
||||
$this->assertEqual(count($entity->{$this->field_name}), $cardinality, "Bundle name has been updated in the field storage");
|
||||
|
@ -389,7 +389,7 @@ class FieldAttachStorageTest extends FieldUnitTestBase {
|
|||
entity_test_delete_bundle($this->instance->bundle, $entity_type);
|
||||
|
||||
// Verify no data gets loaded
|
||||
$controller = $this->container->get('entity.manager')->getStorageController($entity->entityType());
|
||||
$controller = $this->container->get('entity.manager')->getStorageController($entity->getEntityTypeId());
|
||||
$controller->resetCache();
|
||||
$entity= $controller->load($entity->id());
|
||||
|
||||
|
|
|
@ -52,8 +52,8 @@ abstract class FieldTestBase extends WebTestBase {
|
|||
*/
|
||||
function assertFieldValues(EntityInterface $entity, $field_name, $expected_values, $langcode = Language::LANGCODE_NOT_SPECIFIED, $column = 'value') {
|
||||
// Re-load the entity to make sure we have the latest changes.
|
||||
entity_get_controller($entity->entityType())->resetCache(array($entity->id()));
|
||||
$e = entity_load($entity->entityType(), $entity->id());
|
||||
entity_get_controller($entity->getEntityTypeId())->resetCache(array($entity->id()));
|
||||
$e = entity_load($entity->getEntityTypeId(), $entity->id());
|
||||
$field = $values = $e->getTranslation($langcode)->$field_name;
|
||||
// Filter out empty values so that they don't mess with the assertions.
|
||||
$field->filterEmptyItems();
|
||||
|
|
|
@ -109,7 +109,7 @@ abstract class FieldUnitTestBase extends DrupalUnitTestBase {
|
|||
*/
|
||||
protected function entitySaveReload(EntityInterface $entity) {
|
||||
$entity->save();
|
||||
$controller = $this->container->get('entity.manager')->getStorageController($entity->entityType());
|
||||
$controller = $this->container->get('entity.manager')->getStorageController($entity->getEntityTypeId());
|
||||
$controller->resetCache();
|
||||
return $controller->load($entity->id());
|
||||
}
|
||||
|
@ -150,8 +150,8 @@ abstract class FieldUnitTestBase extends DrupalUnitTestBase {
|
|||
*/
|
||||
function assertFieldValues(EntityInterface $entity, $field_name, $expected_values, $langcode = Language::LANGCODE_NOT_SPECIFIED, $column = 'value') {
|
||||
// Re-load the entity to make sure we have the latest changes.
|
||||
entity_get_controller($entity->entityType())->resetCache(array($entity->id()));
|
||||
$e = entity_load($entity->entityType(), $entity->id());
|
||||
entity_get_controller($entity->getEntityTypeId())->resetCache(array($entity->id()));
|
||||
$e = entity_load($entity->getEntityTypeId(), $entity->id());
|
||||
$field = $values = $e->getTranslation($langcode)->$field_name;
|
||||
// Filter out empty values so that they don't mess with the assertions.
|
||||
$field->filterEmptyItems();
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
|
||||
/**
|
||||
* @file
|
||||
|
@ -44,7 +45,7 @@ function field_test_entity_info_translatable($entity_type = NULL, $translatable
|
|||
*
|
||||
* @deprecated Use \Drupal\field_test\Form\FieldTestForm::testEntityNestedForm()
|
||||
*/
|
||||
function field_test_entity_nested_form($form, &$form_state, $entity_1, $entity_2) {
|
||||
function field_test_entity_nested_form($form, &$form_state, EntityInterface $entity_1, EntityInterface $entity_2) {
|
||||
// First entity.
|
||||
foreach (array('id', 'type') as $key) {
|
||||
$form[$key] = array(
|
||||
|
@ -52,7 +53,7 @@ function field_test_entity_nested_form($form, &$form_state, $entity_1, $entity_2
|
|||
'#value' => $entity_1->$key->value,
|
||||
);
|
||||
}
|
||||
$form_state['form_display'] = entity_get_form_display($entity_1->entityType(), $entity_1->bundle(), 'default');
|
||||
$form_state['form_display'] = entity_get_form_display($entity_1->getEntityTypeId(), $entity_1->bundle(), 'default');
|
||||
field_attach_form($entity_1, $form, $form_state);
|
||||
|
||||
// Second entity.
|
||||
|
@ -69,7 +70,7 @@ function field_test_entity_nested_form($form, &$form_state, $entity_1, $entity_2
|
|||
'#value' => $entity_2->$key->value,
|
||||
);
|
||||
}
|
||||
$form_state['form_display'] = entity_get_form_display($entity_1->entityType(), $entity_1->bundle(), 'default');
|
||||
$form_state['form_display'] = entity_get_form_display($entity_1->getEntityTypeId(), $entity_1->bundle(), 'default');
|
||||
field_attach_form($entity_2, $form['entity_2'], $form_state);
|
||||
|
||||
$form['save'] = array(
|
||||
|
|
|
@ -180,7 +180,7 @@ function field_ui_form_node_type_form_alter(&$form, $form_state) {
|
|||
* Implements hook_entity_operation_alter().
|
||||
*/
|
||||
function field_ui_entity_operation_alter(array &$operations, EntityInterface $entity) {
|
||||
$info = $entity->entityInfo();
|
||||
$info = $entity->getEntityType();
|
||||
// Add manage fields and display links if this entity type is the bundle
|
||||
// of another.
|
||||
if ($bundle_of = $info->getBundleOf()) {
|
||||
|
|
|
@ -560,7 +560,7 @@ abstract class DisplayOverviewBase extends OverviewBase {
|
|||
// If no display exists for the newly enabled view mode, initialize
|
||||
// it with those from the 'default' view mode, which were used so
|
||||
// far.
|
||||
if (!entity_load($this->getEntityDisplay('default')->entityType(), $this->entity_type . '.' . $this->bundle . '.' . $mode)) {
|
||||
if (!entity_load($this->getEntityDisplay('default')->getEntityTypeId(), $this->entity_type . '.' . $this->bundle . '.' . $mode)) {
|
||||
$display = $this->getEntityDisplay('default')->createCopy($mode);
|
||||
$display->save();
|
||||
}
|
||||
|
|
|
@ -219,7 +219,7 @@ function hook_file_delete(Drupal\file\FileInterface $file) {
|
|||
* @see hook_entity_field_access().
|
||||
*/
|
||||
function hook_file_download_access($field, Drupal\Core\Entity\EntityInterface $entity, Drupal\file\FileInterface $file) {
|
||||
if ($entity->entityType() == 'node') {
|
||||
if ($entity->getEntityTypeId() == 'node') {
|
||||
return $entity->access('view');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ class FileStorageController extends FieldableDatabaseStorageController implement
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function spaceUsed($uid = NULL, $status = FILE_STATUS_PERMANENT) {
|
||||
$query = $this->database->select($this->entityInfo->getBaseTable(), 'f')
|
||||
$query = $this->database->select($this->entityType->getBaseTable(), 'f')
|
||||
->condition('f.status', $status);
|
||||
$query->addExpression('SUM(f.filesize)', 'filesize');
|
||||
if (isset($uid)) {
|
||||
|
@ -33,7 +33,7 @@ class FileStorageController extends FieldableDatabaseStorageController implement
|
|||
public function retrieveTemporaryFiles() {
|
||||
// Use separate placeholders for the status to avoid a bug in some versions
|
||||
// of PHP. See http://drupal.org/node/352956.
|
||||
return $this->database->query('SELECT fid FROM {' . $this->entityInfo->getBaseTable() . '} WHERE status <> :permanent AND changed < :changed', array(
|
||||
return $this->database->query('SELECT fid FROM {' . $this->entityType->getBaseTable() . '} WHERE status <> :permanent AND changed < :changed', array(
|
||||
':permanent' => FILE_STATUS_PERMANENT,
|
||||
':changed' => REQUEST_TIME - DRUPAL_MAXIMUM_TEMP_FILE_AGE
|
||||
));
|
||||
|
|
|
@ -28,7 +28,7 @@ class FileFieldItemList extends ConfigFieldItemList {
|
|||
|
||||
// Add a new usage for newly uploaded files.
|
||||
foreach ($this->targetEntities() as $file) {
|
||||
\Drupal::service('file.usage')->add($file, 'file', $entity->entityType(), $entity->id());
|
||||
\Drupal::service('file.usage')->add($file, 'file', $entity->getEntityTypeId(), $entity->id());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ class FileFieldItemList extends ConfigFieldItemList {
|
|||
// deletion of previous file usages are necessary.
|
||||
if (!empty($entity->original) && $entity->getRevisionId() != $entity->original->getRevisionId()) {
|
||||
foreach ($files as $file) {
|
||||
\Drupal::service('file.usage')->add($file, 'file', $entity->entityType(), $entity->id());
|
||||
\Drupal::service('file.usage')->add($file, 'file', $entity->getEntityTypeId(), $entity->id());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -64,13 +64,13 @@ class FileFieldItemList extends ConfigFieldItemList {
|
|||
$removed_fids = array_filter(array_diff($original_fids, $fids));
|
||||
$removed_files = \Drupal::entityManager()->getStorageController('file')->loadMultiple($removed_fids);
|
||||
foreach ($removed_files as $file) {
|
||||
\Drupal::service('file.usage')->delete($file, 'file', $entity->entityType(), $entity->id());
|
||||
\Drupal::service('file.usage')->delete($file, 'file', $entity->getEntityTypeId(), $entity->id());
|
||||
}
|
||||
|
||||
// Add new usage entries for newly added files.
|
||||
foreach ($files as $fid => $file) {
|
||||
if (!in_array($fid, $original_fids)) {
|
||||
\Drupal::service('file.usage')->add($file, 'file', $entity->entityType(), $entity->id());
|
||||
\Drupal::service('file.usage')->add($file, 'file', $entity->getEntityTypeId(), $entity->id());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ class FileFieldItemList extends ConfigFieldItemList {
|
|||
|
||||
// Delete all file usages within this entity.
|
||||
foreach ($this->targetEntities() as $file) {
|
||||
\Drupal::service('file.usage')->delete($file, 'file', $entity->entityType(), $entity->id(), 0);
|
||||
\Drupal::service('file.usage')->delete($file, 'file', $entity->getEntityTypeId(), $entity->id(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -97,7 +97,7 @@ class FileFieldItemList extends ConfigFieldItemList {
|
|||
|
||||
// Decrement the file usage by 1.
|
||||
foreach ($this->targetEntities() as $file) {
|
||||
\Drupal::service('file.usage')->delete($file, 'file', $entity->entityType(), $entity->id());
|
||||
\Drupal::service('file.usage')->delete($file, 'file', $entity->getEntityTypeId(), $entity->id());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ function file_module_test_form_submit($form, &$form_state) {
|
|||
* Implements hook_file_download_access().
|
||||
*/
|
||||
function file_module_test_file_download_access(FieldInterface $field, EntityInterface $entity, File $file) {
|
||||
$instance = field_info_instance($entity->entityType(), $field->getName(), $entity->bundle());
|
||||
$instance = field_info_instance($entity->getEntityTypeId(), $field->getName(), $entity->bundle());
|
||||
// Allow the file to be downloaded only if the given arguments are correct.
|
||||
// If any are wrong, $instance will be NULL.
|
||||
if (empty($instance)) {
|
||||
|
|
|
@ -29,13 +29,14 @@ class EntityNormalizer extends NormalizerBase {
|
|||
*/
|
||||
public function normalize($entity, $format = NULL, array $context = array()) {
|
||||
// Create the array of normalized properties, starting with the URI.
|
||||
/** @var $entity \Drupal\Core\Entity\ContentEntityInterface */
|
||||
$normalized = array(
|
||||
'_links' => array(
|
||||
'self' => array(
|
||||
'href' => $this->getEntityUri($entity),
|
||||
),
|
||||
'type' => array(
|
||||
'href' => $this->linkManager->getTypeUri($entity->entityType(), $entity->bundle()),
|
||||
'href' => $this->linkManager->getTypeUri($entity->getEntityTypeId(), $entity->bundle()),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -43,6 +44,7 @@ class EntityNormalizer extends NormalizerBase {
|
|||
// If the properties to use were specified, only output those properties.
|
||||
// Otherwise, output all properties except internal ID.
|
||||
if (isset($context['included_fields'])) {
|
||||
$properties = array();
|
||||
foreach ($context['included_fields'] as $property_name) {
|
||||
$properties[] = $entity->get($property_name);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ class EntityReferenceItemNormalizer extends FieldItemNormalizer implements UuidR
|
|||
* Implements \Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize()
|
||||
*/
|
||||
public function normalize($field_item, $format = NULL, array $context = array()) {
|
||||
/** @var $field_item \Drupal\Core\Field\FieldItemInterface */
|
||||
$target_entity = $field_item->get('entity')->getValue();
|
||||
|
||||
// If the parent entity passed in a langcode, unset it before normalizing
|
||||
|
@ -48,7 +49,7 @@ class EntityReferenceItemNormalizer extends FieldItemNormalizer implements UuidR
|
|||
// objects.
|
||||
$field_name = $field_item->getParent()->getName();
|
||||
$entity = $field_item->getEntity();
|
||||
$field_uri = $this->linkManager->getRelationUri($entity->entityType(), $entity->bundle(), $field_name);
|
||||
$field_uri = $this->linkManager->getRelationUri($entity->getEntityTypeId(), $entity->bundle(), $field_name);
|
||||
return array(
|
||||
'_links' => array(
|
||||
$field_uri => array($link),
|
||||
|
|
|
@ -153,7 +153,7 @@ function hook_language_fallback_candidates_alter(array &$candidates, array $cont
|
|||
function hook_language_fallback_candidates_OPERATION_alter(array &$candidates, array $context) {
|
||||
// We know that the current OPERATION deals with entities so no need to check
|
||||
// here.
|
||||
if ($context['data']->entityType() == 'node') {
|
||||
if ($context['data']->getEntityTypeId() == 'node') {
|
||||
$candidates = array_reverse($candidates);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ class LanguageListController extends DraggableListController {
|
|||
|
||||
// Sort the entities using the entity class's sort() method.
|
||||
// See \Drupal\Core\Config\Entity\ConfigEntityBase::sort().
|
||||
uasort($entities, array($this->entityInfo->getClass(), 'sort'));
|
||||
uasort($entities, array($this->entityType->getClass(), 'sort'));
|
||||
return $entities;
|
||||
}
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ class LinkFormatter extends FormatterBase {
|
|||
if (empty($settings['url_only']) && !empty($item->title)) {
|
||||
// Unsanitizied token replacement here because $options['html'] is FALSE
|
||||
// by default in l().
|
||||
$link_title = \Drupal::token()->replace($item->title, array($entity->entityType() => $entity), array('sanitize' => FALSE, 'clear' => TRUE));
|
||||
$link_title = \Drupal::token()->replace($item->title, array($entity->getEntityTypeId() => $entity), array('sanitize' => FALSE, 'clear' => TRUE));
|
||||
}
|
||||
|
||||
// Trim the link text to the desired length.
|
||||
|
|
|
@ -48,7 +48,7 @@ class LinkSeparateFormatter extends LinkFormatter {
|
|||
if (empty($settings['url_only']) && !empty($item->title)) {
|
||||
// Unsanitized token replacement here because $options['html'] is FALSE
|
||||
// by default in l().
|
||||
$link_title = \Drupal::token()->replace($item->title, array($entity->entityType() => $entity), array('sanitize' => FALSE, 'clear' => TRUE));
|
||||
$link_title = \Drupal::token()->replace($item->title, array($entity->getEntityTypeId() => $entity), array('sanitize' => FALSE, 'clear' => TRUE));
|
||||
}
|
||||
|
||||
// The link_separate formatter has two titles; the link text (as in the
|
||||
|
|
|
@ -515,7 +515,7 @@ class LinkFieldTest extends WebTestBase {
|
|||
$this->container->get('entity.manager')->getStorageController('entity_test')->resetCache(array($id));
|
||||
}
|
||||
$entity = entity_load('entity_test', $id);
|
||||
$display = entity_get_display($entity->entityType(), $entity->bundle(), $view_mode);
|
||||
$display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), $view_mode);
|
||||
field_attach_prepare_view('entity_test', array($entity->id() => $entity), array($entity->bundle() => $display));
|
||||
$entity->content = field_attach_view($entity, $display);
|
||||
|
||||
|
|
|
@ -283,7 +283,7 @@ class MenuLink extends Entity implements \ArrayAccess, MenuLinkInterface {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function isNewRevision() {
|
||||
return $this->newRevision || ($this->entityInfo()->hasKey('revision') && !$this->getRevisionId());
|
||||
return $this->newRevision || ($this->getEntityType()->hasKey('revision') && !$this->getRevisionId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -298,7 +298,7 @@ class MenuLink extends Entity implements \ArrayAccess, MenuLinkInterface {
|
|||
*/
|
||||
public function isTranslatable() {
|
||||
// @todo Inject the entity manager and retrieve bundle info from it.
|
||||
$bundles = entity_get_bundles($this->entityType);
|
||||
$bundles = entity_get_bundles($this->entityTypeId);
|
||||
return !empty($bundles[$this->bundle()]['translatable']);
|
||||
}
|
||||
|
||||
|
@ -366,7 +366,7 @@ class MenuLink extends Entity implements \ArrayAccess, MenuLinkInterface {
|
|||
$original = $all_links[$this->machine_name];
|
||||
$original['machine_name'] = $this->machine_name;
|
||||
/** @var \Drupal\menu_link\MenuLinkStorageControllerInterface $storage_controller */
|
||||
$storage_controller = \Drupal::entityManager()->getStorageController($this->entityType);
|
||||
$storage_controller = \Drupal::entityManager()->getStorageController($this->entityTypeId);
|
||||
$new_link = $storage_controller->createFromDefaultLink($original);
|
||||
// Merge existing menu link's ID and 'has_children' property.
|
||||
foreach (array('mlid', 'has_children') as $key) {
|
||||
|
|
|
@ -262,7 +262,7 @@ class MenuLinkFormController extends EntityFormController {
|
|||
// Invoke all specified builders for copying form values to entity properties.
|
||||
if (isset($form['#entity_builders'])) {
|
||||
foreach ($form['#entity_builders'] as $function) {
|
||||
call_user_func_array($function, array($entity->entityType(), $entity, &$form, &$form_state));
|
||||
call_user_func_array($function, array($entity->getEntityTypeId(), $entity, &$form, &$form_state));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -117,11 +117,11 @@ class MenuLinkStorageController extends DatabaseStorageController implements Men
|
|||
try {
|
||||
// Load the stored entity, if any.
|
||||
if (!$entity->isNew() && !isset($entity->original)) {
|
||||
$entity->original = entity_load_unchanged($this->entityType, $entity->id());
|
||||
$entity->original = entity_load_unchanged($this->entityTypeId, $entity->id());
|
||||
}
|
||||
|
||||
if ($entity->isNew()) {
|
||||
$entity->mlid = $this->database->insert($this->entityInfo->getBaseTable())->fields(array('menu_name' => $entity->menu_name))->execute();
|
||||
$entity->mlid = $this->database->insert($this->entityType->getBaseTable())->fields(array('menu_name' => $entity->menu_name))->execute();
|
||||
$entity->enforceIsNew();
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ class MenuLinkStorageController extends DatabaseStorageController implements Men
|
|||
// $entity may have additional keys left over from building a router entry.
|
||||
// The intersect removes the extra keys, allowing a meaningful comparison.
|
||||
if ($entity->isNew() || (array_intersect_key(get_object_vars($entity), get_object_vars($entity->original)) != get_object_vars($entity->original))) {
|
||||
$return = drupal_write_record($this->entityInfo->getBaseTable(), $entity, $this->idKey);
|
||||
$return = drupal_write_record($this->entityType->getBaseTable(), $entity, $this->idKey);
|
||||
|
||||
if ($return) {
|
||||
if (!$entity->isNew()) {
|
||||
|
@ -164,7 +164,7 @@ class MenuLinkStorageController extends DatabaseStorageController implements Men
|
|||
}
|
||||
catch (\Exception $e) {
|
||||
$transaction->rollback();
|
||||
watchdog_exception($this->entityType, $e);
|
||||
watchdog_exception($this->entityTypeId, $e);
|
||||
throw new EntityStorageException($e->getMessage(), $e->getCode(), $e);
|
||||
}
|
||||
}
|
||||
|
@ -199,11 +199,11 @@ class MenuLinkStorageController extends DatabaseStorageController implements Men
|
|||
);
|
||||
$query_result = $query->execute();
|
||||
|
||||
if ($class = $this->entityInfo->getClass()) {
|
||||
if ($class = $this->entityType->getClass()) {
|
||||
// We provide the necessary arguments for PDO to create objects of the
|
||||
// specified entity class.
|
||||
// @see \Drupal\Core\Entity\EntityInterface::__construct()
|
||||
$query_result->setFetchMode(\PDO::FETCH_CLASS, $class, array(array(), $this->entityType));
|
||||
$query_result->setFetchMode(\PDO::FETCH_CLASS, $class, array(array(), $this->entityTypeId));
|
||||
}
|
||||
|
||||
return $query_result->fetchAllAssoc($this->idKey);
|
||||
|
@ -232,7 +232,7 @@ class MenuLinkStorageController extends DatabaseStorageController implements Men
|
|||
// If plid == 0, there is nothing to update.
|
||||
if ($entity->plid) {
|
||||
// Check if at least one visible child exists in the table.
|
||||
$query = \Drupal::entityQuery($this->entityType);
|
||||
$query = \Drupal::entityQuery($this->entityTypeId);
|
||||
$query
|
||||
->condition('menu_name', $entity->menu_name)
|
||||
->condition('hidden', 0)
|
||||
|
@ -279,7 +279,7 @@ class MenuLinkStorageController extends DatabaseStorageController implements Men
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function moveChildren(EntityInterface $entity) {
|
||||
$query = $this->database->update($this->entityInfo->getBaseTable());
|
||||
$query = $this->database->update($this->entityType->getBaseTable());
|
||||
|
||||
$query->fields(array('menu_name' => $entity->menu_name));
|
||||
|
||||
|
@ -325,7 +325,7 @@ class MenuLinkStorageController extends DatabaseStorageController implements Men
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function countMenuLinks($menu_name) {
|
||||
$query = \Drupal::entityQuery($this->entityType);
|
||||
$query = \Drupal::entityQuery($this->entityTypeId);
|
||||
$query
|
||||
->condition('menu_name', $menu_name)
|
||||
->count();
|
||||
|
@ -341,7 +341,7 @@ class MenuLinkStorageController extends DatabaseStorageController implements Men
|
|||
$parent = FALSE;
|
||||
$parent_path = substr($parent_path, 0, strrpos($parent_path, '/'));
|
||||
|
||||
$query = \Drupal::entityQuery($this->entityType);
|
||||
$query = \Drupal::entityQuery($this->entityTypeId);
|
||||
$query
|
||||
->condition('mlid', $entity->id(), '<>')
|
||||
->condition('module', 'system')
|
||||
|
|
|
@ -181,7 +181,7 @@ class Node extends ContentEntityBase implements NodeInterface {
|
|||
}
|
||||
|
||||
return \Drupal::entityManager()
|
||||
->getAccessController($this->entityType)
|
||||
->getAccessController($this->entityTypeId)
|
||||
->access($this, $operation, $this->prepareLangcode(), $account);
|
||||
}
|
||||
|
||||
|
|
|
@ -1873,7 +1873,7 @@ function node_modules_uninstalled($modules) {
|
|||
* Implements hook_file_download_access().
|
||||
*/
|
||||
function node_file_download_access($field, EntityInterface $entity, File $file) {
|
||||
if ($entity->entityType() == 'node') {
|
||||
if ($entity->getEntityTypeId() == 'node') {
|
||||
return $entity->access('view');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -214,7 +214,7 @@ abstract class ListItemBase extends ConfigFieldItemBase implements AllowedValues
|
|||
// Prevent removing values currently in use.
|
||||
if ($has_data) {
|
||||
$lost_keys = array_diff(array_keys($this->getFieldSetting('allowed_values')), array_keys($values));
|
||||
if (_options_values_in_use($this->getEntity()->entityType(), $this->getFieldDefinition()->getName(), $lost_keys)) {
|
||||
if (_options_values_in_use($this->getEntity()->getEntityTypeId(), $this->getFieldDefinition()->getName(), $lost_keys)) {
|
||||
\Drupal::formBuilder()->setError($element, $form_state, t('Allowed values list: some values are being removed while currently in use.'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ function options_field_entity_delete(FieldInterface $field) {
|
|||
function options_allowed_values(FieldDefinitionInterface $field_definition, EntityInterface $entity) {
|
||||
$allowed_values = &drupal_static(__FUNCTION__, array());
|
||||
|
||||
$cache_id = implode(':', array($entity->entityType(), $entity->bundle(), $field_definition->getName()));
|
||||
$cache_id = implode(':', array($entity->getEntityTypeId(), $entity->bundle(), $field_definition->getName()));
|
||||
if (!isset($allowed_values[$cache_id])) {
|
||||
$function = $field_definition->getSetting('allowed_values_function');
|
||||
// If $cacheable is FALSE, then the allowed values are not statically
|
||||
|
|
|
@ -80,7 +80,7 @@ class EntityResource extends ResourceBase {
|
|||
$definition = $this->getPluginDefinition();
|
||||
// Verify that the deserialized entity is of the type that we expect to
|
||||
// prevent security issues.
|
||||
if ($entity->entityType() != $definition['entity_type']) {
|
||||
if ($entity->getEntityTypeId() != $definition['entity_type']) {
|
||||
throw new BadRequestHttpException(t('Invalid entity type'));
|
||||
}
|
||||
// POSTed entities must not have an ID set, because we always want to create
|
||||
|
@ -98,7 +98,7 @@ class EntityResource extends ResourceBase {
|
|||
$this->validate($entity);
|
||||
try {
|
||||
$entity->save();
|
||||
watchdog('rest', 'Created entity %type with ID %id.', array('%type' => $entity->entityType(), '%id' => $entity->id()));
|
||||
watchdog('rest', 'Created entity %type with ID %id.', array('%type' => $entity->getEntityTypeId(), '%id' => $entity->id()));
|
||||
|
||||
$url = url(strtr($this->pluginId, ':', '/') . '/' . $entity->id(), array('absolute' => TRUE));
|
||||
// 201 Created responses have an empty body.
|
||||
|
@ -131,7 +131,7 @@ class EntityResource extends ResourceBase {
|
|||
throw new NotFoundHttpException();
|
||||
}
|
||||
$definition = $this->getPluginDefinition();
|
||||
if ($entity->entityType() != $definition['entity_type']) {
|
||||
if ($entity->getEntityTypeId() != $definition['entity_type']) {
|
||||
throw new BadRequestHttpException(t('Invalid entity type'));
|
||||
}
|
||||
$original_entity = entity_load($definition['entity_type'], $id);
|
||||
|
@ -161,7 +161,7 @@ class EntityResource extends ResourceBase {
|
|||
$this->validate($original_entity);
|
||||
try {
|
||||
$original_entity->save();
|
||||
watchdog('rest', 'Updated entity %type with ID %id.', array('%type' => $entity->entityType(), '%id' => $entity->id()));
|
||||
watchdog('rest', 'Updated entity %type with ID %id.', array('%type' => $entity->getEntityTypeId(), '%id' => $entity->id()));
|
||||
|
||||
// Update responses have an empty body.
|
||||
return new ResourceResponse(NULL, 204);
|
||||
|
@ -191,7 +191,7 @@ class EntityResource extends ResourceBase {
|
|||
}
|
||||
try {
|
||||
$entity->delete();
|
||||
watchdog('rest', 'Deleted entity %type with ID %id.', array('%type' => $entity->entityType(), '%id' => $entity->id()));
|
||||
watchdog('rest', 'Deleted entity %type with ID %id.', array('%type' => $entity->getEntityTypeId(), '%id' => $entity->id()));
|
||||
|
||||
// Delete responses have an empty body.
|
||||
return new ResourceResponse(NULL, 204);
|
||||
|
|
|
@ -109,7 +109,7 @@ class SearchPageRepository implements SearchPageRepositoryInterface {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function sortSearchPages($search_pages) {
|
||||
$entity_info = $this->storage->entityInfo();
|
||||
$entity_info = $this->storage->getEntityType();
|
||||
uasort($search_pages, array($entity_info->getClass(), 'sort'));
|
||||
return $search_pages;
|
||||
}
|
||||
|
|
|
@ -270,7 +270,7 @@ class SearchPageRepositoryTest extends UnitTestCase {
|
|||
->method('getClass')
|
||||
->will($this->returnValue('Drupal\search\Tests\TestSearchPage'));
|
||||
$this->storage->expects($this->once())
|
||||
->method('entityInfo')
|
||||
->method('getEntityType')
|
||||
->will($this->returnValue($entity_type));
|
||||
|
||||
// Declare entities out of their expected order so we can be sure they were
|
||||
|
|
|
@ -173,7 +173,7 @@ class EntitySerializationTest extends NormalizerTestBase {
|
|||
foreach (array('json', 'xml') as $type) {
|
||||
$denormalized = $this->serializer->denormalize($normalized, $this->entityClass, $type, array('entity_type' => 'entity_test_mulrev'));
|
||||
$this->assertTrue($denormalized instanceof $this->entityClass, String::format('Denormalized entity is an instance of @class', array('@class' => $this->entityClass)));
|
||||
$this->assertIdentical($denormalized->entityType(), $this->entity->entityType(), 'Expected entity type found.');
|
||||
$this->assertIdentical($denormalized->getEntityTypeId(), $this->entity->getEntityTypeId(), 'Expected entity type found.');
|
||||
$this->assertIdentical($denormalized->bundle(), $this->entity->bundle(), 'Expected entity bundle found.');
|
||||
$this->assertIdentical($denormalized->uuid(), $this->entity->uuid(), 'Expected entity UUID found.');
|
||||
}
|
||||
|
|
|
@ -300,7 +300,7 @@ function hook_entity_insert(Drupal\Core\Entity\EntityInterface $entity) {
|
|||
// Insert the new entity into a fictional table of all entities.
|
||||
db_insert('example_entity')
|
||||
->fields(array(
|
||||
'type' => $entity->entityType(),
|
||||
'type' => $entity->getEntityTypeId(),
|
||||
'id' => $entity->id(),
|
||||
'created' => REQUEST_TIME,
|
||||
'updated' => REQUEST_TIME,
|
||||
|
@ -323,7 +323,7 @@ function hook_entity_update(Drupal\Core\Entity\EntityInterface $entity) {
|
|||
->fields(array(
|
||||
'updated' => REQUEST_TIME,
|
||||
))
|
||||
->condition('type', $entity->entityType())
|
||||
->condition('type', $entity->getEntityTypeId())
|
||||
->condition('id', $entity->id())
|
||||
->execute();
|
||||
}
|
||||
|
@ -372,7 +372,7 @@ function hook_entity_predelete(Drupal\Core\Entity\EntityInterface $entity) {
|
|||
// Count references to this entity in a custom table before they are removed
|
||||
// upon entity deletion.
|
||||
$id = $entity->id();
|
||||
$type = $entity->entityType();
|
||||
$type = $entity->getEntityTypeId();
|
||||
$count = db_select('example_entity_data')
|
||||
->condition('type', $type)
|
||||
->condition('id', $id)
|
||||
|
@ -400,7 +400,7 @@ function hook_entity_predelete(Drupal\Core\Entity\EntityInterface $entity) {
|
|||
function hook_entity_delete(Drupal\Core\Entity\EntityInterface $entity) {
|
||||
// Delete the entity's entry from a fictional table of all entities.
|
||||
db_delete('example_entity')
|
||||
->condition('type', $entity->entityType())
|
||||
->condition('type', $entity->getEntityTypeId())
|
||||
->condition('id', $entity->id())
|
||||
->execute();
|
||||
}
|
||||
|
@ -554,7 +554,7 @@ function hook_entity_prepare_view($entity_type, array $entities, array $displays
|
|||
*/
|
||||
function hook_entity_view_mode_alter(&$view_mode, Drupal\Core\Entity\EntityInterface $entity, $context) {
|
||||
// For nodes, change the view mode when it is teaser.
|
||||
if ($entity->entityType() == 'node' && $view_mode == 'teaser') {
|
||||
if ($entity->getEntityTypeId() == 'node' && $view_mode == 'teaser') {
|
||||
$view_mode = 'my_custom_view_mode';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ abstract class DateFormatFormBase extends EntityFormController {
|
|||
*/
|
||||
public function exists($entity_id, array $element, array $form_state) {
|
||||
return (bool) $this->queryFactory
|
||||
->get($this->entity->entityType())
|
||||
->get($this->entity->getEntityTypeId())
|
||||
->condition('id', $element['#field_prefix'] . $entity_id)
|
||||
->execute();
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue