diff --git a/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php b/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php index dba51830b2a972575a9924ba211e4b1dabef0bb8..fbe988c9e1ac2800533f52d8717119c1a903418f 100644 --- a/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php +++ b/core/lib/Drupal/Core/Field/FieldDefinitionInterface.php @@ -75,7 +75,7 @@ public function getName(); * @return string * The field type, i.e. the id of a field type plugin. For example 'text'. * - * @see \Drupal\Core\Field\FieldTypePluginManager + * @see \Drupal\Core\Field\FieldTypePluginManagerInterface */ public function getType(); diff --git a/core/lib/Drupal/Core/Field/FieldTypePluginManager.php b/core/lib/Drupal/Core/Field/FieldTypePluginManager.php index 86e55522d4cfdb33ca69024593b30cd5317ff75d..75ea2fd4b0b778fb7e8b833d671068138c5a5096 100644 --- a/core/lib/Drupal/Core/Field/FieldTypePluginManager.php +++ b/core/lib/Drupal/Core/Field/FieldTypePluginManager.php @@ -17,7 +17,7 @@ * * @todo Add FieldTypePluginManagerInterface in https://drupal.org/node/2175415. */ -class FieldTypePluginManager extends DefaultPluginManager { +class FieldTypePluginManager extends DefaultPluginManager implements FieldTypePluginManagerInterface { /** * {@inheritdoc} @@ -62,14 +62,7 @@ public function processDefinition(&$definition, $plugin_id) { } /** - * Returns the default field-level settings for a field type. - * - * @param string $type - * A field type name. - * - * @return array - * The type's default settings, as provided by the plugin - * definition, or an empty array if type or settings are undefined. + * {@inheritdoc} */ public function getDefaultSettings($type) { $info = $this->getDefinition($type); @@ -77,14 +70,7 @@ public function getDefaultSettings($type) { } /** - * Returns the default instance-level settings for a field type. - * - * @param string $type - * A field type name. - * - * @return array - * The instance's default settings, as provided by the plugin - * definition, or an empty array if type or settings are undefined. + * {@inheritdoc} */ public function getDefaultInstanceSettings($type) { $info = $this->getDefinition($type); @@ -92,10 +78,7 @@ public function getDefaultInstanceSettings($type) { } /** - * Gets the definition of all field types that are configurable. - * - * @return array - * An array of field type definitions. + * {@inheritdoc} */ public function getConfigurableDefinitions() { $definitions = $this->getDefinitions(); diff --git a/core/lib/Drupal/Core/Field/FieldTypePluginManagerInterface.php b/core/lib/Drupal/Core/Field/FieldTypePluginManagerInterface.php new file mode 100644 index 0000000000000000000000000000000000000000..4d2d7477561d223bbe03422b7a91abf36f6dcc5e --- /dev/null +++ b/core/lib/Drupal/Core/Field/FieldTypePluginManagerInterface.php @@ -0,0 +1,49 @@ +<?php + +/** + * @file + * Contains \Drupal\Core\Field\FieldTypePluginManagerInterface. + */ + +namespace Drupal\Core\Field; + +use Drupal\Component\Plugin\PluginManagerInterface; + +/** + * Defines an interface for the field type plugin manager. + */ +interface FieldTypePluginManagerInterface extends PluginManagerInterface { + + /** + * Returns the default instance-level settings for a field type. + * + * @param string $type + * A field type name. + * + * @return array + * The instance's default settings, as provided by the plugin definition, or + * an empty array if type or settings are undefined. + */ + public function getDefaultInstanceSettings($type); + + /** + * Returns the default field-level settings for a field type. + * + * @param string $type + * A field type name. + * + * @return array + * The type's default settings, as provided by the plugin definition, or an + * empty array if type or settings are undefined. + */ + public function getDefaultSettings($type); + + /** + * Gets the definition of all field types that are configurable. + * + * @return array + * An array of field type definitions. + */ + public function getConfigurableDefinitions(); + +} diff --git a/core/lib/Drupal/Core/Field/FormatterPluginManager.php b/core/lib/Drupal/Core/Field/FormatterPluginManager.php index 18a7789c57e5680503aeaba12d9bb39bce85ca62..c30ab0ea419de69b16894965f015ec71e5c43b16 100644 --- a/core/lib/Drupal/Core/Field/FormatterPluginManager.php +++ b/core/lib/Drupal/Core/Field/FormatterPluginManager.php @@ -28,7 +28,7 @@ class FormatterPluginManager extends DefaultPluginManager { /** * The field type manager to define field. * - * @var \Drupal\Core\Field\FieldTypePluginManager + * @var \Drupal\Core\Field\FieldTypePluginManagerInterface */ protected $fieldTypeManager; @@ -44,10 +44,10 @@ class FormatterPluginManager extends DefaultPluginManager { * The module handler. * @param \Drupal\Core\Language\LanguageManager $language_manager * The language manager. - * @param \Drupal\Core\Field\FieldTypePluginManager $field_type_manager + * @param \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_manager * The 'field type' plugin manager. */ - public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, LanguageManager $language_manager, FieldTypePluginManager $field_type_manager) { + public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, LanguageManager $language_manager, FieldTypePluginManagerInterface $field_type_manager) { parent::__construct('Plugin/Field/FieldFormatter', $namespaces, 'Drupal\Core\Field\Annotation\FieldFormatter'); diff --git a/core/lib/Drupal/Core/Field/Plugin/DataType/Deriver/FieldItemDeriver.php b/core/lib/Drupal/Core/Field/Plugin/DataType/Deriver/FieldItemDeriver.php index d2fc7fdba379e78f0103758ba1c451f914b143e7..d6b6778b75013b39daafde4813f4d4eb4321f65e 100644 --- a/core/lib/Drupal/Core/Field/Plugin/DataType/Deriver/FieldItemDeriver.php +++ b/core/lib/Drupal/Core/Field/Plugin/DataType/Deriver/FieldItemDeriver.php @@ -7,7 +7,7 @@ namespace Drupal\Core\Field\Plugin\DataType\Deriver; -use Drupal\Component\Plugin\PluginManagerInterface; +use Drupal\Core\Field\FieldTypePluginManagerInterface; use Drupal\Core\Plugin\Discovery\ContainerDerivativeInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -33,7 +33,7 @@ class FieldItemDeriver implements ContainerDerivativeInterface { /** * The field type plugin manager. * - * @var \Drupal\Component\Plugin\PluginManagerInterface + * @var \Drupal\Core\Field\FieldTypePluginManagerInterface */ protected $fieldTypePluginManager; @@ -42,10 +42,10 @@ class FieldItemDeriver implements ContainerDerivativeInterface { * * @param string $base_plugin_id * The base plugin ID. - * @param \Drupal\Component\Plugin\PluginManagerInterface $field_type_plugin_manager + * @param \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_manager * The field type plugin manager. */ - public function __construct($base_plugin_id, PluginManagerInterface $field_type_plugin_manager) { + public function __construct($base_plugin_id, FieldTypePluginManagerInterface $field_type_plugin_manager) { $this->basePluginId = $base_plugin_id; $this->fieldTypePluginManager = $field_type_plugin_manager; } diff --git a/core/lib/Drupal/Core/Field/WidgetPluginManager.php b/core/lib/Drupal/Core/Field/WidgetPluginManager.php index 8d010e76ccc8d4f6ed1800a05c0f8abbdeafa4ed..5ca455a0e7eb1b690b0156282f83e223bb49a50c 100644 --- a/core/lib/Drupal/Core/Field/WidgetPluginManager.php +++ b/core/lib/Drupal/Core/Field/WidgetPluginManager.php @@ -21,7 +21,7 @@ class WidgetPluginManager extends DefaultPluginManager { /** * The field type manager to define field. * - * @var \Drupal\Core\Field\FieldTypePluginManager + * @var \Drupal\Core\Field\FieldTypePluginManagerInterface */ protected $fieldTypeManager; @@ -44,10 +44,10 @@ class WidgetPluginManager extends DefaultPluginManager { * The module handler. * @param \Drupal\Core\Language\LanguageManager $language_manager * The language manager. - * @param \Drupal\Core\Field\FieldTypePluginManager $field_type_manager + * @param \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_manager * The 'field type' plugin manager. */ - public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, LanguageManager $language_manager, FieldTypePluginManager $field_type_manager) { + public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, LanguageManager $language_manager, FieldTypePluginManagerInterface $field_type_manager) { parent::__construct('Plugin/Field/FieldWidget', $namespaces, 'Drupal\Core\Field\Annotation\FieldWidget'); $this->setCacheBackend($cache_backend, $language_manager, 'field_widget_types_plugins'); diff --git a/core/modules/field/lib/Drupal/field/FieldInfo.php b/core/modules/field/lib/Drupal/field/FieldInfo.php index 61663e8b8e4250ece028fe4960c35aee304a3c96..4be22b75165f47683a37e98b4a3d313403e7553d 100644 --- a/core/modules/field/lib/Drupal/field/FieldInfo.php +++ b/core/modules/field/lib/Drupal/field/FieldInfo.php @@ -10,10 +10,8 @@ use Drupal\Core\Cache\Cache; use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Config\ConfigFactory; -use Drupal\Core\Field\FieldTypePluginManager; +use Drupal\Core\Field\FieldTypePluginManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\field\FieldInterface; -use Drupal\field\FieldInstanceInterface; /** * Provides field and instance definitions for the current runtime environment. @@ -51,7 +49,7 @@ class FieldInfo { /** * The field type manager to define field. * - * @var \Drupal\Core\Field\FieldTypePluginManager + * @var \Drupal\Core\Field\FieldTypePluginManagerInterface */ protected $fieldTypeManager; @@ -134,10 +132,10 @@ class FieldInfo { * The configuration factory object to use. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler class to use for invoking hooks. - * @param \Drupal\Core\Field\FieldTypePluginManager $field_type_manager + * @param \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_manager * The 'field type' plugin manager. */ - public function __construct(CacheBackendInterface $cache_backend, ConfigFactory $config, ModuleHandlerInterface $module_handler, FieldTypePluginManager $field_type_manager) { + public function __construct(CacheBackendInterface $cache_backend, ConfigFactory $config, ModuleHandlerInterface $module_handler, FieldTypePluginManagerInterface $field_type_manager) { $this->cacheBackend = $cache_backend; $this->moduleHandler = $module_handler; $this->config = $config; diff --git a/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php b/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php index cd462175e67e46a937a003d4b8be73fe15e7341a..f11863b01eaecc0d47ca65e76c6f7452df7600d0 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/DisplayOverviewBase.php @@ -11,7 +11,7 @@ use Drupal\Core\Entity\Display\EntityDisplayInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Field\FieldDefinitionInterface; -use Drupal\Core\Field\FieldTypePluginManager; +use Drupal\Core\Field\FieldTypePluginManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -45,12 +45,12 @@ abstract class DisplayOverviewBase extends OverviewBase { * * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. - * @param \Drupal\Core\Field\FieldTypePluginManager $field_type_manager + * @param \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_manager * The field type manager. * @param \Drupal\Component\Plugin\PluginManagerBase $plugin_manager * The widget or formatter plugin manager. */ - public function __construct(EntityManagerInterface $entity_manager, FieldTypePluginManager $field_type_manager, PluginManagerBase $plugin_manager) { + public function __construct(EntityManagerInterface $entity_manager, FieldTypePluginManagerInterface $field_type_manager, PluginManagerBase $plugin_manager) { parent::__construct($entity_manager); $this->fieldTypes = $field_type_manager->getConfigurableDefinitions(); diff --git a/core/modules/field_ui/lib/Drupal/field_ui/FieldListController.php b/core/modules/field_ui/lib/Drupal/field_ui/FieldListController.php index 10db033ecb4ccefbe70f692ce659e5f6b204404d..7a6bf7504644eab35a274f298e8e7f7acf0f073c 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/FieldListController.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/FieldListController.php @@ -11,7 +11,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityTypeInterface; -use Drupal\Core\Field\FieldTypePluginManager; +use Drupal\Core\Field\FieldTypePluginManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -43,7 +43,7 @@ class FieldListController extends ConfigEntityListController { /** * The field type manager. * - * @var \Drupal\Core\Field\FieldTypePluginManager + * @var \Drupal\Core\Field\FieldTypePluginManagerInterface */ protected $fieldTypeManager; @@ -54,10 +54,10 @@ class FieldListController extends ConfigEntityListController { * The entity info for the entity type. * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. - * @param \Drupal\Core\Field\FieldTypePluginManager $field_type_manager + * @param \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_manager * The 'field type' plugin manager. */ - public function __construct(EntityTypeInterface $entity_info, EntityManagerInterface $entity_manager, FieldTypePluginManager $field_type_manager) { + public function __construct(EntityTypeInterface $entity_info, EntityManagerInterface $entity_manager, FieldTypePluginManagerInterface $field_type_manager) { parent::__construct($entity_info, $entity_manager->getStorageController($entity_info->id())); $this->entityManager = $entity_manager; diff --git a/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php b/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php index 2e0106f58f7de51fb35ea168231cf7a8f8c7d42a..5fd2f693925859fbfbd146fb80f6b804e3300f1e 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php @@ -8,8 +8,8 @@ namespace Drupal\field_ui; use Drupal\Core\Entity\EntityManagerInterface; -use Drupal\Core\Field\FieldTypePluginManager; use Drupal\Core\Extension\ModuleHandlerInterface; +use Drupal\Core\Field\FieldTypePluginManagerInterface; use Drupal\field_ui\OverviewBase; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\field\Entity\Field; @@ -22,7 +22,7 @@ class FieldOverview extends OverviewBase { /** * The field type manager. * - * @var \Drupal\Core\Field\FieldTypePluginManager + * @var \Drupal\Core\Field\FieldTypePluginManagerInterface */ protected $fieldTypeManager; @@ -38,12 +38,12 @@ class FieldOverview extends OverviewBase { * * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. - * @param \Drupal\Core\Field\FieldTypePluginManager $field_type_manager + * @param \Drupal\Core\Field\FieldTypePluginManagerInterface $field_type_manager * The field type manager * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * The module handler to invoke hooks on. */ - public function __construct(EntityManagerInterface $entity_manager, FieldTypePluginManager $field_type_manager, ModuleHandlerInterface $module_handler) { + public function __construct(EntityManagerInterface $entity_manager, FieldTypePluginManagerInterface $field_type_manager, ModuleHandlerInterface $module_handler) { parent::__construct($entity_manager); $this->fieldTypeManager = $field_type_manager; $this->moduleHandler = $module_handler; diff --git a/core/tests/Drupal/Tests/Core/Entity/FieldDefinitionTest.php b/core/tests/Drupal/Tests/Core/Entity/FieldDefinitionTest.php index 02a1bafbf27ee12d2a091bd25891df7a02ba401a..39b73cf78cc112196710d74a793cffd15847055e 100644 --- a/core/tests/Drupal/Tests/Core/Entity/FieldDefinitionTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/FieldDefinitionTest.php @@ -46,10 +46,7 @@ public static function getInfo() { */ public function setUp() { // Mock the field type manager and place it in the container. - // @todo Add FieldTypePluginManagerInterface in https://drupal.org/node/2175415. - $field_type_manager = $this->getMockBuilder('Drupal\Core\Field\FieldTypePluginManager') - ->disableOriginalConstructor() - ->getMock(); + $field_type_manager = $this->getMock('Drupal\Core\Field\FieldTypePluginManagerInterface'); $this->fieldType = $this->randomName(); $this->fieldTypeDefinition = array( diff --git a/core/tests/Drupal/Tests/Core/Entity/FieldableDatabaseStorageControllerTest.php b/core/tests/Drupal/Tests/Core/Entity/FieldableDatabaseStorageControllerTest.php index bfd25c59cf562ce54da28a731ccfe3cdf16a52e4..9e8018b4b5f0dd6f3e3281e456857997d531d954 100644 --- a/core/tests/Drupal/Tests/Core/Entity/FieldableDatabaseStorageControllerTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/FieldableDatabaseStorageControllerTest.php @@ -40,10 +40,7 @@ public static function getInfo() { * @see \Drupal\Core\Entity\Controller\FieldableDatabaseStorageController::_fieldSqlSchema() */ public function testFieldSqlSchemaForEntityWithStringIdentifier() { - // @todo Add FieldTypePluginManagerInterface in https://drupal.org/node/2175415. - $field_type_manager = $this->getMockBuilder('Drupal\Core\Field\FieldTypePluginManager') - ->disableOriginalConstructor() - ->getMock(); + $field_type_manager = $this->getMock('Drupal\Core\Field\FieldTypePluginManagerInterface'); $entity_manager = $this->getMock('\Drupal\Core\Entity\EntityManagerInterface'); $container = new ContainerBuilder();