Unverified Commit b1f49624 authored by alexpott's avatar alexpott
Browse files

Issue #2946122 by mikelutz, heddn, tim.plunkett, phenaproxima, alexpott,...

Issue #2946122 by mikelutz, heddn, tim.plunkett, phenaproxima, alexpott, MegaChriz, joachim: Deprecate ConfigurablePluginInterface and replace with an interface that doesn't extend DependentPluginInterface
parent dad18d89
......@@ -1383,7 +1383,8 @@
* instantiated. Usually this interface will extend one or more of the
* following interfaces:
* - \Drupal\Component\Plugin\PluginInspectionInterface
* - \Drupal\Component\Plugin\ConfigurablePluginInterface
* - \Drupal\Component\Plugin\ConfigurableInterface
* - \Drupal\Component\Plugin\DependentPluginInterface
* - \Drupal\Component\Plugin\ContextAwarePluginInterface
* - \Drupal\Core\Plugin\PluginFormInterface
* - \Drupal\Core\Executable\ExecutableInterface
......
<?php
namespace Drupal\Component\Plugin;
/**
* Provides an interface for a configurable plugin.
*
* @ingroup plugin_api
*/
interface ConfigurableInterface {
/**
* Gets this plugin's configuration.
*
* @return array
* An array of this plugin's configuration.
*/
public function getConfiguration();
/**
* Sets the configuration for this plugin instance.
*
* @param array $configuration
* An associative array containing the plugin's configuration.
*/
public function setConfiguration(array $configuration);
/**
* Gets default configuration for this plugin.
*
* @return array
* An associative array with the default configuration.
*/
public function defaultConfiguration();
}
......@@ -5,6 +5,15 @@
/**
* Provides an interface for a configurable plugin.
*
* @deprecated Drupal\Component\Plugin\ConfigurablePluginInterface is deprecated
* in Drupal 8.7.0 and will be removed before Drupal 9.0.0. You should implement
* ConfigurableInterface and/or DependentPluginInterface directly as needed. If
* you implement ConfigurableInterface you may choose to implement
* ConfigurablePluginInterface in Drupal 8 as well for maximum compatibility,
* however this must be removed prior to Drupal 9.
*
* @see https://www.drupal.org/node/2946161
*
* @ingroup plugin_api
*/
interface ConfigurablePluginInterface extends DependentPluginInterface {
......
......@@ -30,7 +30,7 @@ abstract class PluginBase implements PluginInspectionInterface, DerivativeInspec
* Configuration information passed into the plugin.
*
* When using an interface like
* \Drupal\Component\Plugin\ConfigurablePluginInterface, this is where the
* \Drupal\Component\Plugin\ConfigurableInterface, this is where the
* configuration should be stored.
*
* Plugin configuration is optional, so plugin implementations must provide
......@@ -54,6 +54,10 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition
$this->configuration = $configuration;
$this->pluginId = $plugin_id;
$this->pluginDefinition = $plugin_definition;
if ($this instanceof ConfigurablePluginInterface && !$this instanceof ConfigurableInterface) {
@trigger_error('Drupal\Component\Plugin\ConfigurablePluginInterface is deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. You should implement ConfigurableInterface and/or DependentPluginInterface directly as needed. If you implement ConfigurableInterface you may choose to implement ConfigurablePluginInterface in Drupal 8 as well for maximum compatibility, however this must be removed prior to Drupal 9. See https://www.drupal.org/node/2946161', E_USER_DEPRECATED);
}
}
/**
......@@ -93,4 +97,14 @@ public function getPluginDefinition() {
return $this->pluginDefinition;
}
/**
* Determines if the plugin is configurable.
*
* @return bool
* A boolean indicating whether the plugin is configurable.
*/
public function isConfigurable() {
return $this instanceof ConfigurableInterface || $this instanceof ConfigurablePluginInterface;
}
}
......@@ -2,14 +2,16 @@
namespace Drupal\Core\Action;
use Drupal\Component\Plugin\ConfigurableInterface;
use Drupal\Component\Plugin\ConfigurablePluginInterface;
use Drupal\Component\Plugin\DependentPluginInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\PluginFormInterface;
/**
* Provides a base implementation for a configurable Action plugin.
*/
abstract class ConfigurableActionBase extends ActionBase implements ConfigurablePluginInterface, PluginFormInterface {
abstract class ConfigurableActionBase extends ActionBase implements ConfigurableInterface, DependentPluginInterface, ConfigurablePluginInterface, PluginFormInterface {
/**
* {@inheritdoc}
......
......@@ -2,10 +2,12 @@
namespace Drupal\Core\Block;
use Drupal\Component\Plugin\ConfigurablePluginInterface;
use Drupal\Component\Plugin\DerivativeInspectionInterface;
use Drupal\Core\Cache\CacheableDependencyInterface;
use Drupal\Component\Plugin\PluginInspectionInterface;
use Drupal\Component\Plugin\ConfigurablePluginInterface;
use Drupal\Component\Plugin\ConfigurableInterface;
use Drupal\Component\Plugin\DependentPluginInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\PluginFormInterface;
use Drupal\Core\Session\AccountInterface;
......@@ -20,7 +22,7 @@
*
* @ingroup block_api
*/
interface BlockPluginInterface extends ConfigurablePluginInterface, PluginFormInterface, PluginInspectionInterface, CacheableDependencyInterface, DerivativeInspectionInterface {
interface BlockPluginInterface extends ConfigurableInterface, DependentPluginInterface, ConfigurablePluginInterface, PluginFormInterface, PluginInspectionInterface, CacheableDependencyInterface, DerivativeInspectionInterface {
/**
* Indicates the block label (title) should be displayed to end users.
......
......@@ -2,7 +2,9 @@
namespace Drupal\Core\Condition;
use Drupal\Component\Plugin\ConfigurableInterface;
use Drupal\Component\Plugin\ConfigurablePluginInterface;
use Drupal\Component\Plugin\DependentPluginInterface;
use Drupal\Component\Plugin\PluginInspectionInterface;
use Drupal\Core\Cache\CacheableDependencyInterface;
use Drupal\Core\Executable\ExecutableInterface;
......@@ -42,7 +44,7 @@
*
* @ingroup plugin_api
*/
interface ConditionInterface extends ExecutableInterface, PluginFormInterface, ConfigurablePluginInterface, PluginInspectionInterface, CacheableDependencyInterface {
interface ConditionInterface extends ExecutableInterface, PluginFormInterface, ConfigurableInterface, DependentPluginInterface, ConfigurablePluginInterface, PluginInspectionInterface, CacheableDependencyInterface {
/**
* Determines whether condition result will be negated.
......
......@@ -2,7 +2,9 @@
namespace Drupal\Core\Display;
use Drupal\Component\Plugin\ConfigurableInterface;
use Drupal\Component\Plugin\ConfigurablePluginInterface;
use Drupal\Component\Plugin\DependentPluginInterface;
use Drupal\Component\Plugin\PluginInspectionInterface;
use Drupal\Core\Cache\RefinableCacheableDependencyInterface;
use Drupal\Core\Plugin\PluginFormInterface;
......@@ -16,7 +18,7 @@
* @see \Drupal\Core\Display\VariantManager
* @see plugin_api
*/
interface VariantInterface extends PluginInspectionInterface, ConfigurablePluginInterface, PluginFormInterface, RefinableCacheableDependencyInterface {
interface VariantInterface extends PluginInspectionInterface, ConfigurableInterface, DependentPluginInterface, ConfigurablePluginInterface, PluginFormInterface, RefinableCacheableDependencyInterface {
/**
* Returns the user-facing display variant label.
......
......@@ -2,7 +2,9 @@
namespace Drupal\Core\Entity\EntityReferenceSelection;
use Drupal\Component\Plugin\ConfigurableInterface;
use Drupal\Component\Plugin\ConfigurablePluginInterface;
use Drupal\Component\Plugin\DependentPluginInterface;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Database\Query\SelectInterface;
use Drupal\Core\Form\FormStateInterface;
......@@ -11,7 +13,7 @@
/**
* Provides a base class for configurable selection handlers.
*/
abstract class SelectionPluginBase extends PluginBase implements SelectionInterface, ConfigurablePluginInterface {
abstract class SelectionPluginBase extends PluginBase implements SelectionInterface, ConfigurableInterface, DependentPluginInterface, ConfigurablePluginInterface {
/**
* Constructs a new selection object.
......
......@@ -9,7 +9,7 @@
* Interface definition for plugin with settings.
*
* @deprecated in Drupal 8.1.0 and will be removed before Drupal 9.0.0. Use
* \Drupal\Component\Plugin\ConfigurablePluginInterface instead.
* \Drupal\Component\Plugin\ConfigurableInterface instead.
*/
interface PluginSettingsInterface extends PluginInspectionInterface, ThirdPartySettingsInterface {
......
......@@ -2,14 +2,16 @@
namespace Drupal\Core\Layout;
use Drupal\Component\Plugin\ConfigurablePluginInterface;
use Drupal\Component\Plugin\DerivativeInspectionInterface;
use Drupal\Component\Plugin\PluginInspectionInterface;
use Drupal\Component\Plugin\ConfigurablePluginInterface;
use Drupal\Component\Plugin\ConfigurableInterface;
use Drupal\Component\Plugin\DependentPluginInterface;
/**
* Provides an interface for static Layout plugins.
*/
interface LayoutInterface extends PluginInspectionInterface, DerivativeInspectionInterface, ConfigurablePluginInterface {
interface LayoutInterface extends PluginInspectionInterface, DerivativeInspectionInterface, ConfigurableInterface, DependentPluginInterface, ConfigurablePluginInterface {
/**
* Build a render array for layout with regions.
......
......@@ -2,7 +2,6 @@
namespace Drupal\Core\Plugin;
use Drupal\Component\Plugin\ConfigurablePluginInterface;
use Drupal\Component\Plugin\ContextAwarePluginBase as ComponentContextAwarePluginBase;
use Drupal\Component\Plugin\Exception\ContextException;
use Drupal\Core\Cache\Cache;
......@@ -78,7 +77,7 @@ public function setContextValue($name, $value) {
* {@inheritdoc}
*/
public function getContextMapping() {
$configuration = $this instanceof ConfigurablePluginInterface ? $this->getConfiguration() : $this->configuration;
$configuration = $this->isConfigurable() ? $this->getConfiguration() : $this->configuration;
return isset($configuration['context_mapping']) ? $configuration['context_mapping'] : [];
}
......@@ -86,7 +85,7 @@ public function getContextMapping() {
* {@inheritdoc}
*/
public function setContextMapping(array $context_mapping) {
if ($this instanceof ConfigurablePluginInterface) {
if ($this->isConfigurable()) {
$configuration = $this->getConfiguration();
$configuration['context_mapping'] = array_filter($context_mapping);
$this->setConfiguration($configuration);
......
......@@ -5,7 +5,6 @@
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
use Drupal\Component\Plugin\LazyPluginCollection;
use Drupal\Component\Plugin\PluginManagerInterface;
use Drupal\Component\Plugin\ConfigurablePluginInterface;
use Drupal\Core\DependencyInjection\DependencySerializationTrait;
/**
......@@ -112,7 +111,7 @@ public function getConfiguration() {
$this->instanceIDs = $this->originalOrder + $current_order;
foreach ($this as $instance_id => $instance) {
if ($instance instanceof ConfigurablePluginInterface) {
if ($instance->isConfigurable()) {
$instances[$instance_id] = $instance->getConfiguration();
}
else {
......@@ -158,7 +157,7 @@ public function setConfiguration($configuration) {
public function setInstanceConfiguration($instance_id, array $configuration) {
$this->configurations[$instance_id] = $configuration;
$instance = $this->get($instance_id);
if ($instance instanceof ConfigurablePluginInterface) {
if ($instance->isConfigurable()) {
$instance->setConfiguration($configuration);
}
}
......
......@@ -4,7 +4,6 @@
use Drupal\Component\Plugin\PluginManagerInterface;
use Drupal\Component\Plugin\LazyPluginCollection;
use Drupal\Component\Plugin\ConfigurablePluginInterface;
use Drupal\Core\DependencyInjection\DependencySerializationTrait;
/**
......@@ -67,7 +66,7 @@ protected function initializePlugin($instance_id) {
*/
public function getConfiguration() {
$plugin = $this->get($this->instanceId);
if ($plugin instanceof ConfigurablePluginInterface) {
if ($plugin && $plugin->isConfigurable()) {
return $plugin->getConfiguration();
}
else {
......@@ -81,7 +80,7 @@ public function getConfiguration() {
public function setConfiguration($configuration) {
$this->configuration = $configuration;
$plugin = $this->get($this->instanceId);
if ($plugin instanceof ConfigurablePluginInterface) {
if ($plugin && $plugin->isConfigurable()) {
$plugin->setConfiguration($configuration);
}
return $this;
......
......@@ -2,7 +2,9 @@
namespace Drupal\aggregator\Plugin;
use Drupal\Component\Plugin\ConfigurableInterface;
use Drupal\Component\Plugin\ConfigurablePluginInterface;
use Drupal\Component\Plugin\DependentPluginInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\PluginBase;
use Drupal\Core\Plugin\PluginFormInterface;
......@@ -19,7 +21,7 @@
* @see \Drupal\aggregator\Plugin\ParserInterface
* @see plugin_api
*/
abstract class AggregatorPluginSettingsBase extends PluginBase implements PluginFormInterface, ConfigurablePluginInterface {
abstract class AggregatorPluginSettingsBase extends PluginBase implements PluginFormInterface, ConfigurableInterface, DependentPluginInterface, ConfigurablePluginInterface {
/**
* {@inheritdoc}
......
......@@ -2,8 +2,10 @@
namespace Drupal\filter\Plugin;
use Drupal\Component\Plugin\PluginInspectionInterface;
use Drupal\Component\Plugin\ConfigurablePluginInterface;
use Drupal\Component\Plugin\PluginInspectionInterface;
use Drupal\Component\Plugin\ConfigurableInterface;
use Drupal\Component\Plugin\DependentPluginInterface;
use Drupal\Core\Form\FormStateInterface;
/**
......@@ -75,7 +77,7 @@
* @see \Drupal\filter\Plugin\FilterBase
* @see plugin_api
*/
interface FilterInterface extends ConfigurablePluginInterface, PluginInspectionInterface {
interface FilterInterface extends ConfigurableInterface, DependentPluginInterface, ConfigurablePluginInterface, PluginInspectionInterface {
/**
* Non-HTML markup language filters that generate HTML.
......
......@@ -2,7 +2,9 @@
namespace Drupal\image;
use Drupal\Component\Plugin\ConfigurableInterface;
use Drupal\Component\Plugin\ConfigurablePluginInterface;
use Drupal\Component\Plugin\DependentPluginInterface;
use Drupal\Component\Plugin\PluginInspectionInterface;
use Drupal\Core\Image\ImageInterface;
......@@ -16,7 +18,7 @@
* @see \Drupal\image\ImageEffectManager
* @see plugin_api
*/
interface ImageEffectInterface extends PluginInspectionInterface, ConfigurablePluginInterface {
interface ImageEffectInterface extends PluginInspectionInterface, ConfigurableInterface, DependentPluginInterface, ConfigurablePluginInterface {
/**
* Applies an image effect to the image object.
......
......@@ -2,7 +2,9 @@
namespace Drupal\media;
use Drupal\Component\Plugin\ConfigurableInterface;
use Drupal\Component\Plugin\ConfigurablePluginInterface;
use Drupal\Component\Plugin\DependentPluginInterface;
use Drupal\Component\Plugin\PluginInspectionInterface;
use Drupal\Core\Entity\Display\EntityFormDisplayInterface;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
......@@ -66,7 +68,7 @@
* @see \Drupal\media\MediaSourceFieldConstraintsInterface
* @see plugin_api
*/
interface MediaSourceInterface extends PluginInspectionInterface, ConfigurablePluginInterface, PluginFormInterface {
interface MediaSourceInterface extends PluginInspectionInterface, ConfigurableInterface, DependentPluginInterface, ConfigurablePluginInterface, PluginFormInterface {
/**
* Default empty value for metadata fields.
......
......@@ -2,13 +2,15 @@
namespace Drupal\search\Plugin;
use Drupal\Component\Plugin\ConfigurableInterface;
use Drupal\Component\Plugin\ConfigurablePluginInterface;
use Drupal\Component\Plugin\DependentPluginInterface;
use Drupal\Core\Plugin\PluginFormInterface;
/**
* Provides an interface for a configurable Search plugin.
*/
interface ConfigurableSearchPluginInterface extends ConfigurablePluginInterface, PluginFormInterface, SearchInterface {
interface ConfigurableSearchPluginInterface extends ConfigurableInterface, DependentPluginInterface, ConfigurablePluginInterface, PluginFormInterface, SearchInterface {
/**
* Sets the ID for the search page using this plugin.
......
......@@ -7,7 +7,6 @@
use Drupal\Core\Entity\EntityWithPluginCollectionInterface;
use Drupal\system\ActionConfigEntityInterface;
use Drupal\Core\Action\ActionPluginCollection;
use Drupal\Component\Plugin\ConfigurablePluginInterface;
/**
* Defines the configured action entity.
......@@ -133,7 +132,7 @@ public function execute(array $entities) {
* {@inheritdoc}
*/
public function isConfigurable() {
return $this->getPlugin() instanceof ConfigurablePluginInterface;
return $this->getPlugin()->isConfigurable();
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment