Skip to content
Snippets Groups Projects
Commit f6dd96ca authored by Angie Byron's avatar Angie Byron
Browse files

Issue #2175415 by swentel, tim.plunkett, jibran, larowlan: Add FieldTypePluginManagerInterface.

parent 4e2a1c37
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Showing
with 81 additions and 57 deletions
......@@ -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();
......
......@@ -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();
......
<?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();
}
......@@ -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');
......
......@@ -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;
}
......
......@@ -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');
......
......@@ -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;
......
......@@ -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();
......
......@@ -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;
......
......@@ -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;
......
......@@ -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(
......
......@@ -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();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment