diff --git a/core/lib/Drupal/Core/Entity/ContentEntityInterface.php b/core/lib/Drupal/Core/Entity/ContentEntityInterface.php index 292c3fd..c67bea0 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityInterface.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityInterface.php @@ -12,22 +12,20 @@ /** * Defines a common interface for all content entity objects. * - * This interface builds upon the general interfaces provided by the typed data - * API, while extending them with content entity-specific additions. I.e., a - * content entity implements the ComplexDataInterface among others, thus is - * complex data containing fields as its data properties. The contained fields - * have to implement \Drupal\Core\Field\FieldItemListInterface, - * which builds upon typed data interfaces as well. + * Content entities use fields for all their entity properties and are + * translatable and revisionable, while translations and revisions can be + * enabled per entity type. It's best practice to always implement + * ContentEntityInterface for content-like entities that should be stored in + * some database, and enable/disable revisions and translations as desired. * * When implementing this interface which extends Traversable, make sure to list * IteratorAggregate or Iterator before this interface in the implements clause. * - * @see \Drupal\Core\TypedData\TypedDataManager - * @see \Drupal\Core\Field\FieldItemListInterface + * @see \Drupal\Core\Entity\ContentEntityBase * * @ingroup entity_api */ -interface ContentEntityInterface extends EntityInterface, RevisionableInterface, TranslatableInterface { +interface ContentEntityInterface extends FieldableEntityInterface, RevisionableInterface, TranslatableInterface { /** * Marks the translation identified by the given language code as existing. @@ -40,181 +38,4 @@ */ public function initTranslation($langcode); - /** - * Provides base field definitions for an entity type. - * - * Implementations typically use the class - * \Drupal\Core\Field\BaseFieldDefinition for creating the field definitions; - * for example a 'name' field could be defined as the following: - * @code - * $fields['name'] = BaseFieldDefinition::create('string') - * ->setLabel(t('Name')); - * @endcode - * - * By definition, base fields are fields that exist for every bundle. To - * provide definitions for fields that should only exist on some bundles, use - * \Drupal\Core\Entity\ContentEntityInterface::bundleFieldDefinitions(). - * - * The definitions returned by this function can be overridden for all - * bundles by hook_entity_base_field_info_alter() or overridden on a - * per-bundle basis via 'base_field_override' configuration entities. - * - * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type - * The entity type definition. Useful when a single class is used for multiple, - * possibly dynamic entity types. - * - * @return \Drupal\Core\Field\FieldDefinitionInterface[] - * An array of base field definitions for the entity type, keyed by field - * name. - * - * @see \Drupal\Core\Entity\EntityManagerInterface::getFieldDefinitions() - * @see \Drupal\Core\Entity\ContentEntityInterface::bundleFieldDefinitions() - */ - public static function baseFieldDefinitions(EntityTypeInterface $entity_type); - - /** - * Provides field definitions for a specific bundle. - * - * This function can return definitions both for bundle fields (fields that - * are not defined in $base_field_definitions, and therefore might not exist - * on some bundles) as well as bundle-specific overrides of base fields - * (fields that are defined in $base_field_definitions, and therefore exist - * for all bundles). However, bundle-specific base field overrides can also - * be provided by 'base_field_override' configuration entities, and that is - * the recommended approach except in cases where an entity type needs to - * provide a bundle-specific base field override that is decoupled from - * configuration. Note that for most entity types, the bundles themselves are - * derived from configuration (e.g., 'node' bundles are managed via - * 'node_type' configuration entities), so decoupling bundle-specific base - * field overrides from configuration only makes sense for entity types that - * also decouple their bundles from configuration. In cases where both this - * function returns a bundle-specific override of a base field and a - * 'base_field_override' configuration entity exists, the latter takes - * precedence. - * - * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type - * The entity type definition. Useful when a single class is used for multiple, - * possibly dynamic entity types. - * @param string $bundle - * The bundle. - * @param \Drupal\Core\Field\FieldDefinitionInterface[] $base_field_definitions - * The list of base field definitions. - * - * @return \Drupal\Core\Field\FieldDefinitionInterface[] - * An array of bundle field definitions, keyed by field name. - * - * @see \Drupal\Core\Entity\EntityManagerInterface::getFieldDefinitions() - * @see \Drupal\Core\Entity\ContentEntityInterface::baseFieldDefinitions() - * - * @todo WARNING: This method will be changed in - * https://www.drupal.org/node/2346347. - */ - public static function bundleFieldDefinitions(EntityTypeInterface $entity_type, $bundle, array $base_field_definitions); - - /** - * Returns whether the entity has a field with the given name. - * - * @param string $field_name - * The field name. - * - * @return bool - * TRUE if the entity has a field with the given name. FALSE otherwise. - */ - public function hasField($field_name); - - /** - * Gets the definition of a contained field. - * - * @param string $name - * The name of the field. - * - * @return \Drupal\Core\Field\FieldDefinitionInterface|null - * The definition of the field or null if the field does not exist. - */ - public function getFieldDefinition($name); - - /** - * Gets an array of field definitions of all contained fields. - * - * @return \Drupal\Core\Field\FieldDefinitionInterface[] - * An array of field definitions, keyed by field name. - * - * @see \Drupal\Core\Entity\EntityManagerInterface::getFieldDefinitions() - */ - public function getFieldDefinitions(); - - /** - * Returns an array of all field values. - * - * Gets an array of plain field values, including only non-computed values. - * Note that the structure varies by entity type and bundle. - * - * @return array - * An array of field values, keyed by field name. - */ - public function toArray(); - - /** - * Gets a field item list. - * - * @param string $field_name - * The name of the field to get; e.g., 'title' or 'name'. - * - * @throws \InvalidArgumentException - * If an invalid field name is given. - * - * @return \Drupal\Core\Field\FieldItemListInterface - * The field item list, containing the field items. - */ - public function get($field_name); - - /** - * Sets a field value. - * - * @param string $field_name - * The name of the field to set; e.g., 'title' or 'name'. - * @param mixed $value - * The value to set, or NULL to unset the field. - * @param bool $notify - * (optional) Whether to notify the entity of the change. Defaults to - * TRUE. If the update stems from the entity, set it to FALSE to avoid - * being notified again. - * - * @throws \InvalidArgumentException - * If the specified field does not exist. - * - * @return $this - */ - public function set($field_name, $value, $notify = TRUE); - - /** - * Gets an array of field item lists. - * - * @param bool $include_computed - * If set to TRUE, computed fields are included. Defaults to FALSE. - * - * @return \Drupal\Core\Field\FieldItemListInterface[] - * An array of field item lists implementing, keyed by field name. - */ - public function getFields($include_computed = TRUE); - - /** - * Reacts to changes to a field. - * - * Note that this is invoked after any changes have been applied. - * - * @param string $field_name - * The name of the field which is changed. - */ - public function onChange($field_name); - - /** - * Validates the currently set values. - * - * @return \Symfony\Component\Validator\ConstraintViolationListInterface - * A list of constraint violations. If the list is empty, validation - * succeeded. - */ - public function validate(); - } diff --git a/core/lib/Drupal/Core/Entity/Controller/EntityViewController.php b/core/lib/Drupal/Core/Entity/Controller/EntityViewController.php index 9db0a64..1ef08c9 100644 --- a/core/lib/Drupal/Core/Entity/Controller/EntityViewController.php +++ b/core/lib/Drupal/Core/Entity/Controller/EntityViewController.php @@ -9,7 +9,7 @@ use Drupal\Core\DependencyInjection\ContainerInjectionInterface; use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Entity\ContentEntityInterface; +use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Entity\EntityManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -70,7 +70,7 @@ public function view(EntityInterface $_entity, $view_mode = 'full', $langcode = // rendered title field formatter as the page title instead of the default // plain text title. This allows attributes set on the field to propagate // correctly (e.g. RDFa, in-place editing). - if ($_entity instanceof ContentEntityInterface) { + if ($_entity instanceof FieldableEntityInterface) { $label_field = $_entity->getEntityType()->getKey('label'); if ($label_field && $_entity->getFieldDefinition($label_field)->getDisplayOptions('view')) { // We must render the label field, because rendering the entity may be diff --git a/core/lib/Drupal/Core/Entity/Display/EntityFormDisplayInterface.php b/core/lib/Drupal/Core/Entity/Display/EntityFormDisplayInterface.php index 5282532..57b5abf 100644 --- a/core/lib/Drupal/Core/Entity/Display/EntityFormDisplayInterface.php +++ b/core/lib/Drupal/Core/Entity/Display/EntityFormDisplayInterface.php @@ -7,7 +7,7 @@ namespace Drupal\Core\Entity\Display; -use Drupal\Core\Entity\ContentEntityInterface; +use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Form\FormStateInterface; /** @@ -86,7 +86,7 @@ * accessed by \Drupal\Core\Field\WidgetBaseInterface::getWidgetState() and * \Drupal\Core\Field\WidgetBaseInterface::setWidgetState(). * - * @param \Drupal\Core\Entity\ContentEntityInterface $entity + * @param \Drupal\Core\Entity\FieldableEntityInterface $entity * The entity. * @param array $form * The form structure to fill in. This can be a full form structure, or a @@ -98,7 +98,7 @@ * @param \Drupal\Core\Form\FormStateInterface $form_state * The form state. */ - public function buildForm(ContentEntityInterface $entity, array &$form, FormStateInterface $form_state); + public function buildForm(FieldableEntityInterface $entity, array &$form, FormStateInterface $form_state); /** * Validates submitted widget values and sets the corresponding form errors. @@ -119,7 +119,7 @@ public function buildForm(ContentEntityInterface $entity, array &$form, FormStat * It reports field constraint violations as form errors on the correct form * elements. * - * @param \Drupal\Core\Entity\ContentEntityInterface $entity + * @param \Drupal\Core\Entity\FieldableEntityInterface $entity * The entity. * @param array $form * The form structure where field elements are attached to. This might be a @@ -127,7 +127,7 @@ public function buildForm(ContentEntityInterface $entity, array &$form, FormStat * @param \Drupal\Core\Form\FormStateInterface $form_state * The form state. */ - public function validateFormValues(ContentEntityInterface $entity, array &$form, FormStateInterface $form_state); + public function validateFormValues(FieldableEntityInterface $entity, array &$form, FormStateInterface $form_state); /** * Extracts field values from the submitted widget values into the entity. @@ -135,7 +135,7 @@ public function validateFormValues(ContentEntityInterface $entity, array &$form, * This accounts for drag-and-drop reordering of field values, and filtering * of empty values. * - * @param \Drupal\Core\Entity\ContentEntityInterface $entity + * @param \Drupal\Core\Entity\FieldableEntityInterface $entity * The entity. * @param array $form * The form structure where field elements are attached to. This might be a @@ -149,6 +149,6 @@ public function validateFormValues(ContentEntityInterface $entity, array &$form, * if any, do not correspond to widgets and should be extracted manually by * the caller if needed. */ - public function extractFormValues(ContentEntityInterface $entity, array &$form, FormStateInterface $form_state); + public function extractFormValues(FieldableEntityInterface $entity, array &$form, FormStateInterface $form_state); } diff --git a/core/lib/Drupal/Core/Entity/Display/EntityViewDisplayInterface.php b/core/lib/Drupal/Core/Entity/Display/EntityViewDisplayInterface.php index 69ecb78..3771d81 100644 --- a/core/lib/Drupal/Core/Entity/Display/EntityViewDisplayInterface.php +++ b/core/lib/Drupal/Core/Entity/Display/EntityViewDisplayInterface.php @@ -7,7 +7,7 @@ namespace Drupal\Core\Entity\Display; -use Drupal\Core\Entity\ContentEntityInterface; +use Drupal\Core\Entity\FieldableEntityInterface; /** * Provides a common interface for entity view displays. @@ -19,7 +19,7 @@ * * See the buildMultiple() method for details. * - * @param \Drupal\Core\Entity\ContentEntityInterface $entity + * @param \Drupal\Core\Entity\FieldableEntityInterface $entity * The entity being displayed. * * @return array @@ -27,7 +27,7 @@ * * @see \Drupal\Core\Entity\Display\EntityViewDisplayInterface::buildMultiple() */ - public function build(ContentEntityInterface $entity); + public function build(FieldableEntityInterface $entity); /** * Returns a renderable array for the components of a set of entities. @@ -40,7 +40,7 @@ public function build(ContentEntityInterface $entity); * hook_entity_display_build_alter() is invoked on each entity, allowing 3rd * party code to alter the render array. * - * @param \Drupal\Core\Entity\ContentEntityInterface[] $entities + * @param \Drupal\Core\Entity\FieldableEntityInterface[] $entities * The entities being displayed. * * @return array diff --git a/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php b/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php index 6339c18..f512022 100644 --- a/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php +++ b/core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php @@ -7,7 +7,7 @@ namespace Drupal\Core\Entity\Entity; -use Drupal\Core\Entity\ContentEntityInterface; +use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Entity\Display\EntityFormDisplayInterface; use Drupal\Core\Entity\EntityDisplayBase; use Drupal\Core\Form\FormStateInterface; @@ -50,7 +50,7 @@ class EntityFormDisplay extends EntityDisplayBase implements EntityFormDisplayIn * party code to alter the display options held in the display before they are * used to generate render arrays. * - * @param \Drupal\Core\Entity\ContentEntityInterface $entity + * @param \Drupal\Core\Entity\FieldableEntityInterface $entity * The entity for which the form is being built. * @param string $form_mode * The form mode. @@ -61,7 +61,7 @@ class EntityFormDisplay extends EntityDisplayBase implements EntityFormDisplayIn * @see entity_get_form_display() * @see hook_entity_form_display_alter() */ - public static function collectRenderDisplay(ContentEntityInterface $entity, $form_mode) { + public static function collectRenderDisplay(FieldableEntityInterface $entity, $form_mode) { $entity_type = $entity->getEntityTypeId(); $bundle = $entity->bundle(); @@ -148,7 +148,7 @@ public function getRenderer($field_name) { /** * {@inheritdoc} */ - public function buildForm(ContentEntityInterface $entity, array &$form, FormStateInterface $form_state) { + public function buildForm(FieldableEntityInterface $entity, array &$form, FormStateInterface $form_state) { // Set #parents to 'top-level' by default. $form += array('#parents' => array()); @@ -197,7 +197,7 @@ public function processForm($element, FormStateInterface $form_state, $form) { /** * {@inheritdoc} */ - public function extractFormValues(ContentEntityInterface $entity, array &$form, FormStateInterface $form_state) { + public function extractFormValues(FieldableEntityInterface $entity, array &$form, FormStateInterface $form_state) { $extracted = array(); foreach ($entity as $name => $items) { if ($widget = $this->getRenderer($name)) { @@ -211,7 +211,7 @@ public function extractFormValues(ContentEntityInterface $entity, array &$form, /** * {@inheritdoc} */ - public function validateFormValues(ContentEntityInterface $entity, array &$form, FormStateInterface $form_state) { + public function validateFormValues(FieldableEntityInterface $entity, array &$form, FormStateInterface $form_state) { foreach ($entity as $field_name => $items) { // Only validate the fields that actually appear in the form, and let the // widget assign the violations to the right form elements. diff --git a/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php b/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php index 57041e9..9a73268 100644 --- a/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php +++ b/core/lib/Drupal/Core/Entity/Entity/EntityViewDisplay.php @@ -9,7 +9,7 @@ use Drupal\Component\Utility\NestedArray; use Drupal\Core\Entity\Display\EntityViewDisplayInterface; -use Drupal\Core\Entity\ContentEntityInterface; +use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Entity\EntityDisplayBase; /** @@ -50,7 +50,7 @@ class EntityViewDisplay extends EntityDisplayBase implements EntityViewDisplayIn * party code to alter the display options held in the display before they are * used to generate render arrays. * - * @param \Drupal\Core\Entity\ContentEntityInterface[] $entities + * @param \Drupal\Core\Entity\FieldableEntityInterface[] $entities * The entities being rendered. They should all be of the same entity type. * @param string $view_mode * The view mode being rendered. @@ -142,7 +142,7 @@ public static function collectRenderDisplays($entities, $view_mode) { * * See the collectRenderDisplays() method for details. * - * @param \Drupal\Core\Entity\ContentEntityInterface $entity + * @param \Drupal\Core\Entity\FieldableEntityInterface $entity * The entity being rendered. * @param string $view_mode * The view mode. @@ -152,7 +152,7 @@ public static function collectRenderDisplays($entities, $view_mode) { * * @see \Drupal\entity\Entity\EntityDisplay::collectRenderDisplays() */ - public static function collectRenderDisplay(ContentEntityInterface $entity, $view_mode) { + public static function collectRenderDisplay(FieldableEntityInterface $entity, $view_mode) { $displays = static::collectRenderDisplays(array($entity), $view_mode); return $displays[$entity->bundle()]; } @@ -196,7 +196,7 @@ public function getRenderer($field_name) { /** * {@inheritdoc} */ - public function build(ContentEntityInterface $entity) { + public function build(FieldableEntityInterface $entity) { $build = $this->buildMultiple(array($entity)); return $build[0]; } diff --git a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php index c57b3a6..251bb00 100644 --- a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php +++ b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php @@ -115,7 +115,7 @@ public function __construct(array $values, $entity_type) { throw new \InvalidArgumentException('Missing required properties for an EntityDisplay entity.'); } - if (!$this->entityManager()->getDefinition($values['targetEntityType'])->isSubclassOf('\Drupal\Core\Entity\ContentEntityInterface')) { + if (!$this->entityManager()->getDefinition($values['targetEntityType'])->isSubclassOf('\Drupal\Core\Entity\FieldableEntityInterface')) { throw new \InvalidArgumentException('EntityDisplay entities can only handle content entity types.'); } @@ -357,7 +357,7 @@ protected function getFieldDefinition($field_name) { protected function getFieldDefinitions() { // Entity displays are sometimes created for non-content entities. // @todo Prevent this in https://drupal.org/node/2095195. - if (!\Drupal::entityManager()->getDefinition($this->targetEntityType)->isSubclassOf('\Drupal\Core\Entity\ContentEntityInterface')) { + if (!\Drupal::entityManager()->getDefinition($this->targetEntityType)->isSubclassOf('\Drupal\Core\Entity\FieldableEntityInterface')) { return array(); } diff --git a/core/lib/Drupal/Core/Entity/EntityInterface.php b/core/lib/Drupal/Core/Entity/EntityInterface.php index 9280d79..25073ac 100644 --- a/core/lib/Drupal/Core/Entity/EntityInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityInterface.php @@ -11,6 +11,8 @@ /** * Defines a common interface for all entity objects. + * + * @ingroup entity_api */ interface EntityInterface extends AccessibleInterface { diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index 9ed6671..73839c9 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -353,7 +353,7 @@ public function getBaseFieldDefinitions($entity_type_id) { * * @param string $entity_type_id * The entity type ID. Only entity types that implement - * \Drupal\Core\Entity\ContentEntityInterface are supported. + * \Drupal\Core\Entity\FieldableEntityInterface are supported. * * @return \Drupal\Core\Field\FieldDefinitionInterface[] * An array of field definitions, keyed by field name. @@ -366,8 +366,8 @@ protected function buildBaseFieldDefinitions($entity_type_id) { $entity_type = $this->getDefinition($entity_type_id); $class = $entity_type->getClass(); - // Fail with an exception for config entity types. - if (!$entity_type->isSubclassOf('\Drupal\Core\Entity\ContentEntityInterface')) { + // Fail with an exception for non-fieldable entity types. + if (!$entity_type->isSubclassOf('\Drupal\Core\Entity\FieldableEntityInterface')) { throw new \LogicException(String::format('Getting the base fields is not supported for entity type @type.', array('@type' => $entity_type->getLabel()))); } @@ -456,7 +456,7 @@ public function getFieldDefinitions($entity_type_id, $bundle) { * * @param string $entity_type_id * The entity type ID. Only entity types that implement - * \Drupal\Core\Entity\ContentEntityInterface are supported. + * \Drupal\Core\Entity\FieldableEntityInterface are supported. * @param string $bundle * The bundle. * @param \Drupal\Core\Field\FieldDefinitionInterface[] $base_field_definitions @@ -568,7 +568,7 @@ public function getFieldMap() { else { // Rebuild the definitions and put it into the cache. foreach ($this->getDefinitions() as $entity_type_id => $entity_type) { - if ($entity_type->isSubclassOf('\Drupal\Core\Entity\ContentEntityInterface')) { + if ($entity_type->isSubclassOf('\Drupal\Core\Entity\FieldableEntityInterface')) { foreach ($this->getBundleInfo($entity_type_id) as $bundle => $bundle_info) { foreach ($this->getFieldDefinitions($entity_type_id, $bundle) as $field_name => $field_definition) { $this->fieldMap[$entity_type_id][$field_name]['type'] = $field_definition->getType(); @@ -608,7 +608,7 @@ public function getFieldMapByFieldType($field_type) { * * @param string $entity_type_id * The entity type ID. Only entity types that implement - * \Drupal\Core\Entity\ContentEntityInterface are supported + * \Drupal\Core\Entity\FieldableEntityInterface are supported * * @return \Drupal\Core\Field\FieldStorageDefinitionInterface[] * An array of field storage definitions, keyed by field name. diff --git a/core/lib/Drupal/Core/Entity/EntityManagerInterface.php b/core/lib/Drupal/Core/Entity/EntityManagerInterface.php index daea71f..8cf95ee 100644 --- a/core/lib/Drupal/Core/Entity/EntityManagerInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityManagerInterface.php @@ -36,7 +36,7 @@ public function getEntityTypeLabels($group = FALSE); * * @param string $entity_type_id * The entity type ID. Only entity types that implement - * \Drupal\Core\Entity\ContentEntityInterface are supported. + * \Drupal\Core\Entity\FieldableEntityInterface are supported. * * @return \Drupal\Core\Field\FieldDefinitionInterface[] * The array of base field definitions for the entity type, keyed by field @@ -52,7 +52,7 @@ public function getBaseFieldDefinitions($entity_type_id); * * @param string $entity_type_id * The entity type ID. Only entity types that implement - * \Drupal\Core\Entity\ContentEntityInterface are supported. + * \Drupal\Core\Entity\FieldableEntityInterface are supported. * @param string $bundle * The bundle. * diff --git a/core/lib/Drupal/Core/Entity/EntityViewBuilder.php b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php index e24735a..4d9780b 100644 --- a/core/lib/Drupal/Core/Entity/EntityViewBuilder.php +++ b/core/lib/Drupal/Core/Entity/EntityViewBuilder.php @@ -247,7 +247,7 @@ public function buildMultiple(array $build_list) { foreach ($children as $key) { if (isset($build_list[$key][$entity_type_key])) { $entity = $build_list[$key][$entity_type_key]; - if ($entity instanceof ContentEntityInterface) { + if ($entity instanceof FieldableEntityInterface) { $view_modes[$build_list[$key]['#view_mode']][$key] = $entity; } } diff --git a/core/lib/Drupal/Core/Entity/FieldableEntityInterface.php b/core/lib/Drupal/Core/Entity/FieldableEntityInterface.php new file mode 100644 index 0000000..24a74be --- /dev/null +++ b/core/lib/Drupal/Core/Entity/FieldableEntityInterface.php @@ -0,0 +1,209 @@ +setLabel(t('Name')); + * @endcode + * + * By definition, base fields are fields that exist for every bundle. To + * provide definitions for fields that should only exist on some bundles, use + * \Drupal\Core\Entity\FieldableEntityInterface::bundleFieldDefinitions(). + * + * The definitions returned by this function can be overridden for all + * bundles by hook_entity_base_field_info_alter() or overridden on a + * per-bundle basis via 'base_field_override' configuration entities. + * + * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type + * The entity type definition. Useful when a single class is used for multiple, + * possibly dynamic entity types. + * + * @return \Drupal\Core\Field\FieldDefinitionInterface[] + * An array of base field definitions for the entity type, keyed by field + * name. + * + * @see \Drupal\Core\Entity\EntityManagerInterface::getFieldDefinitions() + * @see \Drupal\Core\Entity\FieldableEntityInterface::bundleFieldDefinitions() + */ + public static function baseFieldDefinitions(EntityTypeInterface $entity_type); + + /** + * Provides field definitions for a specific bundle. + * + * This function can return definitions both for bundle fields (fields that + * are not defined in $base_field_definitions, and therefore might not exist + * on some bundles) as well as bundle-specific overrides of base fields + * (fields that are defined in $base_field_definitions, and therefore exist + * for all bundles). However, bundle-specific base field overrides can also + * be provided by 'base_field_override' configuration entities, and that is + * the recommended approach except in cases where an entity type needs to + * provide a bundle-specific base field override that is decoupled from + * configuration. Note that for most entity types, the bundles themselves are + * derived from configuration (e.g., 'node' bundles are managed via + * 'node_type' configuration entities), so decoupling bundle-specific base + * field overrides from configuration only makes sense for entity types that + * also decouple their bundles from configuration. In cases where both this + * function returns a bundle-specific override of a base field and a + * 'base_field_override' configuration entity exists, the latter takes + * precedence. + * + * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type + * The entity type definition. Useful when a single class is used for multiple, + * possibly dynamic entity types. + * @param string $bundle + * The bundle. + * @param \Drupal\Core\Field\FieldDefinitionInterface[] $base_field_definitions + * The list of base field definitions. + * + * @return \Drupal\Core\Field\FieldDefinitionInterface[] + * An array of bundle field definitions, keyed by field name. + * + * @see \Drupal\Core\Entity\EntityManagerInterface::getFieldDefinitions() + * @see \Drupal\Core\Entity\FieldableEntityInterface::baseFieldDefinitions() + * + * @todo WARNING: This method will be changed in + * https://www.drupal.org/node/2346347. + */ + public static function bundleFieldDefinitions(EntityTypeInterface $entity_type, $bundle, array $base_field_definitions); + + /** + * Returns whether the entity has a field with the given name. + * + * @param string $field_name + * The field name. + * + * @return bool + * TRUE if the entity has a field with the given name. FALSE otherwise. + */ + public function hasField($field_name); + + /** + * Gets the definition of a contained field. + * + * @param string $name + * The name of the field. + * + * @return \Drupal\Core\Field\FieldDefinitionInterface|null + * The definition of the field or null if the field does not exist. + */ + public function getFieldDefinition($name); + + /** + * Gets an array of field definitions of all contained fields. + * + * @return \Drupal\Core\Field\FieldDefinitionInterface[] + * An array of field definitions, keyed by field name. + * + * @see \Drupal\Core\Entity\EntityManagerInterface::getFieldDefinitions() + */ + public function getFieldDefinitions(); + + /** + * Returns an array of all field values. + * + * Gets an array of plain field values, including only non-computed values. + * Note that the structure varies by entity type and bundle. + * + * @return array + * An array of field values, keyed by field name. + */ + public function toArray(); + + /** + * Gets a field item list. + * + * @param string $field_name + * The name of the field to get; e.g., 'title' or 'name'. + * + * @throws \InvalidArgumentException + * If an invalid field name is given. + * + * @return \Drupal\Core\Field\FieldItemListInterface + * The field item list, containing the field items. + */ + public function get($field_name); + + /** + * Sets a field value. + * + * @param string $field_name + * The name of the field to set; e.g., 'title' or 'name'. + * @param mixed $value + * The value to set, or NULL to unset the field. + * @param bool $notify + * (optional) Whether to notify the entity of the change. Defaults to + * TRUE. If the update stems from the entity, set it to FALSE to avoid + * being notified again. + * + * @throws \InvalidArgumentException + * If the specified field does not exist. + * + * @return $this + */ + public function set($field_name, $value, $notify = TRUE); + + /** + * Gets an array of field item lists. + * + * @param bool $include_computed + * If set to TRUE, computed fields are included. Defaults to TRUE. + * + * @return \Drupal\Core\Field\FieldItemListInterface[] + * An array of field item lists implementing, keyed by field name. + */ + public function getFields($include_computed = TRUE); + + /** + * Reacts to changes to a field. + * + * Note that this is invoked after any changes have been applied. + * + * @param string $field_name + * The name of the field which is changed. + */ + public function onChange($field_name); + + /** + * Validates the currently set values. + * + * @return \Symfony\Component\Validator\ConstraintViolationListInterface + * A list of constraint violations. If the list is empty, validation + * succeeded. + */ + public function validate(); + +} diff --git a/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php b/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php index 442162c..3d34f76 100644 --- a/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php +++ b/core/lib/Drupal/Core/Entity/KeyValueStore/KeyValueEntityStorage.php @@ -10,7 +10,7 @@ use Drupal\Component\Utility\String; use Drupal\Component\Uuid\UuidInterface; use Drupal\Core\Config\Entity\Exception\ConfigEntityIdLengthException; -use Drupal\Core\Entity\ContentEntityInterface; +use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityMalformedException; use Drupal\Core\Entity\EntityStorageBase; @@ -98,10 +98,10 @@ public function doCreate(array $values = array()) { $entity = new $this->entityClass($values, $this->entityTypeId); // @todo This is handled by ContentEntityStorageBase, which assumes - // ContentEntityInterface. The current approach in + // FieldableEntityInterface. The current approach in // https://drupal.org/node/1867228 improves this but does not solve it // completely. - if ($entity instanceof ContentEntityInterface) { + if ($entity instanceof FieldableEntityInterface) { foreach ($entity as $name => $field) { if (isset($values[$name])) { $entity->$name = $values[$name]; diff --git a/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php b/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php index 7e413b0..0fb2330 100644 --- a/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php +++ b/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityAdapter.php @@ -8,7 +8,7 @@ namespace Drupal\Core\Entity\Plugin\DataType; use Drupal\Component\Utility\String; -use Drupal\Core\Entity\ContentEntityInterface; +use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\TypedData\EntityDataDefinition; use Drupal\Core\TypedData\ComplexDataInterface; @@ -83,7 +83,7 @@ public function get($property_name) { if (!isset($this->entity)) { throw new MissingDataException(String::format('Unable to get property @name as no entity has been provided.', array('@name' => $property_name))); } - if (!$this->entity instanceof ContentEntityInterface) { + if (!$this->entity instanceof FieldableEntityInterface) { // @todo: Add support for config entities in // https://www.drupal.org/node/1818574. throw new \InvalidArgumentException(String::format('Unable to get unknown property @name.', array('@name' => $property_name))); @@ -99,7 +99,7 @@ public function set($property_name, $value, $notify = TRUE) { if (!isset($this->entity)) { throw new MissingDataException(String::format('Unable to set property @name as no entity has been provided.', array('@name' => $property_name))); } - if (!$this->entity instanceof ContentEntityInterface) { + if (!$this->entity instanceof FieldableEntityInterface) { // @todo: Add support for config entities in // https://www.drupal.org/node/1818574. throw new \InvalidArgumentException(String::format('Unable to set unknown property @name.', array('@name' => $property_name))); @@ -115,7 +115,7 @@ public function getProperties($include_computed = FALSE) { if (!isset($this->entity)) { throw new MissingDataException(String::format('Unable to get properties as no entity has been provided.')); } - if (!$this->entity instanceof ContentEntityInterface) { + if (!$this->entity instanceof FieldableEntityInterface) { // @todo: Add support for config entities in // https://www.drupal.org/node/1818574. return array(); @@ -144,7 +144,7 @@ public function isEmpty() { * {@inheritdoc} */ public function onChange($property_name) { - if (isset($this->entity) && $this->entity instanceof ContentEntityInterface) { + if (isset($this->entity) && $this->entity instanceof FieldableEntityInterface) { // Let the entity know of any changes. $this->entity->onChange($property_name); } diff --git a/core/lib/Drupal/Core/Field/BaseFieldDefinition.php b/core/lib/Drupal/Core/Field/BaseFieldDefinition.php index 7eb0d8a..a51333f 100644 --- a/core/lib/Drupal/Core/Field/BaseFieldDefinition.php +++ b/core/lib/Drupal/Core/Field/BaseFieldDefinition.php @@ -7,7 +7,7 @@ namespace Drupal\Core\Field; -use Drupal\Core\Entity\ContentEntityInterface; +use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Field\Entity\BaseFieldOverride; use Drupal\Core\Field\TypedData\FieldItemDataDefinition; use Drupal\Core\TypedData\ListDataDefinition; @@ -379,7 +379,7 @@ public function isDisplayConfigurable($display_context) { /** * {@inheritdoc} */ - public function getDefaultValue(ContentEntityInterface $entity) { + public function getDefaultValue(FieldableEntityInterface $entity) { // Allow custom default values function. if (!empty($this->definition['default_value_callback'])) { $value = call_user_func($this->definition['default_value_callback'], $entity, $this); @@ -401,7 +401,7 @@ public function getDefaultValue(ContentEntityInterface $entity) { * The callback to invoke for getting the default value (pass NULL to unset * a previously set callback). The callback will be invoked with the * following arguments: - * - \Drupal\Core\Entity\ContentEntityInterface $entity + * - \Drupal\Core\Entity\FieldableEntityInterface $entity * The entity being created. * - \Drupal\Core\Field\FieldDefinitionInterface $definition * The field definition. @@ -435,7 +435,7 @@ public function setDefaultValue($value) { /** * {@inheritdoc} */ - public function getOptionsProvider($property_name, ContentEntityInterface $entity) { + public function getOptionsProvider($property_name, FieldableEntityInterface $entity) { // If the field item class implements the interface, proxy it through. $item = $entity->get($this->getName())->first(); if ($item instanceof OptionsProviderInterface) { diff --git a/core/lib/Drupal/Core/Field/EntityReferenceFieldItemList.php b/core/lib/Drupal/Core/Field/EntityReferenceFieldItemList.php index 477d2bc..a47e23b 100644 --- a/core/lib/Drupal/Core/Field/EntityReferenceFieldItemList.php +++ b/core/lib/Drupal/Core/Field/EntityReferenceFieldItemList.php @@ -7,7 +7,7 @@ namespace Drupal\Core\Field; -use Drupal\Core\Entity\ContentEntityInterface; +use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Form\FormStateInterface; /** @@ -52,7 +52,7 @@ public function referencedEntities() { /** * {@inheritdoc} */ - public static function processDefaultValue($default_value, ContentEntityInterface $entity, FieldDefinitionInterface $definition) { + public static function processDefaultValue($default_value, FieldableEntityInterface $entity, FieldDefinitionInterface $definition) { $default_value = parent::processDefaultValue($default_value, $entity, $definition); if ($default_value) { diff --git a/core/lib/Drupal/Core/Field/FieldConfigBase.php b/core/lib/Drupal/Core/Field/FieldConfigBase.php index 69473f4..cbf9efc 100644 --- a/core/lib/Drupal/Core/Field/FieldConfigBase.php +++ b/core/lib/Drupal/Core/Field/FieldConfigBase.php @@ -9,8 +9,8 @@ use Drupal\Core\Config\Entity\ConfigEntityBase; use Drupal\Core\Config\Entity\ThirdPartySettingsTrait; -use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\EntityStorageInterface; +use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Field\TypedData\FieldItemDataDefinition; /** @@ -153,7 +153,7 @@ * The name of a callback function that returns default values. * * The function will be called with the following arguments: - * - \Drupal\Core\Entity\ContentEntityInterface $entity + * - \Drupal\Core\Entity\FieldableEntityInterface $entity * The entity being created. * - \Drupal\Core\Field\FieldDefinitionInterface $definition * The field definition. @@ -332,7 +332,7 @@ public function isRequired() { /** * {@inheritdoc} */ - public function getDefaultValue(ContentEntityInterface $entity) { + public function getDefaultValue(FieldableEntityInterface $entity) { // Allow custom default values function. if ($function = $this->default_value_function) { $value = call_user_func($function, $entity, $this); diff --git a/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php b/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php index 02843e6..9d6acd1 100644 --- a/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php +++ b/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php @@ -7,7 +7,7 @@ namespace Drupal\Core\Field; -use Drupal\Core\Entity\ContentEntityInterface; +use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\TypedData\ListDataDefinitionInterface; /** @@ -162,7 +162,7 @@ public function isRequired(); /** * Returns the default value for the field in a newly created entity. * - * @param \Drupal\Core\Entity\ContentEntityInterface $entity + * @param \Drupal\Core\Entity\FieldableEntityInterface $entity * The entity for which the default value is generated. * * @return mixed @@ -175,7 +175,7 @@ public function isRequired(); * array. * - NULL or array() for no default value. */ - public function getDefaultValue(ContentEntityInterface $entity); + public function getDefaultValue(FieldableEntityInterface $entity); /** * Returns whether the field is translatable. diff --git a/core/lib/Drupal/Core/Field/FieldItemList.php b/core/lib/Drupal/Core/Field/FieldItemList.php index f6ae7d5..0afb5bb 100644 --- a/core/lib/Drupal/Core/Field/FieldItemList.php +++ b/core/lib/Drupal/Core/Field/FieldItemList.php @@ -7,10 +7,10 @@ namespace Drupal\Core\Field; +use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Access\AccessResult; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; -use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\TypedData\DataDefinitionInterface; use Drupal\Core\TypedData\Plugin\DataType\ItemList; @@ -357,7 +357,7 @@ public function defaultValuesFormSubmit(array $element, array &$form, FormStateI /** * {@inheritdoc} */ - public static function processDefaultValue($default_value, ContentEntityInterface $entity, FieldDefinitionInterface $definition) { + public static function processDefaultValue($default_value, FieldableEntityInterface $entity, FieldDefinitionInterface $definition) { return $default_value; } diff --git a/core/lib/Drupal/Core/Field/FieldItemListInterface.php b/core/lib/Drupal/Core/Field/FieldItemListInterface.php index 97e0f8c..7ec91c9 100644 --- a/core/lib/Drupal/Core/Field/FieldItemListInterface.php +++ b/core/lib/Drupal/Core/Field/FieldItemListInterface.php @@ -7,7 +7,7 @@ namespace Drupal\Core\Field; -use Drupal\Core\Entity\ContentEntityInterface; +use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Access\AccessibleInterface; @@ -247,7 +247,7 @@ public function defaultValuesFormSubmit(array $element, array &$form, FormStateI * * @param mixed * The default value as defined for the field. - * @param \Drupal\Core\Entity\ContentEntityInterface $entity + * @param \Drupal\Core\Entity\FieldableEntityInterface $entity * The entity for which the default value is generated. * @param \Drupal\Core\Field\FieldDefinitionInterface $definition * The definition of the field. @@ -262,6 +262,6 @@ public function defaultValuesFormSubmit(array $element, array &$form, FormStateI * array. * - NULL or array() for no default value. */ - public static function processDefaultValue($default_value, ContentEntityInterface $entity, FieldDefinitionInterface $definition); + public static function processDefaultValue($default_value, FieldableEntityInterface $entity, FieldDefinitionInterface $definition); } diff --git a/core/lib/Drupal/Core/Field/FieldStorageDefinitionInterface.php b/core/lib/Drupal/Core/Field/FieldStorageDefinitionInterface.php index 7df3c83..578a6da 100644 --- a/core/lib/Drupal/Core/Field/FieldStorageDefinitionInterface.php +++ b/core/lib/Drupal/Core/Field/FieldStorageDefinitionInterface.php @@ -7,7 +7,7 @@ namespace Drupal\Core\Field; -use Drupal\Core\Entity\ContentEntityInterface; +use Drupal\Core\Entity\FieldableEntityInterface; /** * Defines an interface for entity field storage definitions. @@ -137,13 +137,13 @@ public function getDescription(); * * @param string $property_name * The name of the property to get options for; e.g., 'value'. - * @param \Drupal\Core\Entity\ContentEntityInterface $entity + * @param \Drupal\Core\Entity\FieldableEntityInterface $entity * The entity for which the options should be provided. * * @return \Drupal\Core\TypedData\OptionsProviderInterface|null * An options provider, or NULL if no options are defined. */ - public function getOptionsProvider($property_name, ContentEntityInterface $entity); + public function getOptionsProvider($property_name, FieldableEntityInterface $entity); /** * Returns whether the field can contain multiple items. diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php index 5073a73..4075d52 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php @@ -61,7 +61,7 @@ public static function propertyDefinitions(FieldStorageDefinitionInterface $fiel $settings = $field_definition->getSettings(); $target_type_info = \Drupal::entityManager()->getDefinition($settings['target_type']); - if ($target_type_info->isSubclassOf('\Drupal\Core\Entity\ContentEntityInterface')) { + if ($target_type_info->isSubclassOf('\Drupal\Core\Entity\FieldableEntityInterface')) { // @todo: Lookup the entity type's ID data type and use it here. // https://drupal.org/node/2107249 $target_id_definition = DataDefinition::create('integer') @@ -102,7 +102,7 @@ public static function schema(FieldStorageDefinitionInterface $field_definition) $target_type = $field_definition->getSetting('target_type'); $target_type_info = \Drupal::entityManager()->getDefinition($target_type); - if ($target_type_info->isSubclassOf('\Drupal\Core\Entity\ContentEntityInterface')) { + if ($target_type_info->isSubclassOf('\Drupal\Core\Entity\FieldableEntityInterface')) { $columns = array( 'target_id' => array( 'description' => 'The ID of the target entity.', diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 4231ee5..05b6e8e 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -14,9 +14,9 @@ use Drupal\comment\Entity\Comment; use Drupal\comment\CommentManagerInterface; use Drupal\comment\Entity\CommentType; +use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; use Drupal\Component\Utility\String; -use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteMatchInterface; @@ -366,7 +366,7 @@ function comment_form_field_ui_field_storage_edit_form_alter(&$form, FormStateIn */ function comment_entity_storage_load($entities, $entity_type) { // Comments can only be attached to content entities, so skip others. - if (!\Drupal::entityManager()->getDefinition($entity_type)->isSubclassOf('Drupal\Core\Entity\ContentEntityInterface')) { + if (!\Drupal::entityManager()->getDefinition($entity_type)->isSubclassOf('Drupal\Core\Entity\FieldableEntityInterface')) { return; } if (!\Drupal::service('comment.manager')->getFields($entity_type)) { @@ -412,7 +412,7 @@ function comment_entity_predelete(EntityInterface $entity) { // mismatched types. So, we need to verify that the ID is numeric (even for an // entity type that has an integer ID, $entity->id() might be a string // containing a number), and then cast it to an integer when querying. - if ($entity instanceof ContentEntityInterface && is_numeric($entity->id())) { + if ($entity instanceof FieldableEntityInterface && is_numeric($entity->id())) { $entity_query = \Drupal::entityQuery('comment'); $entity_query->condition('entity_id', (int) $entity->id()); $entity_query->condition('entity_type', $entity->getEntityTypeId()); diff --git a/core/modules/comment/comment.tokens.inc b/core/modules/comment/comment.tokens.inc index 227c724..789ede3 100644 --- a/core/modules/comment/comment.tokens.inc +++ b/core/modules/comment/comment.tokens.inc @@ -247,7 +247,7 @@ 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 */ + /** @var $entity \Drupal\Core\Entity\FieldableEntityInterface */ $entity = !empty($data['entity']) ? $data['entity'] : $data['node']; foreach ($tokens as $name => $original) { diff --git a/core/modules/comment/src/CommentLinkBuilder.php b/core/modules/comment/src/CommentLinkBuilder.php index b1864da..9726712 100644 --- a/core/modules/comment/src/CommentLinkBuilder.php +++ b/core/modules/comment/src/CommentLinkBuilder.php @@ -8,7 +8,7 @@ namespace Drupal\comment; use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; -use Drupal\Core\Entity\ContentEntityInterface; +use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; @@ -66,7 +66,7 @@ public function __construct(AccountInterface $current_user, CommentManagerInterf /** * {@inheritdoc} */ - public function buildCommentedEntityLinks(ContentEntityInterface $entity, array &$context) { + public function buildCommentedEntityLinks(FieldableEntityInterface $entity, array &$context) { $entity_links = array(); $view_mode = $context['view_mode']; if ($view_mode == 'search_index' || $view_mode == 'search_result' || $view_mode == 'print') { diff --git a/core/modules/comment/src/CommentLinkBuilderInterface.php b/core/modules/comment/src/CommentLinkBuilderInterface.php index 995efcf..f9de037 100644 --- a/core/modules/comment/src/CommentLinkBuilderInterface.php +++ b/core/modules/comment/src/CommentLinkBuilderInterface.php @@ -7,7 +7,7 @@ namespace Drupal\comment; -use Drupal\Core\Entity\ContentEntityInterface; +use Drupal\Core\Entity\FieldableEntityInterface; /** * Defines an interface for building comment links on a commented entity. @@ -19,7 +19,7 @@ /** * Builds links for the given entity. * - * @param \Drupal\Core\Entity\ContentEntityInterface $entity + * @param \Drupal\Core\Entity\FieldableEntityInterface $entity * Entity for which the links are being built. * @param array $context * Array of context passed from the entity view builder. @@ -27,6 +27,6 @@ * @return array * Array of entity links. */ - public function buildCommentedEntityLinks(ContentEntityInterface $entity, array &$context); + public function buildCommentedEntityLinks(FieldableEntityInterface $entity, array &$context); } diff --git a/core/modules/comment/src/CommentManager.php b/core/modules/comment/src/CommentManager.php index f331f13..0094a01 100644 --- a/core/modules/comment/src/CommentManager.php +++ b/core/modules/comment/src/CommentManager.php @@ -110,7 +110,7 @@ public function __construct(EntityManagerInterface $entity_manager, QueryFactory */ public function getFields($entity_type_id) { $entity_type = $this->entityManager->getDefinition($entity_type_id); - if (!$entity_type->isSubclassOf('\Drupal\Core\Entity\ContentEntityInterface')) { + if (!$entity_type->isSubclassOf('\Drupal\Core\Entity\FieldableEntityInterface')) { return array(); } diff --git a/core/modules/comment/src/CommentStatistics.php b/core/modules/comment/src/CommentStatistics.php index 0f2e936..c275f42 100644 --- a/core/modules/comment/src/CommentStatistics.php +++ b/core/modules/comment/src/CommentStatistics.php @@ -8,7 +8,7 @@ use Drupal\Core\Database\Connection; -use Drupal\Core\Entity\ContentEntityInterface; +use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Entity\EntityChangedInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityManagerInterface; @@ -96,7 +96,7 @@ public function delete(EntityInterface $entity) { /** * {@inheritdoc} */ - public function create(ContentEntityInterface $entity, $fields) { + public function create(FieldableEntityInterface $entity, $fields) { $query = $this->database->insert('comment_entity_statistics') ->fields(array( 'entity_id', diff --git a/core/modules/comment/src/CommentStatisticsInterface.php b/core/modules/comment/src/CommentStatisticsInterface.php index 5e54a16..f73dccd 100644 --- a/core/modules/comment/src/CommentStatisticsInterface.php +++ b/core/modules/comment/src/CommentStatisticsInterface.php @@ -6,7 +6,7 @@ namespace Drupal\comment; -use Drupal\Core\Entity\ContentEntityInterface; +use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Entity\EntityInterface; /** @@ -75,11 +75,11 @@ public function getMaximumCount($entity_type); /** * Insert an empty record for the given entity. * - * @param \Drupal\Core\Entity\ContentEntityInterface $entity + * @param \Drupal\Core\Entity\FieldableEntityInterface $entity * The created entity for which a statistics record is to be initialized. * @param array $fields * Array of comment field definitions for the given entity. */ - public function create(ContentEntityInterface $entity, $fields); + public function create(FieldableEntityInterface $entity, $fields); } diff --git a/core/modules/comment/src/CommentStorage.php b/core/modules/comment/src/CommentStorage.php index 28422e2..2cbaed7 100644 --- a/core/modules/comment/src/CommentStorage.php +++ b/core/modules/comment/src/CommentStorage.php @@ -9,10 +9,10 @@ use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Database\Connection; -use Drupal\Core\Entity\ContentEntityInterface; -use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityTypeInterface; +use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Entity\Sql\SqlContentEntityStorage; use Drupal\Core\Session\AccountInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -131,7 +131,7 @@ public function getDisplayOrdinal(CommentInterface $comment, $comment_mode, $div /** * {@inheritdoc} */ - public function getNewCommentPageNumber($total_comments, $new_comments, ContentEntityInterface $entity, $field_name = 'comment') { + public function getNewCommentPageNumber($total_comments, $new_comments, FieldableEntityInterface $entity, $field_name = 'comment') { $field = $entity->getFieldDefinition($field_name); $comments_per_page = $field->getSetting('per_page'); diff --git a/core/modules/comment/src/CommentStorageInterface.php b/core/modules/comment/src/CommentStorageInterface.php index d3f15a9..5be4776 100644 --- a/core/modules/comment/src/CommentStorageInterface.php +++ b/core/modules/comment/src/CommentStorageInterface.php @@ -7,9 +7,9 @@ namespace Drupal\comment; -use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityStorageInterface; +use Drupal\Core\Entity\FieldableEntityInterface; /** * Defines an interface for comment entity storage classes. @@ -46,7 +46,7 @@ public function getMaxThreadPerThread(CommentInterface $comment); * The total number of comments that the entity has. * @param int $new_comments * The number of new comments that the entity has. - * @param \Drupal\Core\Entity\ContentEntityInterface $entity + * @param \Drupal\Core\Entity\FieldableEntityInterface $entity * The entity to which the comments belong. * @param string $field_name * The field name on the entity to which comments are attached. @@ -54,7 +54,7 @@ public function getMaxThreadPerThread(CommentInterface $comment); * @return array|null * The page number where first new comment appears. (First page returns 0.) */ - public function getNewCommentPageNumber($total_comments, $new_comments, ContentEntityInterface $entity, $field_name = 'comment'); + public function getNewCommentPageNumber($total_comments, $new_comments, FieldableEntityInterface $entity, $field_name = 'comment'); /** * Gets the display ordinal or page number for a comment. diff --git a/core/modules/comment/tests/src/Unit/CommentManagerTest.php b/core/modules/comment/tests/src/Unit/CommentManagerTest.php index 0cb5d93..e2a00c7 100644 --- a/core/modules/comment/tests/src/Unit/CommentManagerTest.php +++ b/core/modules/comment/tests/src/Unit/CommentManagerTest.php @@ -29,7 +29,7 @@ public function testGetFields() { ->will($this->returnValue('Node')); $entity_type->expects($this->any()) ->method('isSubclassOf') - ->with('\Drupal\Core\Entity\ContentEntityInterface') + ->with('\Drupal\Core\Entity\FieldableEntityInterface') ->will($this->returnValue(TRUE)); $entity_manager = $this->getMock('Drupal\Core\Entity\EntityManagerInterface'); diff --git a/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php b/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php index aa03882..cbc483b 100644 --- a/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php +++ b/core/modules/datetime/src/Plugin/Field/FieldType/DateTimeFieldItemList.php @@ -8,7 +8,7 @@ namespace Drupal\datetime\Plugin\Field\FieldType; use Drupal\Core\Datetime\DrupalDateTime; -use Drupal\Core\Entity\ContentEntityInterface; +use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldItemList; use Drupal\Core\Form\FormStateInterface; @@ -93,7 +93,7 @@ public function defaultValuesFormSubmit(array $element, array &$form, FormStateI /** * {@inheritdoc} */ - public static function processDefaultValue($default_value, ContentEntityInterface $entity, FieldDefinitionInterface $definition) { + public static function processDefaultValue($default_value, FieldableEntityInterface $entity, FieldDefinitionInterface $definition) { $default_value = parent::processDefaultValue($default_value, $entity, $definition); if (isset($default_value[0]['default_date_type'])) { diff --git a/core/modules/editor/editor.module b/core/modules/editor/editor.module index fec8a70..cc1a238 100644 --- a/core/modules/editor/editor.module +++ b/core/modules/editor/editor.module @@ -6,7 +6,7 @@ */ use Drupal\Component\Utility\Html; -use Drupal\Core\Entity\ContentEntityInterface; +use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Render\Element; @@ -320,7 +320,7 @@ function editor_filter_xss($html, FilterFormatInterface $format, FilterFormatInt */ function editor_entity_insert(EntityInterface $entity) { // Only act on content entities. - if (!($entity instanceof ContentEntityInterface)) { + if (!($entity instanceof FieldableEntityInterface)) { return; } $referenced_files_by_field = _editor_get_file_uuids_by_field($entity); @@ -334,7 +334,7 @@ function editor_entity_insert(EntityInterface $entity) { */ function editor_entity_update(EntityInterface $entity) { // Only act on content entities. - if (!($entity instanceof ContentEntityInterface)) { + if (!($entity instanceof FieldableEntityInterface)) { return; } @@ -373,7 +373,7 @@ function editor_entity_update(EntityInterface $entity) { */ function editor_entity_delete(EntityInterface $entity) { // Only act on content entities. - if (!($entity instanceof ContentEntityInterface)) { + if (!($entity instanceof FieldableEntityInterface)) { return; } $referenced_files_by_field = _editor_get_file_uuids_by_field($entity); @@ -387,7 +387,7 @@ function editor_entity_delete(EntityInterface $entity) { */ function editor_entity_revision_delete(EntityInterface $entity) { // Only act on content entities. - if (!($entity instanceof ContentEntityInterface)) { + if (!($entity instanceof FieldableEntityInterface)) { return; } $referenced_files_by_field = _editor_get_file_uuids_by_field($entity); @@ -463,13 +463,13 @@ function _editor_get_file_uuids_by_field(EntityInterface $entity) { /** * Determines the formatted text fields on an entity. * - * @param ContentEntityInterface $entity + * @param \Drupal\Core\Entity\FieldableEntityInterface $entity * An entity whose fields to analyze. * * @return array * The names of the fields on this entity that support formatted text. */ -function _editor_get_formatted_text_fields(ContentEntityInterface $entity) { +function _editor_get_formatted_text_fields(FieldableEntityInterface $entity) { $field_definitions = $entity->getFieldDefinitions(); if (empty($field_definitions)) { return array(); diff --git a/core/modules/entity_reference/src/ConfigurableEntityReferenceItem.php b/core/modules/entity_reference/src/ConfigurableEntityReferenceItem.php index 98ddf9b..c0301e1 100644 --- a/core/modules/entity_reference/src/ConfigurableEntityReferenceItem.php +++ b/core/modules/entity_reference/src/ConfigurableEntityReferenceItem.php @@ -145,7 +145,7 @@ public static function schema(FieldStorageDefinitionInterface $field_definition) $target_type = $field_definition->getSetting('target_type'); $target_type_info = \Drupal::entityManager()->getDefinition($target_type); - if ($target_type_info->isSubclassOf('\Drupal\Core\Entity\ContentEntityInterface') && $field_definition instanceof FieldStorageConfigInterface) { + if ($target_type_info->isSubclassOf('\Drupal\Core\Entity\FieldableEntityInterface') && $field_definition instanceof FieldStorageConfigInterface) { $schema['columns']['revision_id'] = array( 'description' => 'The revision ID of the target entity.', 'type' => 'int', diff --git a/core/modules/entity_reference/src/Plugin/entity_reference/selection/SelectionBase.php b/core/modules/entity_reference/src/Plugin/entity_reference/selection/SelectionBase.php index 632cda4..c2b877b 100644 --- a/core/modules/entity_reference/src/Plugin/entity_reference/selection/SelectionBase.php +++ b/core/modules/entity_reference/src/Plugin/entity_reference/selection/SelectionBase.php @@ -111,7 +111,7 @@ public static function settingsForm(FieldDefinitionInterface $field_definition) ); } - if ($entity_type->isSubclassOf('\Drupal\Core\Entity\ContentEntityInterface')) { + if ($entity_type->isSubclassOf('\Drupal\Core\Entity\FieldableEntityInterface')) { $fields = array(); foreach (array_keys($bundles) as $bundle) { $bundle_fields = array_filter($entity_manager->getFieldDefinitions($entity_type_id, $bundle), function ($field_definition) { diff --git a/core/modules/field/src/Entity/FieldStorageConfig.php b/core/modules/field/src/Entity/FieldStorageConfig.php index c6e9bd1..29794c7 100644 --- a/core/modules/field/src/Entity/FieldStorageConfig.php +++ b/core/modules/field/src/Entity/FieldStorageConfig.php @@ -10,8 +10,8 @@ use Drupal\Component\Utility\String; use Drupal\Component\Utility\Unicode; use Drupal\Core\Config\Entity\ConfigEntityBase; -use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\EntityStorageInterface; +use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Field\FieldException; use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\TypedData\OptionsProviderInterface; @@ -585,7 +585,7 @@ public function isRequired() { /** * {@inheritdoc} */ - public function getOptionsProvider($property_name, ContentEntityInterface $entity) { + public function getOptionsProvider($property_name, FieldableEntityInterface $entity) { // If the field item class implements the interface, proxy it through. $item = $entity->get($this->getName())->first(); if ($item instanceof OptionsProviderInterface) { diff --git a/core/modules/field/src/Tests/String/StringFormatterTest.php b/core/modules/field/src/Tests/String/StringFormatterTest.php index 8ee3a17..d47149a 100644 --- a/core/modules/field/src/Tests/String/StringFormatterTest.php +++ b/core/modules/field/src/Tests/String/StringFormatterTest.php @@ -9,8 +9,8 @@ use Drupal\Component\Utility\String; use Drupal\Component\Utility\Unicode; -use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\Display\EntityViewDisplayInterface; +use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\entity_test\Entity\EntityTest; use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldStorageConfig; @@ -89,7 +89,7 @@ protected function setUp() { /** * Renders fields of a given entity with a given display. * - * @param \Drupal\Core\Entity\ContentEntityInterface $entity + * @param \Drupal\Core\Entity\FieldableEntityInterface $entity * The entity object with attached fields to render. * @param \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display * The display to render the fields in. @@ -97,7 +97,7 @@ protected function setUp() { * @return string * The rendered entity fields. */ - protected function renderEntityFields(ContentEntityInterface $entity, EntityViewDisplayInterface $display) { + protected function renderEntityFields(FieldableEntityInterface $entity, EntityViewDisplayInterface $display) { $content = $display->build($entity); $content = $this->render($content); return $content; diff --git a/core/modules/field/tests/modules/field_test/field_test.field.inc b/core/modules/field/tests/modules/field_test/field_test.field.inc index b1a5589..48dd312 100644 --- a/core/modules/field/tests/modules/field_test/field_test.field.inc +++ b/core/modules/field/tests/modules/field_test/field_test.field.inc @@ -5,8 +5,8 @@ * Defines a field type and its formatters and widgets. */ +use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Access\AccessResult; -use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldItemListInterface; @@ -32,7 +32,7 @@ function field_test_field_storage_config_update_forbid(FieldStorageConfigInterfa /** * Sample 'default value' callback. */ -function field_test_default_value(ContentEntityInterface $entity, FieldDefinitionInterface $definition) { +function field_test_default_value(FieldableEntityInterface $entity, FieldDefinitionInterface $definition) { return array(array('value' => 99)); } diff --git a/core/modules/hal/src/Normalizer/EntityReferenceItemNormalizer.php b/core/modules/hal/src/Normalizer/EntityReferenceItemNormalizer.php index d5ba85a..44ba171 100644 --- a/core/modules/hal/src/Normalizer/EntityReferenceItemNormalizer.php +++ b/core/modules/hal/src/Normalizer/EntityReferenceItemNormalizer.php @@ -7,7 +7,7 @@ namespace Drupal\hal\Normalizer; -use Drupal\Core\Entity\ContentEntityInterface; +use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\rest\LinkManager\LinkManagerInterface; use Drupal\serialization\EntityResolver\EntityResolverInterface; use Drupal\serialization\EntityResolver\UuidReferenceInterface; @@ -60,7 +60,7 @@ public function normalize($field_item, $format = NULL, array $context = array()) // If this is not a content entity, let the parent implementation handle it, // only content entities are supported as embedded resources. - if (!($target_entity instanceof ContentEntityInterface)) { + if (!($target_entity instanceof FieldableEntityInterface)) { return parent::normalize($field_item, $format, $context); } diff --git a/core/modules/path/path.module b/core/modules/path/path.module index ad99d4a..af72f24 100644 --- a/core/modules/path/path.module +++ b/core/modules/path/path.module @@ -6,8 +6,7 @@ */ use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Entity\ContentEntityInterface; +use Drupal\Core\Field\FieldDefinition; use Drupal\Core\Field\BaseFieldDefinition; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteMatchInterface; diff --git a/core/modules/quickedit/src/Form/QuickEditFieldForm.php b/core/modules/quickedit/src/Form/QuickEditFieldForm.php index f67baa2..a1516fe 100644 --- a/core/modules/quickedit/src/Form/QuickEditFieldForm.php +++ b/core/modules/quickedit/src/Form/QuickEditFieldForm.php @@ -7,7 +7,7 @@ namespace Drupal\quickedit\Form; -use Drupal\Core\Entity\ContentEntityInterface; +use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityChangedInterface; @@ -238,13 +238,13 @@ protected function simplify(array &$form, FormStateInterface $form_state) { /** * Finds the field name for the field carrying the changed timestamp, if any. * - * @param \Drupal\Core\Entity\ContentEntityInterface $entity + * @param \Drupal\Core\Entity\FieldableEntityInterface $entity * The entity. * * @return string|null * The name of the field found or NULL if not found. */ - protected function getChangedFieldName(ContentEntityInterface $entity) { + protected function getChangedFieldName(FieldableEntityInterface $entity) { foreach ($entity->getFieldDefinitions() as $field) { if ($field->getType() == 'changed') { return $field->getName(); diff --git a/core/modules/system/entity.api.php b/core/modules/system/entity.api.php index 8979ce8..b9f60fe 100644 --- a/core/modules/system/entity.api.php +++ b/core/modules/system/entity.api.php @@ -5,7 +5,7 @@ * Hooks provided the Entity module. */ -use Drupal\Component\Utility\String; +use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Access\AccessResult; use Drupal\Core\Entity\ContentEntityInterface; use Drupal\Core\Entity\DynamicallyFieldableEntityStorageInterface; @@ -786,7 +786,7 @@ function hook_entity_bundle_delete($entity_type_id, $bundle) { * @see hook_ENTITY_TYPE_create() */ function hook_entity_create(\Drupal\Core\Entity\EntityInterface $entity) { - if ($entity instanceof ContentEntityInterface && !$entity->foo->value) { + if ($entity instanceof FieldableEntityInterface && !$entity->foo->value) { $entity->foo->value = 'some_initial_value'; } } diff --git a/core/modules/system/src/Tests/Entity/FieldTranslationSqlStorageTest.php b/core/modules/system/src/Tests/Entity/FieldTranslationSqlStorageTest.php index c2a6a65..4222b8f 100644 --- a/core/modules/system/src/Tests/Entity/FieldTranslationSqlStorageTest.php +++ b/core/modules/system/src/Tests/Entity/FieldTranslationSqlStorageTest.php @@ -7,7 +7,7 @@ namespace Drupal\system\Tests\Entity; -use Drupal\Core\Entity\ContentEntityInterface; +use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Language\LanguageInterface; use Drupal\field\Entity\FieldStorageConfig; @@ -71,12 +71,12 @@ public function testFieldSqlStorage() { /** * Checks whether field languages are correctly stored for the given entity. * - * @param \Drupal\Core\Entity\ContentEntityInterface $entity + * @param \Drupal\Core\Entity\FieldableEntityInterface $entity * The entity fields are attached to. * @param string $message * (optional) A message to display with the assertion. */ - protected function assertFieldStorageLangcode(ContentEntityInterface $entity, $message = '') { + protected function assertFieldStorageLangcode(FieldableEntityInterface $entity, $message = '') { $status = TRUE; $entity_type = $entity->getEntityTypeId(); $id = $entity->id(); diff --git a/core/modules/system/tests/modules/entity_test/entity_test.module b/core/modules/system/tests/modules/entity_test/entity_test.module index 06ec1dc..e17eb01 100644 --- a/core/modules/system/tests/modules/entity_test/entity_test.module +++ b/core/modules/system/tests/modules/entity_test/entity_test.module @@ -7,7 +7,7 @@ use Drupal\Core\Access\AccessResult; use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Entity\ContentEntityInterface; +use Drupal\Core\Entity\FieldableEntityInterface; use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Field\FieldDefinitionInterface; use Drupal\Core\Field\FieldItemListInterface; @@ -422,7 +422,7 @@ function entity_test_entity_test_mul_translation_delete(EntityInterface $transla /** * Field default value callback. * - * @param \Drupal\Core\Entity\ContentEntityInterface $entity + * @param \Drupal\Core\Entity\FieldableEntityInterface $entity * The entity being created. * @param \Drupal\Core\Field\FieldDefinitionInterface $definition * The field definition. @@ -433,7 +433,7 @@ function entity_test_entity_test_mul_translation_delete(EntityInterface $transla * * @see \Drupal\field\Entity\FieldConfig::$default_value */ -function entity_test_field_default_value(ContentEntityInterface $entity, FieldDefinitionInterface $definition) { +function entity_test_field_default_value(FieldableEntityInterface $entity, FieldDefinitionInterface $definition) { return array(array('value' => $definition->getName() . '_' . $entity->language()->id)); } diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php index fa3678c..99c783d 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php @@ -716,7 +716,7 @@ protected function setUpEntityWithFieldDefinition($custom_invoke_all = FALSE, $f ->will($this->returnValue(array())); $entity_type->expects($this->any()) ->method('isSubclassOf') - ->with($this->equalTo('\Drupal\Core\Entity\ContentEntityInterface')) + ->with($this->equalTo('\Drupal\Core\Entity\FieldableEntityInterface')) ->will($this->returnValue(TRUE)); $field_definition = $this->getMockBuilder('Drupal\Core\Field\BaseFieldDefinition') ->disableOriginalConstructor() @@ -1039,7 +1039,7 @@ public function testGetFieldMap() { ->will($this->returnValue('test_entity_type')); $entity_type->expects($this->any()) ->method('isSubclassOf') - ->with('\Drupal\Core\Entity\ContentEntityInterface') + ->with('\Drupal\Core\Entity\FieldableEntityInterface') ->will($this->returnValue(TRUE)); // Set up the module handler to return two bundles for the fieldable entity @@ -1098,7 +1098,7 @@ public function testGetFieldMap() { $non_content_entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface'); $entity_type->expects($this->any()) ->method('isSubclassOf') - ->with('\Drupal\Core\Entity\ContentEntityInterface') + ->with('\Drupal\Core\Entity\FieldableEntityInterface') ->will($this->returnValue(FALSE)); // Mock the base field definition override. @@ -1182,7 +1182,7 @@ public function testGetFieldMapByFieldType() { ->will($this->returnValue('test_entity_type')); $entity_type->expects($this->any()) ->method('isSubclassOf') - ->with('\Drupal\Core\Entity\ContentEntityInterface') + ->with('\Drupal\Core\Entity\FieldableEntityInterface') ->will($this->returnValue(TRUE)); // Set up the module handler to return two bundles for the fieldable entity