Change record status: 
Project: 
Introduced in branch: 
8.x
Description: 

Plugins that are configurable should implement \Drupal\Component\Plugin\ConfigurablePluginInterface which lets other code not only get and set configuration on the plugin, but also allows the plugin to provide default configuration through a method. This replaces several custom default value implementations in the Block and Image modules.


namespace Drupal\foo;

use \Drupal\Component\Plugin\ConfigurablePluginInterface;

class Bar implements ConfigurablePluginInterface {

  protected $configuration = array();

  /**
   * {@inheritdoc}
   */
  public function getConfiguration() {
    return $this->configuration + $this->defaultConfiguration();
  }

  /**
   * {@inheritdoc}
   */
  public function setConfiguration(array $configuration) {
    $this->configuration = $configuration;
  }

  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {
    return array(
      'foo' => 'bar',
    );
  }
}
Impacts: 
Module developers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other: 
Other updates done