Commit 3ded2216 authored by alexpott's avatar alexpott

Issue #2115145 by Berdir | effulgentsia: Move field type plugins to Plugin/Field/FieldType.

parent c1027b9d
......@@ -383,7 +383,7 @@ public function get($property_name) {
/**
* Gets a translated field.
*
* @return \Drupal\Core\Entity\Field\FieldItemListInterface
* @return \Drupal\Core\Field\FieldItemListInterface
*/
protected function getTranslatedField($property_name, $langcode) {
if ($this->translations[$this->activeLangcode]['status'] == static::TRANSLATION_REMOVED) {
......
......@@ -17,14 +17,14 @@
* 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\Entity\Field\FieldItemListInterface,
* have to implement \Drupal\Core\Field\FieldItemListInterface,
* which builds upon typed data interfaces as well.
*
* 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\Entity\Field\FieldItemListInterface
* @see \Drupal\Core\Field\FieldItemListInterface
*/
interface ContentEntityInterface extends EntityInterface, RevisionableInterface, TranslatableInterface, ComplexDataInterface {
......
......@@ -7,9 +7,9 @@
namespace Drupal\Core\Entity;
use Drupal\Core\Entity\Field\FieldItemListInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Entity\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Language\Language;
use Drupal\Core\Session\AccountInterface;
......
......@@ -7,9 +7,9 @@
namespace Drupal\Core\Entity;
use Drupal\Core\Entity\Field\FieldItemListInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Entity\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Language\Language;
use Drupal\Core\Session\AccountInterface;
......@@ -78,12 +78,12 @@ public function setModuleHandler(ModuleHandlerInterface $module_handler);
* @param string $operation
* The operation access should be checked for.
* Usually one of "view" or "edit".
* @param \Drupal\Core\Entity\Field\FieldDefinitionInterface $field_definition
* @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
* The field definition.
* @param \Drupal\Core\Session\AccountInterface $account
* (optional) The user session for which to check access, or NULL to check
* access for the current user. Defaults to NULL.
* @param \Drupal\Core\Entity\Field\FieldItemListInterface $items
* @param \Drupal\Core\Field\FieldItemListInterface $items
* (optional) The field values for which to check access, or NULL if access
* is checked for the field definition, without any specific value
* available. Defaults to NULL.
......
......@@ -7,10 +7,10 @@
namespace Drupal\Core\Entity;
use Drupal\Core\Entity\Field\PrepareCacheInterface;
use Drupal\Core\Field\PrepareCacheInterface;
use Drupal\field\FieldInterface;
use Drupal\field\FieldInstanceInterface;
use Drupal\field\Plugin\Type\FieldType\ConfigFieldItemListInterface;
use Drupal\Core\Field\ConfigFieldItemListInterface;
use Symfony\Component\DependencyInjection\Container;
abstract class FieldableEntityStorageControllerBase extends EntityStorageControllerBase implements FieldableEntityStorageControllerInterface {
......
......@@ -14,12 +14,12 @@
* Defines the base plugin for deriving data types for field types.
*
* Note that the class only register the plugin, and is actually never used.
* \Drupal\Core\Entity\Field\FieldItemBase is available for use as base class.
* \Drupal\Core\Field\FieldItemBase is available for use as base class.
*
* @DataType(
* id = "field_item",
* label = @Translation("Field item"),
* list_class = "\Drupal\Core\Entity\Field\FieldItemList",
* list_class = "\Drupal\Core\Field\FieldItemList",
* derivative = "Drupal\Core\Entity\Plugin\DataType\Deriver\FieldItemDeriver"
* )
*/
......
......@@ -2,15 +2,14 @@
/**
* @file
* Contains \Drupal\field\Plugin\Type\FieldType\ConfigEntityReferenceItemBase.
* Contains \Drupal\Core\Field\ConfigEntityReferenceItemBase.
*/
namespace Drupal\field\Plugin\Type\FieldType;
namespace Drupal\Core\Field;
use Drupal\Core\Entity\Plugin\field\field_type\EntityReferenceItem;
use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem;
use Drupal\field\FieldInstanceInterface;
use Drupal\field\FieldInterface;
use Drupal\field\Plugin\Type\FieldType\ConfigFieldItemInterface;
/**
* A common base class for configurable entity reference fields.
......@@ -76,7 +75,7 @@ public function getPropertyDefinitions() {
/**
* {@inheritdoc}
*
* Copied from \Drupal\field\Plugin\field\field_type\LegacyConfigFieldItem,
* Copied from \Drupal\field\Plugin\Field\FieldType\LegacyConfigFieldItem,
* since we cannot extend it.
*/
public static function schema(FieldInterface $field) {
......@@ -108,7 +107,7 @@ public function isEmpty() {
/**
* {@inheritdoc}
*
* Copied from \Drupal\field\Plugin\field\field_type\LegacyConfigFieldItem,
* Copied from \Drupal\field\Plugin\Field\FieldType\LegacyConfigFieldItem,
* since we cannot extend it.
*/
public function settingsForm(array $form, array &$form_state, $has_data) {
......@@ -127,7 +126,7 @@ public function settingsForm(array $form, array &$form_state, $has_data) {
/**
* {@inheritdoc}
*
* Copied from \Drupal\field\Plugin\field\field_type\LegacyConfigFieldItem,
* Copied from \Drupal\field\Plugin\Field\FieldType\LegacyConfigFieldItem,
* since we cannot extend it.
*/
public function instanceSettingsForm(array $form, array &$form_state) {
......@@ -161,7 +160,7 @@ public function getSettableOptions() {
/**
* Returns the legacy callback for a given field type "hook".
*
* Copied from \Drupal\field\Plugin\field\field_type\LegacyConfigFieldItem,
* Copied from \Drupal\field\Plugin\Field\FieldType\LegacyConfigFieldItem,
* since we cannot extend it.
*
* @param string $hook
......
......@@ -2,12 +2,10 @@
/**
* @file
* Contains \Drupal\field\Plugin\Type\FieldType\ConfigFieldItemBase.
* Contains \Drupal\Core\Field\ConfigFieldItemBase.
*/
namespace Drupal\field\Plugin\Type\FieldType;
use Drupal\Core\Entity\Field\FieldItemBase;
namespace Drupal\Core\Field;
/**
* Base class for 'configurable field type' plugin implementations.
......
......@@ -2,12 +2,11 @@
/**
* @file
* Contains \Drupal\field\Plugin\Type\FieldType\ConfigFieldItemInterface.
* Contains \Drupal\Core\Field\ConfigFieldItemInterface.
*/
namespace Drupal\field\Plugin\Type\FieldType;
namespace Drupal\Core\Field;
use Drupal\Core\Entity\Field\FieldItemInterface;
use Drupal\field\FieldInterface;
/**
......
......@@ -2,14 +2,13 @@
/**
* @file
* Contains \Drupal\field\Plugin\Type\FieldType\ConfigFieldItemList.
* Contains \Drupal\Core\Field\ConfigFieldItemList.
*/
namespace Drupal\field\Plugin\Type\FieldType;
namespace Drupal\Core\Field;
use Drupal\Core\TypedData\TypedDataInterface;
use Drupal\Core\Entity\Field\FieldItemList;
use Drupal\field\Field as FieldAPI;
use Drupal\field\Field;
/**
* Represents a configurable entity field item list.
......@@ -39,7 +38,7 @@ public function __construct(array $definition, $name = NULL, TypedDataInterface
public function getFieldDefinition() {
if (!isset($this->instance)) {
$entity = $this->getEntity();
$instances = FieldAPI::fieldInfo()->getBundleInstances($entity->entityType(), $entity->bundle());
$instances = Field::fieldInfo()->getBundleInstances($entity->entityType(), $entity->bundle());
if (isset($instances[$this->getName()])) {
$this->instance = $instances[$this->getName()];
}
......
......@@ -2,12 +2,10 @@
/**
* @file
* Contains \Drupal\field\Plugin\Type\FieldType\ConfigFieldItemListInterface.
* Contains \Drupal\Core\Field\ConfigFieldItemListInterface.
*/
namespace Drupal\field\Plugin\Type\FieldType;
use Drupal\Core\Entity\Field\FieldItemListInterface;
namespace Drupal\Core\Field;
/**
* Interface definition for "configurable fields".
......
......@@ -2,10 +2,11 @@
/**
* @file
* Contains \Drupal\Core\Entity\Field\FieldDefinition.
* Contains \Drupal\Core\Field\FieldDefinition.
*/
namespace Drupal\Core\Entity\Field;
namespace Drupal\Core\Field;
use Drupal\Core\Entity\EntityInterface;
/**
......@@ -43,7 +44,7 @@ public function getFieldName() {
* @param string $name
* The field name to set.
*
* @return \Drupal\Core\Entity\Field\FieldDefinition
* @return \Drupal\Core\Field\FieldDefinition
* The object itself for chaining.
*/
public function setFieldName($name) {
......@@ -66,7 +67,7 @@ public function getFieldType() {
* @param string $type
* The field type to set.
*
* @return \Drupal\Core\Entity\Field\FieldDefinition
* @return \Drupal\Core\Field\FieldDefinition
* The object itself for chaining.
*/
public function setFieldType($type) {
......@@ -80,7 +81,7 @@ public function setFieldType($type) {
* @param string $type
* The field type to set.
*
* @return \Drupal\Core\Entity\Field\FieldDefinition
* @return \Drupal\Core\Field\FieldDefinition
* The object itself for chaining.
*/
public function setFieldSetting($setting_name, $value) {
......@@ -122,7 +123,7 @@ public function isFieldTranslatable() {
* @param bool $translatable
* Whether the field is translatable.
*
* @return \Drupal\Core\Entity\Field\FieldDefinition
* @return \Drupal\Core\Field\FieldDefinition
* The object itself for chaining.
*/
public function setTranslatable($translatable) {
......@@ -143,7 +144,7 @@ public function getFieldLabel() {
* @param string $label
* The field label to set.
*
* @return \Drupal\Core\Entity\Field\FieldDefinition
* @return \Drupal\Core\Field\FieldDefinition
* The object itself for chaining.
*/
public function setFieldLabel($label) {
......@@ -164,7 +165,7 @@ public function getFieldDescription() {
* @param string $description
* The field label to set.
*
* @return \Drupal\Core\Entity\Field\FieldDefinition
* @return \Drupal\Core\Field\FieldDefinition
* The object itself for chaining.
*/
public function setFieldDescription($description) {
......@@ -193,7 +194,7 @@ public function isFieldRequired() {
* @param bool $required
* TRUE if the field is required, FALSE otherwise.
*
* @return \Drupal\Core\Entity\Field\FieldDefinition
* @return \Drupal\Core\Field\FieldDefinition
* The object itself for chaining.
*/
public function setFieldRequired($required) {
......@@ -209,7 +210,7 @@ public function setFieldRequired($required) {
* @param array $constraints
* The constraints to set.
*
* @return \Drupal\Core\Entity\Field\FieldDefinition
* @return \Drupal\Core\Field\FieldDefinition
* The object itself for chaining.
*/
public function setPropertyConstraints($name, array $constraints) {
......
......@@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\Core\Entity\Field\FieldDefinitionInterface.
* Contains \Drupal\Core\Field\FieldDefinitionInterface.
*/
namespace Drupal\Core\Entity\Field;
namespace Drupal\Core\Field;
use Drupal\Core\Entity\EntityInterface;
......@@ -13,7 +13,7 @@
* Defines an interface for entity field definitions.
*
* An entity field is a data object that holds the values of a particular field
* for a particular entity (see \Drupal\Core\Entity\Field\FieldItemListInterface). For
* for a particular entity (see \Drupal\Core\Field\FieldItemListInterface). For
* example, $node_1->body and $node_2->body contain different data and therefore
* are different field objects.
*
......@@ -70,7 +70,7 @@ public function getFieldName();
* @return string
* The field type, i.e. the id of a field type plugin. For example 'text'.
*
* @see \Drupal\Core\Entity\Field\FieldTypePluginManager
* @see \Drupal\Core\Field\FieldTypePluginManager
*/
public function getFieldType();
......
......@@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\Core\Entity\Field\FieldItemBase.
* Contains \Drupal\Core\Field\FieldItemBase.
*/
namespace Drupal\Core\Entity\Field;
namespace Drupal\Core\Field;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\TypedData\Plugin\DataType\Map;
......@@ -18,7 +18,7 @@
* Entity field items making use of this base class have to implement
* ComplexDataInterface::getPropertyDefinitions().
*
* @see \Drupal\Core\Entity\Field\FieldItemInterface
* @see \Drupal\Core\Field\FieldItemInterface
*/
abstract class FieldItemBase extends Map implements FieldItemInterface {
......@@ -110,7 +110,7 @@ public function setValue($values, $notify = TRUE) {
}
/**
* Implements \Drupal\Core\Entity\Field\FieldItemInterface::__get().
* {@inheritdoc}
*/
public function __get($name) {
// There is either a property object or a plain value - possibly for a
......@@ -144,7 +144,7 @@ public function set($property_name, $value, $notify = TRUE) {
}
/**
* Implements \Drupal\Core\Entity\Field\FieldItemInterface::__set().
* {@inheritdoc}
*/
public function __set($name, $value) {
// Support setting values via property objects, but take care in as the
......@@ -156,14 +156,14 @@ public function __set($name, $value) {
}
/**
* Implements \Drupal\Core\Entity\Field\FieldItemInterface::__isset().
* {@inheritdoc}
*/
public function __isset($name) {
return isset($this->values[$name]) || (isset($this->properties[$name]) && $this->properties[$name]->getValue() !== NULL);
}
/**
* Implements \Drupal\Core\Entity\Field\FieldItemInterface::__unset().
* {@inheritdoc}
*/
public function __unset($name) {
$this->set($name, NULL);
......
......@@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\Core\Entity\Field\FieldItemInterface.
* Contains \Drupal\Core\Field\FieldItemInterface.
*/
namespace Drupal\Core\Entity\Field;
namespace Drupal\Core\Field;
use Drupal\Core\TypedData\ComplexDataInterface;
......@@ -18,8 +18,8 @@
* When implementing this interface which extends Traversable, make sure to list
* IteratorAggregate or Iterator before this interface in the implements clause.
*
* @see \Drupal\Core\Entity\Field\FieldItemListInterface
* @see \Drupal\Core\Entity\Field\FieldItemBase
* @see \Drupal\Core\Field\FieldItemListInterface
* @see \Drupal\Core\Field\FieldItemBase
*/
interface FieldItemInterface extends ComplexDataInterface {
......@@ -42,7 +42,7 @@ public function getLangcode();
/**
* Gets the field definition.
*
* @return \Drupal\Core\Entity\Field\FieldDefinitionInterface
* @return \Drupal\Core\Field\FieldDefinitionInterface
* The field definition.
*/
public function getFieldDefinition();
......
......@@ -2,12 +2,11 @@
/**
* @file
* Contains \Drupal\Core\Entity\Field\FieldItemList.
* Contains \Drupal\Core\Field\FieldItemList.
*/
namespace Drupal\Core\Entity\Field;
namespace Drupal\Core\Field;
use Drupal\Core\Entity\Field\FieldItemListInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\TypedData\TypedDataInterface;
use Drupal\Core\TypedData\ItemList;
......@@ -146,49 +145,49 @@ public function setValue($values, $notify = TRUE) {
}
/**
* Implements \Drupal\Core\Entity\Field\FieldItemListInterface::getPropertyDefinition().
* {@inheritdoc}
*/
public function getPropertyDefinition($name) {
return $this->offsetGet(0)->getPropertyDefinition($name);
}
/**
* Implements \Drupal\Core\Entity\Field\FieldItemListInterface::getPropertyDefinitions().
* {@inheritdoc}
*/
public function getPropertyDefinitions() {
return $this->offsetGet(0)->getPropertyDefinitions();
}
/**
* Implements \Drupal\Core\Entity\Field\FieldItemListInterface::__get().
* {@inheritdoc}
*/
public function __get($property_name) {
return $this->offsetGet(0)->__get($property_name);
}
/**
* Implements \Drupal\Core\Entity\Field\FieldItemListInterface::get().
* {@inheritdoc}
*/
public function get($property_name) {
return $this->offsetGet(0)->get($property_name);
}
/**
* Implements \Drupal\Core\Entity\Field\FieldItemListInterface::__set().
* {@inheritdoc}
*/
public function __set($property_name, $value) {
$this->offsetGet(0)->__set($property_name, $value);
}
/**
* Implements \Drupal\Core\Entity\Field\FieldItemListInterface::__isset().
* {@inheritdoc}
*/
public function __isset($property_name) {
return $this->offsetGet(0)->__isset($property_name);
}
/**
* Implements \Drupal\Core\Entity\Field\FieldItemListInterface::__unset().
* {@inheritdoc}
*/
public function __unset($property_name) {
return $this->offsetGet(0)->__unset($property_name);
......
......@@ -2,10 +2,10 @@
/**
* @file
* Contains \Drupal\Core\Entity\Field\FieldItemListInterface.
* Contains \Drupal\Core\Field\FieldItemListInterface.
*/
namespace Drupal\Core\Entity\Field;
namespace Drupal\Core\Field;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Access\AccessibleInterface;
......@@ -55,7 +55,7 @@ public function getLangcode();
/**
* Gets the field definition.
*
* @return \Drupal\Core\Entity\Field\FieldDefinitionInterface
* @return \Drupal\Core\Field\FieldDefinitionInterface
* The field definition.
*/
public function getFieldDefinition();
......@@ -79,49 +79,49 @@ public function filterEmptyValues();
/**
* Gets a property object from the first field item.
*
* @see \Drupal\Core\Entity\Field\FieldItemInterface::get()
* @see \Drupal\Core\Field\FieldItemInterface::get()
*/
public function get($property_name);
/**
* Magic method: Gets a property value of to the first field item.
*
* @see \Drupal\Core\Entity\Field\FieldItemInterface::__get()
* @see \Drupal\Core\Field\FieldItemInterface::__get()
*/
public function __get($property_name);
/**
* Magic method: Sets a property value of the first field item.
*
* @see \Drupal\Core\Entity\Field\FieldItemInterface::__set()
* @see \Drupal\Core\Field\FieldItemInterface::__set()
*/
public function __set($property_name, $value);
/**
* Magic method: Determines whether a property of the first field item is set.
*
* @see \Drupal\Core\Entity\Field\FieldItemInterface::__isset()
* @see \Drupal\Core\Field\FieldItemInterface::__isset()
*/
public function __isset($property_name);
/**
* Magic method: Unsets a property of the first field item.
*
* @see \Drupal\Core\Entity\Field\FieldItemInterface::__unset()
* @see \Drupal\Core\Field\FieldItemInterface::__unset()
*/
public function __unset($property_name);
/**
* Gets the definition of a property of the first field item.
*
* @see \Drupal\Core\Entity\Field\FieldItemInterface::getPropertyDefinition()
* @see \Drupal\Core\Field\FieldItemInterface::getPropertyDefinition()
*/
public function getPropertyDefinition($name);
/**
* Gets an array of property definitions of the first field item.
*
* @see \Drupal\Core\Entity\Field\FieldItemInterface::getPropertyDefinitions()
* @see \Drupal\Core\Field\FieldItemInterface::getPropertyDefinitions()
*/
public function getPropertyDefinitions();
......
......@@ -11,7 +11,6 @@
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Language\LanguageManager;
use Drupal\Core\Plugin\DefaultPluginManager;
use Drupal\field\Plugin\Type\FieldType\LegacyFieldTypeDiscoveryDecorator;
/**
* Plugin manager for 'field type' plugins.
......@@ -40,7 +39,7 @@ class FieldTypePluginManager extends DefaultPluginManager {
* The module handler.
*/
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, LanguageManager $language_manager, ModuleHandlerInterface $module_handler) {
parent::__construct('Plugin/field/field_type', $namespaces, 'Drupal\Core\Field\Annotation\FieldType');
parent::__construct('Plugin/Field/FieldType', $namespaces, 'Drupal\Core\Field\Annotation\FieldType');
$this->alterInfo($module_handler, 'field_info');
$this->setCacheBackend($cache_backend, $language_manager, 'field_types_plugins');
......@@ -56,10 +55,10 @@ public function processDefinition(&$definition, $plugin_id) {
parent::processDefinition($definition, $plugin_id);
if (!isset($definition['list_class'])) {
if ($definition['configurable']) {
$definition['list_class'] = '\Drupal\field\Plugin\Type\FieldType\ConfigFieldItemList';
$definition['list_class'] = '\Drupal\Core\Field\ConfigFieldItemList';
}
else {
$definition['list_class'] = '\Drupal\Core\Entity\Field\FieldItemList';
$definition['list_class'] = '\Drupal\Core\Field\FieldItemList';
}
}
}
......
......@@ -7,10 +7,6 @@
namespace Drupal\Core\Field;
use Drupal\Core\Entity\Field\FieldDefinitionInterface;
use Drupal\Core\Entity\Field\FieldItemListInterface;
use Drupal\field\Plugin\PluginSettingsBase;
/**
* Base class for 'Field formatter' plugin implementations.
*/
......@@ -19,7 +15,7 @@ abstract class FormatterBase extends PluginSettingsBase implements FormatterInte
/**
* The field definition.
*
* @var \Drupal\Core\Entity\Field\FieldDefinitionInterface
* @var \Drupal\Core\Field\FieldDefinitionInterface
*/
protected $fieldDefinition;
......@@ -51,7 +47,7 @@ abstract class FormatterBase extends PluginSettingsBase implements FormatterInte
* The plugin_id for the formatter.
* @param array $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Entity\Field\FieldDefinitionInterface $field_definition
* @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
* The definition of the field to which the formatter is associated.
* @param array $settings
* The formatter settings.
......
......@@ -7,9 +7,6 @@
namespace Drupal\Core\Field;
use Drupal\Core\Entity\Field\FieldItemListInterface;
use Drupal\field\Plugin\PluginSettingsInterface;
/**