From 20315e1de77d4299d6f79f85b437a6f827ca124f Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Thu, 30 Jan 2014 12:06:58 +0000 Subject: [PATCH] Issue #2164827 by Berdir, Xano, tim.plunkett: Rename the entityInfo() and entityType() methods on EntityInterface and EntityStorageControllerInterface. --- core/includes/entity.inc | 10 +-- .../Entity/ConfigEntityListController.php | 4 +- .../Config/Entity/ConfigStorageController.php | 28 ++++---- .../Config/Entity/DraggableListController.php | 6 +- .../Drupal/Core/Entity/ContentEntityBase.php | 30 ++++----- .../Entity/ContentEntityConfirmFormBase.php | 2 +- .../Entity/ContentEntityFormController.php | 6 +- .../Controller/EntityViewController.php | 2 +- .../Core/Entity/DatabaseStorageController.php | 34 +++++----- core/lib/Drupal/Core/Entity/Entity.php | 44 ++++++------- .../Core/Entity/EntityAccessController.php | 20 +++--- .../Core/Entity/EntityConfirmFormBase.php | 2 +- .../Core/Entity/EntityFormController.php | 12 ++-- .../Drupal/Core/Entity/EntityInterface.php | 15 +++-- .../Core/Entity/EntityListController.php | 14 ++-- core/lib/Drupal/Core/Entity/EntityManager.php | 2 +- .../Entity/EntityStorageControllerBase.php | 38 +++++------ .../EntityStorageControllerInterface.php | 14 ++-- .../Drupal/Core/Entity/EntityViewBuilder.php | 36 +++++----- .../FieldableDatabaseStorageController.php | 66 +++++++++---------- .../FieldableEntityStorageControllerBase.php | 26 ++++---- .../EntityChangedConstraintValidator.php | 3 +- .../EntityTypeConstraintValidator.php | 3 +- .../Drupal/Core/Entity/Query/QueryBase.php | 6 +- .../Drupal/Core/Entity/Query/Sql/Query.php | 16 ++--- .../Drupal/Core/Field/ConfigFieldItemList.php | 4 +- core/lib/Drupal/Core/Field/FieldItemList.php | 2 +- core/lib/Drupal/Core/Field/FormatterBase.php | 6 +- core/lib/Drupal/Core/Field/WidgetBase.php | 2 +- .../lib/Drupal/block/BlockListController.php | 2 +- core/modules/comment/comment.module | 48 +++++++------- core/modules/comment/comment.tokens.inc | 5 +- .../Drupal/comment/CommentFormController.php | 10 +-- .../lib/Drupal/comment/CommentManager.php | 2 +- .../lib/Drupal/comment/CommentViewBuilder.php | 4 +- .../comment/Controller/CommentController.php | 8 +-- .../CommentDefaultFormatter.php | 4 +- .../Plugin/Field/FieldType/CommentItem.php | 2 +- .../config/Form/ConfigSingleImportForm.php | 2 +- .../Drupal/config/Tests/ConfigEntityTest.php | 2 +- .../Tests/ConfigTranslationOverviewTest.php | 2 +- .../content_translation.module | 12 ++-- .../content_translation.pages.inc | 4 +- .../ContentTranslationManageAccessCheck.php | 1 + .../ContentTranslationController.php | 14 ++-- .../FieldTranslationSynchronizer.php | 2 +- .../Form/ContentTranslationDeleteForm.php | 4 +- core/modules/edit/edit.module | 5 +- .../edit/lib/Drupal/edit/EditController.php | 6 +- .../lib/Drupal/edit/Form/EditFieldForm.php | 5 +- .../lib/Drupal/edit/MetadataGenerator.php | 2 +- .../edit/tests/modules/edit_test.module | 4 +- core/modules/editor/editor.module | 6 +- .../lib/Drupal/email/Tests/EmailFieldTest.php | 2 +- .../entity/Entity/EntityFormDisplay.php | 2 +- .../EntityDisplayModeListController.php | 18 ++--- .../entity/EntityFormModeListController.php | 2 +- .../entity/Form/EntityDisplayModeAddForm.php | 16 +++-- .../Form/EntityDisplayModeDeleteForm.php | 10 +-- .../entity/Form/EntityDisplayModeEditForm.php | 2 +- .../entity/Form/EntityDisplayModeFormBase.php | 10 +-- .../entity/Form/EntityFormModeAddForm.php | 4 +- .../EntityReferenceEntityFormatter.php | 2 +- .../FieldWidget/AutocompleteWidgetBase.php | 2 +- core/modules/field/field.attach.inc | 6 +- core/modules/field/field.deprecated.inc | 2 +- core/modules/field/field.module | 2 +- .../field/FieldInstanceStorageController.php | 6 +- .../Drupal/field/FieldStorageController.php | 6 +- .../field/Tests/FieldAttachOtherTest.php | 2 +- .../field/Tests/FieldAttachStorageTest.php | 8 +-- .../lib/Drupal/field/Tests/FieldTestBase.php | 4 +- .../Drupal/field/Tests/FieldUnitTestBase.php | 6 +- .../modules/field_test/field_test.entity.inc | 7 +- core/modules/field_ui/field_ui.module | 2 +- .../Drupal/field_ui/DisplayOverviewBase.php | 2 +- core/modules/file/file.api.php | 2 +- .../lib/Drupal/file/FileStorageController.php | 4 +- .../Field/FieldType/FileFieldItemList.php | 12 ++-- .../file_module_test/file_module_test.module | 2 +- .../hal/Normalizer/EntityNormalizer.php | 4 +- .../EntityReferenceItemNormalizer.php | 3 +- core/modules/language/language.api.php | 2 +- .../language/LanguageListController.php | 2 +- .../Field/FieldFormatter/LinkFormatter.php | 2 +- .../FieldFormatter/LinkSeparateFormatter.php | 2 +- .../lib/Drupal/link/Tests/LinkFieldTest.php | 2 +- .../lib/Drupal/menu_link/Entity/MenuLink.php | 6 +- .../menu_link/MenuLinkFormController.php | 2 +- .../menu_link/MenuLinkStorageController.php | 20 +++--- .../node/lib/Drupal/node/Entity/Node.php | 2 +- core/modules/node/node.module | 2 +- .../Plugin/Field/FieldType/ListItemBase.php | 2 +- core/modules/options/options.module | 2 +- .../Plugin/rest/resource/EntityResource.php | 10 +-- .../Drupal/search/SearchPageRepository.php | 2 +- .../search/Tests/SearchPageRepositoryTest.php | 2 +- .../Tests/EntitySerializationTest.php | 2 +- core/modules/system/entity.api.php | 10 +-- .../Drupal/system/Form/DateFormatFormBase.php | 2 +- .../Tests/Entity/EntityTranslationTest.php | 2 +- .../Tests/Entity/EntityUnitTestBase.php | 2 +- .../Entity/FieldTranslationSqlStorageTest.php | 2 +- .../entity_crud_hook_test.module | 12 ++-- .../Drupal/entity_test/Entity/EntityTest.php | 4 +- .../entity_test/EntityTestFormController.php | 10 +-- .../TaxonomyAutocompleteWidget.php | 2 +- .../lib/Drupal/taxonomy/TermViewBuilder.php | 4 +- .../Tests/TermFieldMultipleVocabularyTest.php | 4 +- .../Drupal/taxonomy/Tests/TermFieldTest.php | 2 +- core/modules/taxonomy/taxonomy.module | 2 +- .../lib/Drupal/text/Tests/TextFieldTest.php | 6 +- .../Tests/Views/Argument/RolesRidTest.php | 2 +- core/modules/user/user.module | 2 +- .../Plugin/views/cache/CachePluginBase.php | 4 +- .../views/Plugin/views/filter/Bundle.php | 16 ++--- .../views/Plugin/views/row/EntityRow.php | 18 ++--- .../views/lib/Drupal/views/ResultRow.php | 2 +- .../views/lib/Drupal/views/ViewExecutable.php | 2 +- .../views_ui/lib/Drupal/views_ui/ViewUI.php | 12 ++-- .../Tests/Core/Entity/EntityManagerTest.php | 4 +- 121 files changed, 479 insertions(+), 468 deletions(-) diff --git a/core/includes/entity.inc b/core/includes/entity.inc index 5b7cb3fbe8ce..98acf561d54f 100644 --- a/core/includes/entity.inc +++ b/core/includes/entity.inc @@ -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'; diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigEntityListController.php b/core/lib/Drupal/Core/Config/Entity/ConfigEntityListController.php index 979dddd48319..2cd3fafe5996 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigEntityListController.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigEntityListController.php @@ -23,7 +23,7 @@ public function load() { // 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 @@ public function getOperations(EntityInterface $entity) { $operations['edit']['href'] = $uri['path']; } - if ($this->entityInfo->hasKey('status')) { + if ($this->entityType->hasKey('status')) { if (!$entity->status()) { $operations['enable'] = array( 'title' => t('Enable'), diff --git a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php index e5daa858cc50..97182cb73614 100644 --- a/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php +++ b/core/lib/Drupal/Core/Config/Entity/ConfigStorageController.php @@ -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 @@ public function deleteRevision($revision_id) { * {@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 @@ public static function getIDFromConfigName($config_name, $config_prefix) { * 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 @@ protected function buildQuery($ids, $revision_id = FALSE) { // 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 @@ protected function buildQuery($ids, $revision_id = FALSE) { * 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 @@ public function delete(array $entities) { 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 @@ public function save(EntityInterface $entity) { // 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 @@ public function save(EntityInterface $entity) { */ 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 @@ public function importCreate($name, Config $new_config, Config $old_config) { * {@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 @@ public function importUpdate($name, Config $new_config, Config $old_config) { * {@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(); diff --git a/core/lib/Drupal/Core/Config/Entity/DraggableListController.php b/core/lib/Drupal/Core/Config/Entity/DraggableListController.php index c606a4767a90..d057bc9e8d2d 100644 --- a/core/lib/Drupal/Core/Config/Entity/DraggableListController.php +++ b/core/lib/Drupal/Core/Config/Entity/DraggableListController.php @@ -52,8 +52,8 @@ public function __construct(EntityTypeInterface $entity_info, EntityStorageContr 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 @@ public function buildForm(array $form, array &$form_state) { $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', diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php index 7a54191eabcf..c7f4275d7ce1 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php @@ -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 @@ public function setNewRevision($value = TRUE) { * {@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 @@ public function getRevisionId() { */ 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 @@ public function preSaveRevision(EntityStorageControllerInterface $storage_contro 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 @@ public function getPropertyDefinition($name) { */ 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 @@ public function isEmpty() { 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 @@ public function addTranslation($langcode, array $values = array()) { // 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 @@ public function createDuplicate() { } $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 @@ public function __clone() { */ 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); diff --git a/core/lib/Drupal/Core/Entity/ContentEntityConfirmFormBase.php b/core/lib/Drupal/Core/Entity/ContentEntityConfirmFormBase.php index c43cd9ca6771..a1768c68d1a5 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityConfirmFormBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityConfirmFormBase.php @@ -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'; } /** diff --git a/core/lib/Drupal/Core/Entity/ContentEntityFormController.php b/core/lib/Drupal/Core/Entity/ContentEntityFormController.php index de83f569f5fc..509d10fe5949 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityFormController.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityFormController.php @@ -50,7 +50,7 @@ public function form(array $form, array &$form_state) { $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 @@ public function form(array $form, array &$form_state) { 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 @@ public function isDefaultFormLangcode(array $form_state) { */ 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. diff --git a/core/lib/Drupal/Core/Entity/Controller/EntityViewController.php b/core/lib/Drupal/Core/Entity/Controller/EntityViewController.php index d11e4a6b5047..31672c0ae66b 100644 --- a/core/lib/Drupal/Core/Entity/Controller/EntityViewController.php +++ b/core/lib/Drupal/Core/Entity/Controller/EntityViewController.php @@ -62,7 +62,7 @@ public static function create(ContainerInterface $container) { */ public function view(EntityInterface $_entity, $view_mode = 'full', $langcode = NULL) { return $this->entityManager - ->getViewBuilder($_entity->entityType()) + ->getViewBuilder($_entity->getEntityTypeId()) ->view($_entity, $view_mode, $langcode); } diff --git a/core/lib/Drupal/Core/Entity/DatabaseStorageController.php b/core/lib/Drupal/Core/Entity/DatabaseStorageController.php index bfbdfb413a9d..e137322b04ca 100644 --- a/core/lib/Drupal/Core/Entity/DatabaseStorageController.php +++ b/core/lib/Drupal/Core/Entity/DatabaseStorageController.php @@ -86,10 +86,10 @@ public function __construct(EntityTypeInterface $entity_info, Connection $databa $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 @@ public function loadMultiple(array $ids = NULL) { // 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 @@ public function deleteRevision($revision_id) { */ 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 @@ protected function buildPropertyQuery(QueryInterface $entity_query, array $value * 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 @@ protected function buildQuery($ids, $revision_id = FALSE) { * {@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 @@ public function delete(array $entities) { $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 @@ public function delete(array $entities) { } 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 @@ public function save(EntityInterface $entity) { 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 @@ public function save(EntityInterface $entity) { } catch (\Exception $e) { $transaction->rollback(); - watchdog_exception($this->entityType, $e); + watchdog_exception($this->entityTypeId, $e); throw new EntityStorageException($e->getMessage(), $e->getCode(), $e); } } diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index 5a5532fd4065..1ad832c87b9c 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -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 @@ public function enforceIsNew($value = TRUE) { /** * {@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 @@ public function bundle() { */ 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 @@ public function label() { * 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 @@ public function uri($rel = 'canonical') { // 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 @@ public function uri($rel = 'canonical') { $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 @@ public function uri($rel = 'canonical') { // 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 @@ public function uri($rel = 'canonical') { * An array of link templates containing route names. */ protected function linkTemplates() { - return $this->entityInfo()->getLinkTemplates(); + return $this->getEntityType()->getLinkTemplates(); } /** @@ -243,11 +243,11 @@ protected function linkTemplates() { 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 @@ public function uriRelationships() { 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 @@ public function language() { * {@inheritdoc} */ public function save() { - return \Drupal::entityManager()->getStorageController($this->entityType)->save($this); + return \Drupal::entityManager()->getStorageController($this->entityTypeId)->save($this); } /** @@ -303,7 +303,7 @@ public function save() { */ 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 @@ public function delete() { */ 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 @@ public function createDuplicate() { /** * {@inheritdoc} */ - public function entityInfo() { - return \Drupal::entityManager()->getDefinition($this->entityType()); + public function getEntityType() { + return \Drupal::entityManager()->getDefinition($this->getEntityTypeId()); } /** @@ -388,11 +388,11 @@ public function referencedEntities() { */ 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) { diff --git a/core/lib/Drupal/Core/Entity/EntityAccessController.php b/core/lib/Drupal/Core/Entity/EntityAccessController.php index d17a99943e09..4873292942bb 100644 --- a/core/lib/Drupal/Core/Entity/EntityAccessController.php +++ b/core/lib/Drupal/Core/Entity/EntityAccessController.php @@ -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 @@ public function access(EntityInterface $entity, $operation, $langcode = Language // - 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 @@ protected function processAccessHookResults(array $access) { * 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 @@ public function createAccess($entity_bundle = NULL, AccountInterface $account = // - 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 @@ public function createAccess($entity_bundle = NULL, AccountInterface $account = * 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 { diff --git a/core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php b/core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php index 83091a3ef48b..bc45b6ba7c64 100644 --- a/core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php +++ b/core/lib/Drupal/Core/Entity/EntityConfirmFormBase.php @@ -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'; } /** diff --git a/core/lib/Drupal/Core/Entity/EntityFormController.php b/core/lib/Drupal/Core/Entity/EntityFormController.php index 2ea0fbefa13f..a0884fdcc1c6 100644 --- a/core/lib/Drupal/Core/Entity/EntityFormController.php +++ b/core/lib/Drupal/Core/Entity/EntityFormController.php @@ -59,7 +59,7 @@ public function getBaseFormID() { // 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 @@ public function getBaseFormID() { * {@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 @@ protected function init(array &$form_state) { // 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 @@ public function form(array $form, array &$form_state) { $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 @@ public function processForm($element, $form_state, $form) { } // 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 @@ public function buildEntity(array $form, array &$form_state) { // 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)); } } diff --git a/core/lib/Drupal/Core/Entity/EntityInterface.php b/core/lib/Drupal/Core/Entity/EntityInterface.php index 50e99b6aff97..164be5631b46 100644 --- a/core/lib/Drupal/Core/Entity/EntityInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityInterface.php @@ -72,17 +72,17 @@ public function enforceIsNew($value = TRUE); /** * 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 @@ public static function postLoad(EntityStorageControllerInterface $storage_contro 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. diff --git a/core/lib/Drupal/Core/Entity/EntityListController.php b/core/lib/Drupal/Core/Entity/EntityListController.php index ef3ec4335c90..2a53e90793f0 100644 --- a/core/lib/Drupal/Core/Entity/EntityListController.php +++ b/core/lib/Drupal/Core/Entity/EntityListController.php @@ -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 @@ public static function createInstance(ContainerInterface $container, EntityTypeI * 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 @@ public function render() { '#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)) { diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index 329131b1f381..8f7e929bb903 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -284,7 +284,7 @@ public function getController($entity_type, $controller_type, $controller_class_ */ 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, diff --git a/core/lib/Drupal/Core/Entity/EntityStorageControllerBase.php b/core/lib/Drupal/Core/Entity/EntityStorageControllerBase.php index 7db28fccc7fe..5427501886ac 100644 --- a/core/lib/Drupal/Core/Entity/EntityStorageControllerBase.php +++ b/core/lib/Drupal/Core/Entity/EntityStorageControllerBase.php @@ -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,24 +65,24 @@ 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() { - return $this->entityType; + public function getEntityTypeId() { + return $this->entityTypeId; } /** * {@inheritdoc} */ - public function entityInfo() { - return $this->entityInfo; + public function getEntityType() { + return $this->entityType; } /** @@ -150,9 +148,9 @@ protected function cacheSet($entities) { */ 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 @@ protected function invokeHook($hook, EntityInterface $entity) { * 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 @@ protected function buildPropertyQuery(QueryInterface $entity_query, array $value */ 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(); diff --git a/core/lib/Drupal/Core/Entity/EntityStorageControllerInterface.php b/core/lib/Drupal/Core/Entity/EntityStorageControllerInterface.php index 723e34a70df2..0e0159b337af 100644 --- a/core/lib/Drupal/Core/Entity/EntityStorageControllerInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityStorageControllerInterface.php @@ -155,19 +155,19 @@ public function save(EntityInterface $entity); 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(); } diff --git a/core/lib/Drupal/Core/Entity/EntityViewBuilder.php b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php index fb19c4eae80e..69bb6931e780 100644 --- a/core/lib/Drupal/Core/Entity/EntityViewBuilder.php +++ b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php @@ -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 @@ public static function createInstance(ContainerInterface $container, EntityTypeI * {@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 @@ public function buildContent(array $entities, array $displays, $view_mode, $lang } } - 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 @@ public function buildContent(array $entities, array $displays, $view_mode, $lang */ 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 @@ public function viewMultiple(array $entities = array(), $view_mode = 'full', $la $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 @@ public function resetCache(array $entities = NULL) { $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 @@ protected function isViewModeCacheable($view_mode) { // 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']); } diff --git a/core/lib/Drupal/Core/Entity/FieldableDatabaseStorageController.php b/core/lib/Drupal/Core/Entity/FieldableDatabaseStorageController.php index 282987d1074e..99d17a515ccf 100644 --- a/core/lib/Drupal/Core/Entity/FieldableDatabaseStorageController.php +++ b/core/lib/Drupal/Core/Entity/FieldableDatabaseStorageController.php @@ -111,25 +111,25 @@ public function __construct(EntityTypeInterface $entity_info, Connection $databa $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 @@ protected function mapFromStorageRecords(array $records) { 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 @@ protected function attachPropertyData(array &$entities) { } $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 @@ protected function attachPropertyData(array &$entities) { 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 @@ protected function buildPropertyQuery(QueryInterface $entity_query, array $value * 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 @@ protected function buildQuery($ids, $revision_id = FALSE) { } // 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 @@ protected function postLoad(array &$queried_entities) { $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 @@ public function delete(array $entities) { } $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 @@ public function delete(array $entities) { } 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 @@ public function save(EntityInterface $entity) { // 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 @@ public function save(EntityInterface $entity) { 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 @@ public function save(EntityInterface $entity) { // 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 @@ public function save(EntityInterface $entity) { } 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 @@ public function save(EntityInterface $entity) { * '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 @@ protected function mapToStorageRecord(EntityInterface $entity, $table_key = 'bas $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 @@ protected function saveRevision(EntityInterface $entity) { 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 @@ protected function doLoadFieldItems($entities, $age) { // 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 @@ protected function doSaveFieldItems(EntityInterface $entity, $update) { $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 @@ protected function doSaveFieldItems(EntityInterface $entity, $update) { * {@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 @@ protected function doDeleteFieldItems(EntityInterface $entity) { 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 @@ public function onBundleRename($bundle, $bundle_new) { // 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); diff --git a/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerBase.php b/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerBase.php index 02755974d551..cbfcb2b69315 100644 --- a/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerBase.php +++ b/core/lib/Drupal/Core/Entity/FieldableEntityStorageControllerBase.php @@ -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 @@ public static function createInstance(ContainerInterface $container, EntityTypeI * {@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 @@ protected function loadFieldItems(array $entities) { // 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 @@ protected function loadFieldItems(array $entities) { // 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 @@ protected function loadFieldItems(array $entities) { } } } - $cid = "field:{$this->entityType}:$id"; + $cid = "field:{$this->entityTypeId}:$id"; cache('field')->set($cid, $data); } } @@ -205,9 +205,9 @@ protected function saveFieldItems(EntityInterface $entity, $update = TRUE) { $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 @@ protected function saveFieldItems(EntityInterface $entity, $update = TRUE) { 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()); } } diff --git a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityChangedConstraintValidator.php b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityChangedConstraintValidator.php index 5101d809b4a9..dfa6e3ac2a0a 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityChangedConstraintValidator.php +++ b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityChangedConstraintValidator.php @@ -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); diff --git a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityTypeConstraintValidator.php b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityTypeConstraintValidator.php index c26c6c54fc42..5e316ca393ca 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityTypeConstraintValidator.php +++ b/core/lib/Drupal/Core/Entity/Plugin/Validation/Constraint/EntityTypeConstraintValidator.php @@ -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)); } } diff --git a/core/lib/Drupal/Core/Entity/Query/QueryBase.php b/core/lib/Drupal/Core/Entity/Query/QueryBase.php index 9122bab25f61..3ba51ecebb87 100644 --- a/core/lib/Drupal/Core/Entity/Query/QueryBase.php +++ b/core/lib/Drupal/Core/Entity/Query/QueryBase.php @@ -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 @@ public function __construct($entity_type, $conjunction, array $namespaces) { * Implements \Drupal\Core\Entity\Query\QueryInterface::getEntityType(). */ public function getEntityType() { - return $this->entityType; + return $this->entityTypeId; } /** diff --git a/core/lib/Drupal/Core/Entity/Query/Sql/Query.php b/core/lib/Drupal/Core/Entity/Query/Sql/Query.php index 883513e2a577..3fdf76472f18 100644 --- a/core/lib/Drupal/Core/Entity/Query/Sql/Query.php +++ b/core/lib/Drupal/Core/Entity/Query/Sql/Query.php @@ -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 @@ public function execute() { * 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 @@ protected function prepare() { $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)) { diff --git a/core/lib/Drupal/Core/Field/ConfigFieldItemList.php b/core/lib/Drupal/Core/Field/ConfigFieldItemList.php index f2134b2129ac..3c76be218cf1 100644 --- a/core/lib/Drupal/Core/Field/ConfigFieldItemList.php +++ b/core/lib/Drupal/Core/Field/ConfigFieldItemList.php @@ -44,7 +44,7 @@ public function getFieldDefinition() { // 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 @@ protected function defaultValueWidget(array &$form_state) { // 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())); diff --git a/core/lib/Drupal/Core/Field/FieldItemList.php b/core/lib/Drupal/Core/Field/FieldItemList.php index e8bea1872266..6a48db4d9577 100644 --- a/core/lib/Drupal/Core/Field/FieldItemList.php +++ b/core/lib/Drupal/Core/Field/FieldItemList.php @@ -186,7 +186,7 @@ public function __unset($property_name) { * {@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); } diff --git a/core/lib/Drupal/Core/Field/FormatterBase.php b/core/lib/Drupal/Core/Field/FormatterBase.php index c749243718f0..35bbf33a1da9 100644 --- a/core/lib/Drupal/Core/Field/FormatterBase.php +++ b/core/lib/Drupal/Core/Field/FormatterBase.php @@ -74,7 +74,7 @@ public function view(FieldItemListInterface $items) { $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 @@ public function view(FieldItemListInterface $items) { } 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; } } diff --git a/core/lib/Drupal/Core/Field/WidgetBase.php b/core/lib/Drupal/Core/Field/WidgetBase.php index 683cd76a222b..ffa82d1ed302 100644 --- a/core/lib/Drupal/Core/Field/WidgetBase.php +++ b/core/lib/Drupal/Core/Field/WidgetBase.php @@ -237,7 +237,7 @@ protected function formSingleElement(FieldItemListInterface $items, $delta, arra $entity = $items->getEntity(); $element += array( - '#entity_type' => $entity->entityType(), + '#entity_type' => $entity->getEntityTypeId(), '#bundle' => $entity->bundle(), '#entity' => $entity, '#field_name' => $this->fieldDefinition->getName(), diff --git a/core/modules/block/lib/Drupal/block/BlockListController.php b/core/modules/block/lib/Drupal/block/BlockListController.php index da7cbaa45587..11503ede04b5 100644 --- a/core/modules/block/lib/Drupal/block/BlockListController.php +++ b/core/modules/block/lib/Drupal/block/BlockListController.php @@ -97,7 +97,7 @@ public function load() { $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; } diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 1f5201eba09b..793a36775a04 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -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. diff --git a/core/modules/comment/comment.tokens.inc b/core/modules/comment/comment.tokens.inc index eab4d3e2740a..d17a91543be8 100644 --- a/core/modules/comment/comment.tokens.inc +++ b/core/modules/comment/comment.tokens.inc @@ -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; } } diff --git a/core/modules/comment/lib/Drupal/comment/CommentFormController.php b/core/modules/comment/lib/Drupal/comment/CommentFormController.php index c5afeebb1675..f2f993ac7a6f 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentFormController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentFormController.php @@ -80,11 +80,11 @@ public function form(array $form, array &$form_state) { $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 @@ public function form(array $form, array &$form_state) { // 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 @@ public function save(array $form, array &$form_state) { } $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 @@ public function save(array $form, array &$form_state) { // 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)); } } diff --git a/core/modules/comment/lib/Drupal/comment/CommentManager.php b/core/modules/comment/lib/Drupal/comment/CommentManager.php index e1075b3ce36c..5e58dbf6633f 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentManager.php +++ b/core/modules/comment/lib/Drupal/comment/CommentManager.php @@ -270,7 +270,7 @@ public function forbiddenMessage(EntityInterface $entity, $field_name) { // 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(); diff --git a/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php b/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php index 0563327dbd6c..92ff0279e1f7 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php +++ b/core/modules/comment/lib/Drupal/comment/CommentViewBuilder.php @@ -128,7 +128,7 @@ public function buildContent(array $entities, array $displays, $view_mode, $lang '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 @@ protected function alterBuild(array &$build, EntityInterface $comment, EntityVie 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; diff --git a/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php index 15f09a71c98c..a9200bb06f09 100644 --- a/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php +++ b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php @@ -124,7 +124,7 @@ public function commentPermalink(Request $request, CommentInterface $comment) { 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 @@ public function getReplyForm(Request $request, $entity_type, $entity_id, $field_ // 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 @@ public function getReplyForm(Request $request, $entity_type, $entity_id, $field_ $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); diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php index b6ce0947917e..bcdf86fc5c78 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldFormatter/CommentDefaultFormatter.php @@ -159,7 +159,7 @@ public function viewElements(FieldItemListInterface $items) { '#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 @@ public function viewElements(FieldItemListInterface $items) { } $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(), diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldType/CommentItem.php b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldType/CommentItem.php index 3145e8f626ed..4380baa88a96 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldType/CommentItem.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/Field/FieldType/CommentItem.php @@ -94,7 +94,7 @@ public function instanceSettingsForm(array $form, array &$form_state) { $settings = $this->getFieldSettings(); - $entity_type = $this->getEntity()->entityType(); + $entity_type = $this->getEntity()->getEntityTypeId(); $field_name = $this->getFieldDefinition()->getName(); $element['comment'] = array( diff --git a/core/modules/config/lib/Drupal/config/Form/ConfigSingleImportForm.php b/core/modules/config/lib/Drupal/config/Form/ConfigSingleImportForm.php index b89f68b431bb..8f0d076abdb3 100644 --- a/core/modules/config/lib/Drupal/config/Form/ConfigSingleImportForm.php +++ b/core/modules/config/lib/Drupal/config/Form/ConfigSingleImportForm.php @@ -237,7 +237,7 @@ public function submitForm(array &$form, array &$form_state) { ->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'); diff --git a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php index 2832c93d470d..8176a50a5935 100644 --- a/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php +++ b/core/modules/config/lib/Drupal/config/Tests/ConfigEntityTest.php @@ -60,7 +60,7 @@ function testCRUD() { $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'); diff --git a/core/modules/config_translation/lib/Drupal/config_translation/Tests/ConfigTranslationOverviewTest.php b/core/modules/config_translation/lib/Drupal/config_translation/Tests/ConfigTranslationOverviewTest.php index a471ce9d9cba..bd999b48d9bc 100644 --- a/core/modules/config_translation/lib/Drupal/config_translation/Tests/ConfigTranslationOverviewTest.php +++ b/core/modules/config_translation/lib/Drupal/config_translation/Tests/ConfigTranslationOverviewTest.php @@ -93,7 +93,7 @@ public function testMapperListPage() { $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())); diff --git a/core/modules/content_translation/content_translation.module b/core/modules/content_translation/content_translation.module index b210091c2e4c..7d4ed939e9f8 100644 --- a/core/modules/content_translation/content_translation.module +++ b/core/modules/content_translation/content_translation.module @@ -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(); } diff --git a/core/modules/content_translation/content_translation.pages.inc b/core/modules/content_translation/content_translation.pages.inc index aa1b1f3890c1..7aebcc8e6059 100644 --- a/core/modules/content_translation/content_translation.pages.inc +++ b/core/modules/content_translation/content_translation.pages.inc @@ -18,7 +18,7 @@ * @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; diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Access/ContentTranslationManageAccessCheck.php b/core/modules/content_translation/lib/Drupal/content_translation/Access/ContentTranslationManageAccessCheck.php index 89d03b80d546..2a9f53bf9809 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Access/ContentTranslationManageAccessCheck.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Access/ContentTranslationManageAccessCheck.php @@ -41,6 +41,7 @@ public function __construct(EntityManagerInterface $manager) { */ 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']; diff --git a/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationController.php b/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationController.php index e99c9b030d51..98d9fb45c461 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationController.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/ContentTranslationController.php @@ -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 @@ public function retranslate(EntityInterface $entity, $langcode = NULL) { 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"); } diff --git a/core/modules/content_translation/lib/Drupal/content_translation/FieldTranslationSynchronizer.php b/core/modules/content_translation/lib/Drupal/content_translation/FieldTranslationSynchronizer.php index 4efde317d147..1c8db66b5079 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/FieldTranslationSynchronizer.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/FieldTranslationSynchronizer.php @@ -47,7 +47,7 @@ public function synchronizeFields(ContentEntityInterface $entity, $sync_langcode } // 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; diff --git a/core/modules/content_translation/lib/Drupal/content_translation/Form/ContentTranslationDeleteForm.php b/core/modules/content_translation/lib/Drupal/content_translation/Form/ContentTranslationDeleteForm.php index 5d33cdfe0037..d371f65a86d2 100644 --- a/core/modules/content_translation/lib/Drupal/content_translation/Form/ContentTranslationDeleteForm.php +++ b/core/modules/content_translation/lib/Drupal/content_translation/Form/ContentTranslationDeleteForm.php @@ -64,9 +64,9 @@ public function getQuestion() { */ 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(), ), ); } diff --git a/core/modules/edit/edit.module b/core/modules/edit/edit.module index 3eaabccbba5c..87732dca4438 100644 --- a/core/modules/edit/edit.module +++ b/core/modules/edit/edit.module @@ -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(); } /** diff --git a/core/modules/edit/lib/Drupal/edit/EditController.php b/core/modules/edit/lib/Drupal/edit/EditController.php index 45c63ac8231c..d7c838650694 100644 --- a/core/modules/edit/lib/Drupal/edit/EditController.php +++ b/core/modules/edit/lib/Drupal/edit/EditController.php @@ -164,7 +164,7 @@ public function metadata(Request $request) { $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 @@ public function fieldForm(EntityInterface $entity, $field_name, $langcode, $view * "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 @@ public function entitySave(EntityInterface $entity) { // 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() ); diff --git a/core/modules/edit/lib/Drupal/edit/Form/EditFieldForm.php b/core/modules/edit/lib/Drupal/edit/Form/EditFieldForm.php index 1c356b2325a7..f6f5a9428723 100644 --- a/core/modules/edit/lib/Drupal/edit/Form/EditFieldForm.php +++ b/core/modules/edit/lib/Drupal/edit/Form/EditFieldForm.php @@ -116,7 +116,7 @@ public function buildForm(array $form, array &$form_state, EntityInterface $enti 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 @@ public function submitForm(array &$form, array &$form_state) { * 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 @@ protected function buildEntity(array $form, array &$form_state) { // @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())); } diff --git a/core/modules/edit/lib/Drupal/edit/MetadataGenerator.php b/core/modules/edit/lib/Drupal/edit/MetadataGenerator.php index eac109733122..e34e1dc03eae 100644 --- a/core/modules/edit/lib/Drupal/edit/MetadataGenerator.php +++ b/core/modules/edit/lib/Drupal/edit/MetadataGenerator.php @@ -91,7 +91,7 @@ public function generateFieldMetadata(FieldItemListInterface $items, $view_mode) '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)) { diff --git a/core/modules/edit/tests/modules/edit_test.module b/core/modules/edit/tests/modules/edit_test.module index 157350d71d23..7441f60897d4 100644 --- a/core/modules/edit/tests/modules/edit_test.module +++ b/core/modules/edit/tests/modules/edit_test.module @@ -13,13 +13,13 @@ * 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', diff --git a/core/modules/editor/editor.module b/core/modules/editor/editor.module index 1358910bc3ce..4490836ecb77 100644 --- a/core/modules/editor/editor.module +++ b/core/modules/editor/editor.module @@ -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; }); diff --git a/core/modules/email/lib/Drupal/email/Tests/EmailFieldTest.php b/core/modules/email/lib/Drupal/email/Tests/EmailFieldTest.php index 60fd532ad7cf..a359150b32ce 100644 --- a/core/modules/email/lib/Drupal/email/Tests/EmailFieldTest.php +++ b/core/modules/email/lib/Drupal/email/Tests/EmailFieldTest.php @@ -110,7 +110,7 @@ function testEmailField() { // 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'); diff --git a/core/modules/entity/lib/Drupal/entity/Entity/EntityFormDisplay.php b/core/modules/entity/lib/Drupal/entity/Entity/EntityFormDisplay.php index 26de1db034f9..ec22794ba501 100644 --- a/core/modules/entity/lib/Drupal/entity/Entity/EntityFormDisplay.php +++ b/core/modules/entity/lib/Drupal/entity/Entity/EntityFormDisplay.php @@ -76,7 +76,7 @@ public function getRenderer($field_name) { */ 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); } diff --git a/core/modules/entity/lib/Drupal/entity/EntityDisplayModeListController.php b/core/modules/entity/lib/Drupal/entity/EntityDisplayModeListController.php index 062b3adae806..d904af2f4a7d 100644 --- a/core/modules/entity/lib/Drupal/entity/EntityDisplayModeListController.php +++ b/core/modules/entity/lib/Drupal/entity/EntityDisplayModeListController.php @@ -19,11 +19,11 @@ 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 @@ public function load() { 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 @@ public function render() { $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 @@ public function render() { * doesn't has the correct controller. */ protected function isValidEntity($entity_type) { - return $this->entityInfoComplete[$entity_type]->hasViewBuilderClass(); + return $this->entityTypes[$entity_type]->hasViewBuilderClass(); } } diff --git a/core/modules/entity/lib/Drupal/entity/EntityFormModeListController.php b/core/modules/entity/lib/Drupal/entity/EntityFormModeListController.php index eb55bb02642d..04bc923b2c57 100644 --- a/core/modules/entity/lib/Drupal/entity/EntityFormModeListController.php +++ b/core/modules/entity/lib/Drupal/entity/EntityFormModeListController.php @@ -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(); } } diff --git a/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeAddForm.php b/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeAddForm.php index 203baa03572c..dee20fbde5c1 100644 --- a/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeAddForm.php +++ b/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeAddForm.php @@ -15,18 +15,20 @@ 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 @@ public function buildForm(array $form, array &$form_state, $entity_type = NULL) 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; } } diff --git a/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeDeleteForm.php b/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeDeleteForm.php index d1bdd51bc80c..8de83778060a 100644 --- a/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeDeleteForm.php +++ b/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeDeleteForm.php @@ -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 @@ public function getCancelRoute() { * {@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 @@ public function getQuestion() { * {@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 @@ public function getConfirmText() { 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'; } } diff --git a/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeEditForm.php b/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeEditForm.php index 48c2b96f1ffa..071f433d19d2 100644 --- a/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeEditForm.php +++ b/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeEditForm.php @@ -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( diff --git a/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeFormBase.php b/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeFormBase.php index 3da81437a5c3..4247502f21c8 100644 --- a/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeFormBase.php +++ b/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeFormBase.php @@ -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 @@ public static function create(ContainerInterface $container) { */ 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 @@ public function exists($entity_id, array $element, array $form_state) { 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 @@ public function exists($entity_id, array $element, array $form_state) { * {@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'; } } diff --git a/core/modules/entity/lib/Drupal/entity/Form/EntityFormModeAddForm.php b/core/modules/entity/lib/Drupal/entity/Form/EntityFormModeAddForm.php index 05680c4027bb..4cdece57dd17 100644 --- a/core/modules/entity/lib/Drupal/entity/Form/EntityFormModeAddForm.php +++ b/core/modules/entity/lib/Drupal/entity/Form/EntityFormModeAddForm.php @@ -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; } } diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php index 70996c704325..40e3c396fb46 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldFormatter/EntityReferenceEntityFormatter.php @@ -92,7 +92,7 @@ public function viewElements(FieldItemListInterface $items) { 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)) { diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldWidget/AutocompleteWidgetBase.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldWidget/AutocompleteWidgetBase.php index 4621c5c17dfe..e660056083c1 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldWidget/AutocompleteWidgetBase.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Plugin/Field/FieldWidget/AutocompleteWidgetBase.php @@ -77,7 +77,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen $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(), ); diff --git a/core/modules/field/field.attach.inc b/core/modules/field/field.attach.inc index 0eaf79d93705..d471223e106f 100644 --- a/core/modules/field/field.attach.inc +++ b/core/modules/field/field.attach.inc @@ -85,7 +85,7 @@ * 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(); diff --git a/core/modules/field/field.deprecated.inc b/core/modules/field/field.deprecated.inc index 02f60e3ec2ed..1e63781743b1 100644 --- a/core/modules/field/field.deprecated.inc +++ b/core/modules/field/field.deprecated.inc @@ -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. diff --git a/core/modules/field/field.module b/core/modules/field/field.module index fc29d92806cd..0aaffb5ae20b 100644 --- a/core/modules/field/field.module +++ b/core/modules/field/field.module @@ -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; diff --git a/core/modules/field/lib/Drupal/field/FieldInstanceStorageController.php b/core/modules/field/lib/Drupal/field/FieldInstanceStorageController.php index be9b370a40ef..793f231c6b7c 100644 --- a/core/modules/field/lib/Drupal/field/FieldInstanceStorageController.php +++ b/core/modules/field/lib/Drupal/field/FieldInstanceStorageController.php @@ -107,18 +107,18 @@ public function loadByProperties(array $conditions = array()) { 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); } } diff --git a/core/modules/field/lib/Drupal/field/FieldStorageController.php b/core/modules/field/lib/Drupal/field/FieldStorageController.php index a1f9716d4119..71327e70c8af 100644 --- a/core/modules/field/lib/Drupal/field/FieldStorageController.php +++ b/core/modules/field/lib/Drupal/field/FieldStorageController.php @@ -100,18 +100,18 @@ public function loadByProperties(array $conditions = array()) { 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); } } diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php index ccd6cd1ae729..8f964e059126 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldAttachOtherTest.php @@ -261,7 +261,7 @@ function testFieldAttachCache() { $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); diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php index 6d3ecb7e5431..9d2aa72836e6 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldAttachStorageTest.php @@ -156,7 +156,7 @@ function testFieldAttachLoadMultiple() { } // 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 @@ function testFieldAttachDelete() { $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 @@ function testEntityCreateRenameBundle() { $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 @@ function testEntityDeleteBundle() { 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()); diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldTestBase.php b/core/modules/field/lib/Drupal/field/Tests/FieldTestBase.php index 3cc3d7f55052..3f5d2c5d0de1 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldTestBase.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldTestBase.php @@ -52,8 +52,8 @@ function _generateTestFieldValues($cardinality) { */ 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(); diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldUnitTestBase.php b/core/modules/field/lib/Drupal/field/Tests/FieldUnitTestBase.php index 4f83cc5f2256..b27e88edb266 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldUnitTestBase.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldUnitTestBase.php @@ -109,7 +109,7 @@ function createFieldWithInstance($suffix = '', $entity_type = 'entity_test', $bu */ 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 @@ function _generateTestFieldValues($cardinality) { */ 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(); diff --git a/core/modules/field/tests/modules/field_test/field_test.entity.inc b/core/modules/field/tests/modules/field_test/field_test.entity.inc index af6482dd5613..af135909cbf9 100644 --- a/core/modules/field/tests/modules/field_test/field_test.entity.inc +++ b/core/modules/field/tests/modules/field_test/field_test.entity.inc @@ -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( diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module index ef392cf69717..4af1e90f5440 100644 --- a/core/modules/field_ui/field_ui.module +++ b/core/modules/field_ui/field_ui.module @@ -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()) { diff --git a/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php b/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php index 6a80350ac930..cd462175e67e 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php @@ -560,7 +560,7 @@ public function submitForm(array &$form, array &$form_state) { // 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(); } diff --git a/core/modules/file/file.api.php b/core/modules/file/file.api.php index ebc32aca95c5..202081dceca3 100644 --- a/core/modules/file/file.api.php +++ b/core/modules/file/file.api.php @@ -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'); } } diff --git a/core/modules/file/lib/Drupal/file/FileStorageController.php b/core/modules/file/lib/Drupal/file/FileStorageController.php index 1c0a3f133fb5..afa6b0b0e9ae 100644 --- a/core/modules/file/lib/Drupal/file/FileStorageController.php +++ b/core/modules/file/lib/Drupal/file/FileStorageController.php @@ -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 @@ public function spaceUsed($uid = NULL, $status = FILE_STATUS_PERMANENT) { 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 )); diff --git a/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileFieldItemList.php b/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileFieldItemList.php index 2b750b06f173..5f77d0d57edb 100644 --- a/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileFieldItemList.php +++ b/core/modules/file/lib/Drupal/file/Plugin/Field/FieldType/FileFieldItemList.php @@ -28,7 +28,7 @@ public function insert() { // 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 @@ public function update() { // 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 @@ public function update() { $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 @@ public function delete() { // 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 @@ public function deleteRevision() { // 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()); } } diff --git a/core/modules/file/tests/file_module_test/file_module_test.module b/core/modules/file/tests/file_module_test/file_module_test.module index abb16182342e..8d7015a21a10 100644 --- a/core/modules/file/tests/file_module_test/file_module_test.module +++ b/core/modules/file/tests/file_module_test/file_module_test.module @@ -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)) { diff --git a/core/modules/hal/lib/Drupal/hal/Normalizer/EntityNormalizer.php b/core/modules/hal/lib/Drupal/hal/Normalizer/EntityNormalizer.php index a3aa448d1894..a7687cf1745a 100644 --- a/core/modules/hal/lib/Drupal/hal/Normalizer/EntityNormalizer.php +++ b/core/modules/hal/lib/Drupal/hal/Normalizer/EntityNormalizer.php @@ -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 @@ public function normalize($entity, $format = NULL, array $context = array()) { // 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); } diff --git a/core/modules/hal/lib/Drupal/hal/Normalizer/EntityReferenceItemNormalizer.php b/core/modules/hal/lib/Drupal/hal/Normalizer/EntityReferenceItemNormalizer.php index c615933639a7..7152070ab9fa 100644 --- a/core/modules/hal/lib/Drupal/hal/Normalizer/EntityReferenceItemNormalizer.php +++ b/core/modules/hal/lib/Drupal/hal/Normalizer/EntityReferenceItemNormalizer.php @@ -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 @@ public function normalize($field_item, $format = NULL, array $context = array()) // 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), diff --git a/core/modules/language/language.api.php b/core/modules/language/language.api.php index e93f508dc925..415faac38faf 100644 --- a/core/modules/language/language.api.php +++ b/core/modules/language/language.api.php @@ -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); } } diff --git a/core/modules/language/lib/Drupal/language/LanguageListController.php b/core/modules/language/lib/Drupal/language/LanguageListController.php index 601d0598de8d..81af62fed1fb 100644 --- a/core/modules/language/lib/Drupal/language/LanguageListController.php +++ b/core/modules/language/lib/Drupal/language/LanguageListController.php @@ -27,7 +27,7 @@ public function load() { // 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; } diff --git a/core/modules/link/lib/Drupal/link/Plugin/Field/FieldFormatter/LinkFormatter.php b/core/modules/link/lib/Drupal/link/Plugin/Field/FieldFormatter/LinkFormatter.php index ef8db96d024e..111ce3446c96 100644 --- a/core/modules/link/lib/Drupal/link/Plugin/Field/FieldFormatter/LinkFormatter.php +++ b/core/modules/link/lib/Drupal/link/Plugin/Field/FieldFormatter/LinkFormatter.php @@ -127,7 +127,7 @@ public function viewElements(FieldItemListInterface $items) { 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. diff --git a/core/modules/link/lib/Drupal/link/Plugin/Field/FieldFormatter/LinkSeparateFormatter.php b/core/modules/link/lib/Drupal/link/Plugin/Field/FieldFormatter/LinkSeparateFormatter.php index f1f9d64802e1..4392123f4b96 100644 --- a/core/modules/link/lib/Drupal/link/Plugin/Field/FieldFormatter/LinkSeparateFormatter.php +++ b/core/modules/link/lib/Drupal/link/Plugin/Field/FieldFormatter/LinkSeparateFormatter.php @@ -48,7 +48,7 @@ public function viewElements(FieldItemListInterface $items) { 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 diff --git a/core/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php b/core/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php index e71beac2c9ae..bf61616dc2b7 100644 --- a/core/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php +++ b/core/modules/link/lib/Drupal/link/Tests/LinkFieldTest.php @@ -515,7 +515,7 @@ protected function renderTestEntity($id, $view_mode = 'full', $reset = TRUE) { $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); diff --git a/core/modules/menu_link/lib/Drupal/menu_link/Entity/MenuLink.php b/core/modules/menu_link/lib/Drupal/menu_link/Entity/MenuLink.php index 6d7001488cf0..0eeb19733ad8 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/Entity/MenuLink.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/Entity/MenuLink.php @@ -283,7 +283,7 @@ public function setNewRevision($value = TRUE) { * {@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 @@ public function getRevisionId() { */ 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 @@ public function reset() { $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) { diff --git a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php index bc2c71d03a50..ba6f63fa4e36 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php @@ -262,7 +262,7 @@ public function buildEntity(array $form, array &$form_state) { // 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)); } } diff --git a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php index d8add8e6a989..aa81aee30f20 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkStorageController.php @@ -117,11 +117,11 @@ public function save(EntityInterface $entity) { 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 @@ public function save(EntityInterface $entity) { // $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 @@ public function save(EntityInterface $entity) { } 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 @@ public function loadUpdatedCustomized(array $router_paths) { ); $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 @@ public function updateParentalStatus(EntityInterface $entity, $exclude = FALSE) // 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 @@ public function findChildrenRelativeDepth(EntityInterface $entity) { * {@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 @@ public function moveChildren(EntityInterface $entity) { * {@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 @@ public function getParentFromHierarchy(EntityInterface $entity) { $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') diff --git a/core/modules/node/lib/Drupal/node/Entity/Node.php b/core/modules/node/lib/Drupal/node/Entity/Node.php index 0d4683ec4002..c97f94955f5e 100644 --- a/core/modules/node/lib/Drupal/node/Entity/Node.php +++ b/core/modules/node/lib/Drupal/node/Entity/Node.php @@ -181,7 +181,7 @@ public function access($operation = 'view', AccountInterface $account = NULL) { } return \Drupal::entityManager() - ->getAccessController($this->entityType) + ->getAccessController($this->entityTypeId) ->access($this, $operation, $this->prepareLangcode(), $account); } diff --git a/core/modules/node/node.module b/core/modules/node/node.module index 9cbb1f95d6b4..e503badb4993 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -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'); } } diff --git a/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListItemBase.php b/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListItemBase.php index eb0970ee3bcc..bd89bb62b515 100644 --- a/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListItemBase.php +++ b/core/modules/options/lib/Drupal/options/Plugin/Field/FieldType/ListItemBase.php @@ -214,7 +214,7 @@ public function validateAllowedValues($element, &$form_state) { // 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.')); } } diff --git a/core/modules/options/options.module b/core/modules/options/options.module index 5953ab1c365f..5ebcda2b3ea6 100644 --- a/core/modules/options/options.module +++ b/core/modules/options/options.module @@ -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 diff --git a/core/modules/rest/lib/Drupal/rest/Plugin/rest/resource/EntityResource.php b/core/modules/rest/lib/Drupal/rest/Plugin/rest/resource/EntityResource.php index ae90d745ee07..53281e19e5d3 100644 --- a/core/modules/rest/lib/Drupal/rest/Plugin/rest/resource/EntityResource.php +++ b/core/modules/rest/lib/Drupal/rest/Plugin/rest/resource/EntityResource.php @@ -80,7 +80,7 @@ public function post($id, EntityInterface $entity = NULL) { $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 @@ public function post($id, EntityInterface $entity = NULL) { $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 @@ public function patch($id, EntityInterface $entity = NULL) { 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 @@ public function patch($id, EntityInterface $entity = NULL) { $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 @@ public function delete($id) { } 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); diff --git a/core/modules/search/lib/Drupal/search/SearchPageRepository.php b/core/modules/search/lib/Drupal/search/SearchPageRepository.php index e2af5ffd52ef..24e7eee2510e 100644 --- a/core/modules/search/lib/Drupal/search/SearchPageRepository.php +++ b/core/modules/search/lib/Drupal/search/SearchPageRepository.php @@ -109,7 +109,7 @@ public function setDefaultSearchPage(SearchPageInterface $search_page) { * {@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; } diff --git a/core/modules/search/tests/Drupal/search/Tests/SearchPageRepositoryTest.php b/core/modules/search/tests/Drupal/search/Tests/SearchPageRepositoryTest.php index d12ae684ce0b..131f8fc129be 100644 --- a/core/modules/search/tests/Drupal/search/Tests/SearchPageRepositoryTest.php +++ b/core/modules/search/tests/Drupal/search/Tests/SearchPageRepositoryTest.php @@ -270,7 +270,7 @@ public function testSortSearchPages() { ->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 diff --git a/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php b/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php index c3dc920bd2b8..c6c763687323 100644 --- a/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php +++ b/core/modules/serialization/lib/Drupal/serialization/Tests/EntitySerializationTest.php @@ -173,7 +173,7 @@ public function testDenormalize() { 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.'); } diff --git a/core/modules/system/entity.api.php b/core/modules/system/entity.api.php index 451de06e980c..b7a566bf7a67 100644 --- a/core/modules/system/entity.api.php +++ b/core/modules/system/entity.api.php @@ -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'; } } diff --git a/core/modules/system/lib/Drupal/system/Form/DateFormatFormBase.php b/core/modules/system/lib/Drupal/system/Form/DateFormatFormBase.php index 7ed89ec7a57f..caae9f74e93e 100644 --- a/core/modules/system/lib/Drupal/system/Form/DateFormatFormBase.php +++ b/core/modules/system/lib/Drupal/system/Form/DateFormatFormBase.php @@ -95,7 +95,7 @@ public static function create(ContainerInterface $container) { */ 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(); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php index eb234b4166f1..777fa46b0e9f 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityTranslationTest.php @@ -432,7 +432,7 @@ function testEntityTranslationAPI() { // Check that per-language defaults are properly populated. $entity = $this->reloadEntity($entity); - $instance_id = implode('.', array($entity->entityType(), $entity->bundle(), $this->field_name)); + $instance_id = implode('.', array($entity->getEntityTypeId(), $entity->bundle(), $this->field_name)); $instance = $this->entityManager->getStorageController('field_instance')->load($instance_id); $instance->default_value_function = 'entity_test_field_default_value'; $instance->save(); diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityUnitTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityUnitTestBase.php index ccf6070fbc6d..8537fbb1592a 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityUnitTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityUnitTestBase.php @@ -91,7 +91,7 @@ protected function createUser($values = array(), $permissions = array()) { * The reloaded entity. */ protected function reloadEntity(EntityInterface $entity) { - $controller = $this->entityManager->getStorageController($entity->entityType()); + $controller = $this->entityManager->getStorageController($entity->getEntityTypeId()); $controller->resetCache(array($entity->id())); return $controller->load($entity->id()); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/FieldTranslationSqlStorageTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/FieldTranslationSqlStorageTest.php index b6790aa10e58..45fd696175f4 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/FieldTranslationSqlStorageTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/FieldTranslationSqlStorageTest.php @@ -85,7 +85,7 @@ public function testFieldSqlStorage() { */ protected function assertFieldStorageLangcode(ContentEntityInterface $entity, $message = '') { $status = TRUE; - $entity_type = $entity->entityType(); + $entity_type = $entity->getEntityTypeId(); $id = $entity->id(); $langcode = $entity->getUntranslated()->language()->id; $fields = array($this->field_name, $this->untranslatable_field_name); diff --git a/core/modules/system/tests/modules/entity_crud_hook_test/entity_crud_hook_test.module b/core/modules/system/tests/modules/entity_crud_hook_test/entity_crud_hook_test.module index 9ee487aa11a1..e88ae9978616 100644 --- a/core/modules/system/tests/modules/entity_crud_hook_test/entity_crud_hook_test.module +++ b/core/modules/system/tests/modules/entity_crud_hook_test/entity_crud_hook_test.module @@ -11,7 +11,7 @@ * Implements hook_entity_create(). */ function entity_crud_hook_test_entity_create(EntityInterface $entity) { - $_SESSION['entity_crud_hook_test'][] = (__FUNCTION__ . ' called for type ' . $entity->entityType()); + $_SESSION['entity_crud_hook_test'][] = (__FUNCTION__ . ' called for type ' . $entity->getEntityTypeId()); } /** @@ -67,7 +67,7 @@ function entity_crud_hook_test_user_create() { * Implements hook_entity_presave(). */ function entity_crud_hook_test_entity_presave(EntityInterface $entity) { - $_SESSION['entity_crud_hook_test'][] = (__FUNCTION__ . ' called for type ' . $entity->entityType()); + $_SESSION['entity_crud_hook_test'][] = (__FUNCTION__ . ' called for type ' . $entity->getEntityTypeId()); } /** @@ -123,7 +123,7 @@ function entity_crud_hook_test_user_presave() { * Implements hook_entity_insert(). */ function entity_crud_hook_test_entity_insert(EntityInterface $entity) { - $_SESSION['entity_crud_hook_test'][] = (__FUNCTION__ . ' called for type ' . $entity->entityType()); + $_SESSION['entity_crud_hook_test'][] = (__FUNCTION__ . ' called for type ' . $entity->getEntityTypeId()); } /** @@ -235,7 +235,7 @@ function entity_crud_hook_test_user_load() { * Implements hook_entity_update(). */ function entity_crud_hook_test_entity_update(EntityInterface $entity) { - $_SESSION['entity_crud_hook_test'][] = (__FUNCTION__ . ' called for type ' . $entity->entityType()); + $_SESSION['entity_crud_hook_test'][] = (__FUNCTION__ . ' called for type ' . $entity->getEntityTypeId()); } /** @@ -291,7 +291,7 @@ function entity_crud_hook_test_user_update() { * Implements hook_entity_predelete(). */ function entity_crud_hook_test_entity_predelete(EntityInterface $entity) { - $_SESSION['entity_crud_hook_test'][] = (__FUNCTION__ . ' called for type ' . $entity->entityType()); + $_SESSION['entity_crud_hook_test'][] = (__FUNCTION__ . ' called for type ' . $entity->getEntityTypeId()); } /** @@ -347,7 +347,7 @@ function entity_crud_hook_test_user_predelete() { * Implements hook_entity_delete(). */ function entity_crud_hook_test_entity_delete(EntityInterface $entity) { - $_SESSION['entity_crud_hook_test'][] = (__FUNCTION__ . ' called for type ' . $entity->entityType()); + $_SESSION['entity_crud_hook_test'][] = (__FUNCTION__ . ' called for type ' . $entity->getEntityTypeId()); } /** diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTest.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTest.php index 9798c4f0d092..b7f799ca053e 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTest.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Entity/EntityTest.php @@ -100,7 +100,7 @@ protected function init() { public static function preCreate(EntityStorageControllerInterface $storage_controller, array &$values) { parent::preCreate($storage_controller, $values); if (empty($values['type'])) { - $values['type'] = $storage_controller->entityType(); + $values['type'] = $storage_controller->getEntityTypeId(); } } @@ -108,7 +108,7 @@ public static function preCreate(EntityStorageControllerInterface $storage_contr * Overrides Drupal\entity\Entity::label(). */ public function label() { - $info = $this->entityInfo(); + $info = $this->getEntityType(); if (!isset($langcode)) { $langcode = $this->activeLangcode; } diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestFormController.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestFormController.php index 89fe5acfe0a4..61e10c315f54 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestFormController.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestFormController.php @@ -49,7 +49,7 @@ public function form(array $form, array &$form_state) { ); // @todo: Is there a better way to check if an entity type is revisionable? - $entity_info = $entity->entityInfo(); + $entity_info = $entity->getEntityType(); if ($entity_info->hasKey('revision') && !$entity->isNew()) { $form['revision'] = array( '#type' => 'checkbox', @@ -85,15 +85,15 @@ public function save(array $form, array &$form_state) { $entity->save(); if ($is_new) { - $message = t('%entity_type @id has been created.', array('@id' => $entity->id(), '%entity_type' => $entity->entityType())); + $message = t('%entity_type @id has been created.', array('@id' => $entity->id(), '%entity_type' => $entity->getEntityTypeId())); } else { - $message = t('%entity_type @id has been updated.', array('@id' => $entity->id(), '%entity_type' => $entity->entityType())); + $message = t('%entity_type @id has been updated.', array('@id' => $entity->id(), '%entity_type' => $entity->getEntityTypeId())); } drupal_set_message($message); if ($entity->id()) { - $entity_type = $entity->entityType(); + $entity_type = $entity->getEntityTypeId(); $form_state['redirect_route'] = array( 'route_name' => "entity_test.edit_$entity_type", 'route_parameters' => array( @@ -114,7 +114,7 @@ public function save(array $form, array &$form_state) { public function delete(array $form, array &$form_state) { $entity = $this->entity; $entity->delete(); - drupal_set_message(t('%entity_type @id has been deleted.', array('@id' => $entity->id(), '%entity_type' => $entity->entityType()))); + drupal_set_message(t('%entity_type @id has been deleted.', array('@id' => $entity->id(), '%entity_type' => $entity->getEntityTypeId()))); $form_state['redirect_route']['route_name'] = '<front>'; } } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldWidget/TaxonomyAutocompleteWidget.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldWidget/TaxonomyAutocompleteWidget.php index e8e446bb884d..7c207322fb07 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldWidget/TaxonomyAutocompleteWidget.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Field/FieldWidget/TaxonomyAutocompleteWidget.php @@ -73,7 +73,7 @@ public function formElement(FieldItemListInterface $items, $delta, array $elemen '#default_value' => taxonomy_implode_tags($tags), '#autocomplete_route_name' => $this->getSetting('autocomplete_route_name'), '#autocomplete_route_parameters' => array( - 'entity_type' => $items->getEntity()->entityType(), + 'entity_type' => $items->getEntity()->getEntityTypeId(), 'field_name' => $this->fieldDefinition->getName(), ), '#size' => $this->getSetting('size'), diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/TermViewBuilder.php b/core/modules/taxonomy/lib/Drupal/taxonomy/TermViewBuilder.php index fbf29eac6469..27efd9f92137 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/TermViewBuilder.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/TermViewBuilder.php @@ -44,8 +44,8 @@ protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langco $return = parent::getBuildDefaults($entity, $view_mode, $langcode); // TODO: rename "term" to "taxonomy_term" in theme_taxonomy_term(). - $return['#term'] = $return["#{$this->entityType}"]; - unset($return["#{$this->entityType}"]); + $return['#term'] = $return["#{$this->entityTypeId}"]; + unset($return["#{$this->entityTypeId}"]); return $return; } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php index 60c466196154..9a2aa4396a2f 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldMultipleVocabularyTest.php @@ -101,7 +101,7 @@ function testTaxonomyTermFieldMultipleVocabularies() { // Render the entity. $entity = entity_load('entity_test', $id); $entities = array($id => $entity); - $display = entity_get_display($entity->entityType(), $entity->bundle(), 'full'); + $display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), 'full'); field_attach_prepare_view('entity_test', $entities, array($entity->bundle() => $display)); $entity->content = field_attach_view($entity, $display); $this->content = drupal_render($entity->content); @@ -114,7 +114,7 @@ function testTaxonomyTermFieldMultipleVocabularies() { // Re-render the content. $entity = entity_load('entity_test', $id); $entities = array($id => $entity); - $display = entity_get_display($entity->entityType(), $entity->bundle(), 'full'); + $display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), 'full'); field_attach_prepare_view('entity_test', $entities, array($entity->bundle() => $display)); $entity->content = field_attach_view($entity, $display); $this->plainTextContent = FALSE; diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php index 75ff53579f4b..079b93d88e65 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermFieldTest.php @@ -118,7 +118,7 @@ function testTaxonomyTermFieldWidgets() { // Display the object. $entity = entity_load('entity_test', $id); $entities = array($id => $entity); - $display = entity_get_display($entity->entityType(), $entity->bundle(), 'full'); + $display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), 'full'); field_attach_prepare_view('entity_test', $entities, array($entity->bundle() => $display)); $entity->content = field_attach_view($entity, $display); $this->content = drupal_render($entity->content); diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index c1aa72eff8cf..cf750335591c 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -769,7 +769,7 @@ function taxonomy_term_load($tid) { * Implements hook_file_download_access(). */ function taxonomy_file_download_access($field, EntityInterface $entity, FileInterface $file) { - if ($entity->entityType() == 'taxonomy_term') { + if ($entity->getEntityTypeId() == 'taxonomy_term') { return $entity->access('view'); } } diff --git a/core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php b/core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php index f209a4491867..a6a318baf0b7 100644 --- a/core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php +++ b/core/modules/text/lib/Drupal/text/Tests/TextFieldTest.php @@ -138,7 +138,7 @@ function _testTextfieldWidgets($field_type, $widget_type) { // Display the entity. $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->assertText($value, 'Filtered tags are not displayed'); @@ -211,7 +211,7 @@ function _testTextfieldWidgetsFormatted($field_type, $widget_type) { // Display the entity. $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->content = drupal_render($entity->content); $this->assertNoRaw($value, 'HTML tags are not displayed.'); @@ -253,7 +253,7 @@ function _testTextfieldWidgetsFormatted($field_type, $widget_type) { // Display the entity. $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(), 'full'); + $display = entity_get_display($entity->getEntityTypeId(), $entity->bundle(), 'full'); $entity->content = field_attach_view($entity, $display); $this->content = drupal_render($entity->content); $this->assertRaw($value, 'Value is displayed unfiltered'); diff --git a/core/modules/user/tests/Drupal/user/Tests/Views/Argument/RolesRidTest.php b/core/modules/user/tests/Drupal/user/Tests/Views/Argument/RolesRidTest.php index 054d25a1cbae..a5c9226c7df8 100644 --- a/core/modules/user/tests/Drupal/user/Tests/Views/Argument/RolesRidTest.php +++ b/core/modules/user/tests/Drupal/user/Tests/Views/Argument/RolesRidTest.php @@ -71,7 +71,7 @@ public function testTitleQuery() { ->with($this->equalTo('user_role')) ->will($this->returnValue($role_storage_controller)); - // @todo \Drupal\Core\Entity\Entity::entityInfo() uses a global call to + // @todo \Drupal\Core\Entity\Entity::entityType() uses a global call to // entity_get_info(), which in turn wraps \Drupal::entityManager(). Set // the entity manager until this is fixed. $container = new ContainerBuilder(); diff --git a/core/modules/user/user.module b/core/modules/user/user.module index b6b9f5392a2a..679edbbce400 100644 --- a/core/modules/user/user.module +++ b/core/modules/user/user.module @@ -1835,7 +1835,7 @@ function user_cookie_delete($cookie_name) { * Implements hook_file_download_access(). */ function user_file_download_access($field, EntityInterface $entity, File $file) { - if ($entity->entityType() == 'user') { + if ($entity->getEntityTypeId() == 'user') { return $entity->access('view'); } } diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php b/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php index c07b84607990..cfad8fe41e79 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php @@ -348,13 +348,13 @@ protected function getCacheTags() { // Collect entity IDs if there are view results. if (!empty($this->view->result)) { foreach ($this->view->result as $result) { - $type = $result->_entity->entityType(); + $type = $result->_entity->getEntityTypeId(); $tags[$type][] = $result->_entity->id(); $tags[$type . '_view_' . $result->_entity->bundle()] = TRUE; foreach ($result->_relationship_entities as $entity) { - $type = $entity->entityType(); + $type = $entity->getEntityTypeId(); $tags[$type][] = $entity->id(); $tags[$type . '_view_' . $entity->bundle()] = TRUE; diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/filter/Bundle.php b/core/modules/views/lib/Drupal/views/Plugin/views/filter/Bundle.php index bc4b201b016b..80313f4bcabd 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/filter/Bundle.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/filter/Bundle.php @@ -24,14 +24,14 @@ class Bundle extends InOperator { * * @var string */ - protected $entityType; + protected $entityTypeId; /** - * The entity info for the entity type. + * The entity type definition. * * @var \Drupal\Core\Entity\EntityTypeInterface */ - protected $entityInfo; + protected $entityType; /** * Overrides \Drupal\views\Plugin\views\filter\InOperator::init(). @@ -39,9 +39,9 @@ class Bundle extends InOperator { public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) { parent::init($view, $display, $options); - $this->entityType = $this->getEntityType(); - $this->entityInfo = \Drupal::entityManager()->getDefinition($this->entityType); - $this->real_field = $this->entityInfo->getKey('bundle'); + $this->entityTypeId = $this->getEntityType(); + $this->entityType = \Drupal::entityManager()->getDefinition($this->entityTypeId); + $this->real_field = $this->entityType->getKey('bundle'); } /** @@ -49,8 +49,8 @@ public function init(ViewExecutable $view, DisplayPluginBase $display, array &$o */ public function getValueOptions() { if (!isset($this->value_options)) { - $types = entity_get_bundles($this->entityType); - $this->value_title = t('@entity types', array('@entity' => $this->entityInfo->getLabel())); + $types = entity_get_bundles($this->entityTypeId); + $this->value_title = t('@entity types', array('@entity' => $this->entityType->getLabel())); $options = array(); foreach ($types as $type => $info) { diff --git a/core/modules/views/lib/Drupal/views/Plugin/views/row/EntityRow.php b/core/modules/views/lib/Drupal/views/Plugin/views/row/EntityRow.php index f7d9510f8537..dab155d3660a 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/views/row/EntityRow.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/row/EntityRow.php @@ -37,18 +37,18 @@ class EntityRow extends RowPluginBase { public $base_field; /** - * Stores the entity type of the result entities. + * Stores the entity type ID of the result entities. * * @var string */ - protected $entityType; + protected $entityTypeId; /** - * Contains the entity info of the entity type of this row plugin instance. + * Contains the entity type of this row plugin instance. * * @var \Drupal\Core\Entity\EntityTypeInterface */ - protected $entityInfo; + protected $entityType; /** * Contains an array of render arrays, one for each rendered entity. @@ -75,10 +75,10 @@ public function __construct(array $configuration, $plugin_id, array $plugin_defi public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) { parent::init($view, $display, $options); - $this->entityType = $this->definition['entity_type']; - $this->entityInfo = $this->entityManager->getDefinition($this->entityType); - $this->base_table = $this->entityInfo->getBaseTable(); - $this->base_field = $this->entityInfo->getKey('id'); + $this->entityTypeId = $this->definition['entity_type']; + $this->entityType = $this->entityManager->getDefinition($this->entityTypeId); + $this->base_table = $this->entityType->getBaseTable(); + $this->base_field = $this->entityType->getKey('id'); } /** @@ -119,7 +119,7 @@ public function buildOptionsForm(&$form, &$form_state) { */ protected function buildViewModeOptions() { $options = array('default' => t('Default')); - $view_modes = entity_get_view_modes($this->entityType); + $view_modes = entity_get_view_modes($this->entityTypeId); foreach ($view_modes as $mode => $settings) { $options[$mode] = $settings['label']; } diff --git a/core/modules/views/lib/Drupal/views/ResultRow.php b/core/modules/views/lib/Drupal/views/ResultRow.php index 79186c9b2f8d..018a0de58cb4 100644 --- a/core/modules/views/lib/Drupal/views/ResultRow.php +++ b/core/modules/views/lib/Drupal/views/ResultRow.php @@ -22,7 +22,7 @@ class ResultRow { /** * An array of relationship entities. * - * @var array \Drupal\Core\Entity\EntityInterface[] + * @var \Drupal\Core\Entity\EntityInterface[] */ public $_relationship_entities = array(); diff --git a/core/modules/views/lib/Drupal/views/ViewExecutable.php b/core/modules/views/lib/Drupal/views/ViewExecutable.php index b2b93dc14317..88ebefc54932 100644 --- a/core/modules/views/lib/Drupal/views/ViewExecutable.php +++ b/core/modules/views/lib/Drupal/views/ViewExecutable.php @@ -78,7 +78,7 @@ class ViewExecutable { * * The array must use a numeric index starting at 0. * - * @var array + * @var \Drupal\views\ResultRow[] */ public $result = array(); diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php index 1f5766de9491..6d40894963da 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php @@ -842,10 +842,10 @@ public function isNew() { } /** - * Implements \Drupal\Core\Entity\EntityInterface::entityType(). + * {@inheritdoc} */ - public function entityType() { - return $this->storage->entityType(); + public function getEntityTypeId() { + return $this->storage->getEntityTypeId(); } /** @@ -856,10 +856,10 @@ public function bundle() { } /** - * Implements \Drupal\Core\Entity\EntityInterface::entityInfo(). + * {@inheritdoc} */ - public function entityInfo() { - return $this->storage->entityInfo(); + public function getEntityType() { + return $this->storage->getEntityType(); } /** diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php index 81dc34daadea..24df3b7d5541 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php @@ -462,14 +462,14 @@ public function testGetForm() { $apple_entity = $this->getMock('Drupal\Core\Entity\EntityInterface'); $apple_entity->expects($this->once()) - ->method('entityType') + ->method('getEntityTypeId') ->will($this->returnValue('apple')); $this->assertSame('the form contents', $this->entityManager->getForm($apple_entity)); $banana_entity = $this->getMock('Drupal\Core\Entity\EntityInterface'); $banana_entity->expects($this->once()) - ->method('entityType') + ->method('getEntityTypeId') ->will($this->returnValue('banana')); $this->assertSame('the form contents', $this->entityManager->getForm($banana_entity)); -- GitLab