Change record status: 
Project: 
Introduced in branch: 
8.7.x
Introduced in version: 
8.7.0
Description: 

Currently, \Drupal\Component\Plugin\ConfigurablePluginInterface extends \Drupal\Component\Plugin\DependentPluginInterface. This means that any plugin implementing ConfigurablePluginInterface must also implement a calculateDependencies() method.

As of Drupal 8.7, ConfigurablePluginInterface is deprecated. A new interface, \Drupal\Component\Plugin\ConfigurableInterface has been created, containing the getConfiguration, setConfiguration, and defaultConfiguration methods. Classes should use this interface instead of ConfigurablePluginInterface. Classes further wishing to implement DependentPluginInterface should do so separately.

Before this change, this was okay:

use Drupal\Component\Plugin\ConfigurablePluginInterface;

class MyPlugin implements ConfigurablePluginInterface {

  protected $config;

  public function getConfiguration() {
    return $this->config;
  }

  public function setConfiguration(array $config) {
    $this->config = $config;
  }

  public function defaultConfiguration() {
    return [];
  }

  public function calculateDependencies() {
    return ['module' => ['node']];
  }

}

Now, you should explicitly implement ConfigurableInterface and DependentPluginInterface separately, like so:

use Drupal\Component\Plugin\ConfigurableInterface;
use Drupal\Component\Plugin\DependentPluginInterface;

class MyPlugin implements ConfigurableInterface, DependentPluginInterface {

  protected $config;

  public function getConfiguration() {
    return $this->config;
  }

  public function setConfiguration(array $config) {
    $this->config = $config;
  }

  public function defaultConfiguration() {
    return [];
  }

  public function calculateDependencies() {
    return ['module' => ['node']];
  }

}

However, if your plugin is not used as part of a configuration entity, and does not need to provide dependencies, you no longer need to implement DependentPluginInterface or the calculateDependencies() method.

If your code is interacting with a configurable plugin, you should use the \Drupal\Component\PluginHelper::isConfigurable() static method to determine if a plugin is configurable, rather than checking for a specific interface.

Before: if ($some_plugin instanceof ConfigurablePluginInterface) { return $plugin->getConfiguration(); }

Now: if (PluginHelper::isConfigurable($some_plugin)) { return $plugin->getConfiguration(); }

*NOTE:*For absolute maximum compatibility, a module may choose to implement both ConfigurableInterface and ConfigurablePluginInterface in Drupal 8. In the particular case where your plugin is consumed by another contrib module that is still checking against ConfigurablePluginInterface rather than PluginHelper::isConfigurable() this may be necessary for compatibility, however ConfigurablePluginInterface will be removed in Drupal 9.0.0, so the reference must be later removed for your module to be compatible with Drupal 9.

Impacts: 
Module developers