Unverified Commit 71103ea3 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2852463 by mikelutz, tim.plunkett, joachim, smustgrave, heddn, irinaz,...

Issue #2852463 by mikelutz, tim.plunkett, joachim, smustgrave, heddn, irinaz, shubham.prakash, bhanu951, alexpott, megachriz, xjm, benjifisher, phenaproxima, dawehner, quietone, wim leers, bojanz: Create a trait and base class to implement \Drupal\Component\Plugin\ConfigurableInterface
parent ef776a99
Loading
Loading
Loading
Loading
Loading
+0 −48
Original line number Diff line number Diff line
@@ -1237,12 +1237,6 @@
	'count' => 1,
	'path' => __DIR__ . '/lib/Drupal/Core/Action/ActionManager.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Core\\\\Action\\\\ConfigurableActionBase\\:\\:setConfiguration\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
	'count' => 1,
	'path' => __DIR__ . '/lib/Drupal/Core/Action/ConfigurableActionBase.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Core\\\\Action\\\\ConfigurableActionBase\\:\\:validateConfigurationForm\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
@@ -3967,12 +3961,6 @@
	'count' => 1,
	'path' => __DIR__ . '/lib/Drupal/Core/Display/VariantBase.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Core\\\\Display\\\\VariantBase\\:\\:setConfiguration\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
	'count' => 1,
	'path' => __DIR__ . '/lib/Drupal/Core/Display/VariantBase.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Core\\\\Display\\\\VariantBase\\:\\:setWeight\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
@@ -5161,12 +5149,6 @@
	'count' => 1,
	'path' => __DIR__ . '/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionPluginBase.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Core\\\\Entity\\\\EntityReferenceSelection\\\\SelectionPluginBase\\:\\:setConfiguration\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
	'count' => 1,
	'path' => __DIR__ . '/lib/Drupal/Core/Entity/EntityReferenceSelection/SelectionPluginBase.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Core\\\\Entity\\\\EntityReferenceSelection\\\\SelectionPluginBase\\:\\:submitConfigurationForm\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
@@ -8539,12 +8521,6 @@
	'count' => 1,
	'path' => __DIR__ . '/lib/Drupal/Core/Layout/LayoutDefault.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Core\\\\Layout\\\\LayoutDefault\\:\\:setConfiguration\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
	'count' => 1,
	'path' => __DIR__ . '/lib/Drupal/Core/Layout/LayoutDefault.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Core\\\\Layout\\\\LayoutDefault\\:\\:setContext\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
@@ -18703,12 +18679,6 @@
	'count' => 1,
	'path' => __DIR__ . '/modules/image/src/Form/ImageStyleFormBase.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\image\\\\ImageEffectBase\\:\\:setConfiguration\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
	'count' => 1,
	'path' => __DIR__ . '/modules/image/src/ImageEffectBase.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\image\\\\ImageEffectBase\\:\\:transformDimensions\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
@@ -29054,12 +29024,6 @@
	'count' => 1,
	'path' => __DIR__ . '/modules/search/src/Plugin/Block/SearchBlock.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\search\\\\Plugin\\\\ConfigurableSearchPluginBase\\:\\:setConfiguration\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
	'count' => 1,
	'path' => __DIR__ . '/modules/search/src/Plugin/ConfigurableSearchPluginBase.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\search\\\\Plugin\\\\ConfigurableSearchPluginBase\\:\\:validateConfigurationForm\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
@@ -45578,12 +45542,6 @@
	'count' => 1,
	'path' => __DIR__ . '/modules/workflows/src/Form/WorkflowTransitionEditForm.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\workflows\\\\Plugin\\\\WorkflowTypeBase\\:\\:setConfiguration\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
	'count' => 1,
	'path' => __DIR__ . '/modules/workflows/src/Plugin/WorkflowTypeBase.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\workflows\\\\Plugin\\\\WorkflowTypeConfigureFormBase\\:\\:setPlugin\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
@@ -51587,12 +51545,6 @@
	'count' => 1,
	'path' => __DIR__ . '/tests/Drupal/Tests/Core/Plugin/FilteredPluginManagerTraitTest.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Tests\\\\Core\\\\Plugin\\\\Fixtures\\\\TestConfigurablePlugin\\:\\:setConfiguration\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
	'count' => 1,
	'path' => __DIR__ . '/tests/Drupal/Tests/Core/Plugin/Fixtures/TestConfigurablePlugin.php',
];
$ignoreErrors[] = [
	'message' => '#^Method Drupal\\\\Tests\\\\Core\\\\Plugin\\\\LazyPluginCollectionTestBase\\:\\:setupPluginCollection\\(\\) has no return type specified\\.$#',
	'identifier' => 'missingType.return',
+3 −21
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
use Drupal\Component\Plugin\ConfigurableInterface;
use Drupal\Component\Plugin\DependentPluginInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ConfigurableTrait;
use Drupal\Core\Plugin\PluginFormInterface;

/**
@@ -12,6 +13,8 @@
 */
abstract class ConfigurableActionBase extends ActionBase implements ConfigurableInterface, DependentPluginInterface, PluginFormInterface {

  use ConfigurableTrait;

  /**
   * {@inheritdoc}
   */
@@ -21,27 +24,6 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition
    $this->setConfiguration($configuration);
  }

  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {
    return [];
  }

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

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

  /**
   * {@inheritdoc}
   */
+2 −19
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@

use Drupal\Core\Cache\RefinableCacheableDependencyTrait;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\PluginBase;
use Drupal\Core\Plugin\ConfigurablePluginBase;
use Drupal\Core\Plugin\PluginDependencyTrait;
use Drupal\Core\Session\AccountInterface;

@@ -16,20 +16,11 @@
 * @see \Drupal\Core\Display\VariantManager
 * @see plugin_api
 */
abstract class VariantBase extends PluginBase implements VariantInterface {
abstract class VariantBase extends ConfigurablePluginBase implements VariantInterface {

  use PluginDependencyTrait;
  use RefinableCacheableDependencyTrait;

  /**
   * {@inheritdoc}
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);

    $this->setConfiguration($configuration);
  }

  /**
   * {@inheritdoc}
   */
@@ -74,14 +65,6 @@ public function getConfiguration() {
    ] + $this->configuration;
  }

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

  /**
   * {@inheritdoc}
   */
+2 −37
Original line number Diff line number Diff line
@@ -2,32 +2,15 @@

namespace Drupal\Core\Entity\EntityReferenceSelection;

use Drupal\Component\Plugin\ConfigurableInterface;
use Drupal\Component\Plugin\DependentPluginInterface;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Database\Query\SelectInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\PluginBase;
use Drupal\Core\Plugin\ConfigurablePluginBase;

/**
 * Provides a base class for configurable selection handlers.
 */
abstract class SelectionPluginBase extends PluginBase implements SelectionInterface, ConfigurableInterface, DependentPluginInterface {

  /**
   * Constructs a new selection object.
   *
   * @param array $configuration
   *   A configuration array containing information about the plugin instance.
   * @param string $plugin_id
   *   The plugin ID for the plugin instance.
   * @param mixed $plugin_definition
   *   The plugin implementation definition.
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->setConfiguration($configuration);
  }
abstract class SelectionPluginBase extends ConfigurablePluginBase implements SelectionInterface, DependentPluginInterface {

  /**
   * {@inheritdoc}
@@ -39,24 +22,6 @@ public function defaultConfiguration() {
    ];
  }

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

  /**
   * {@inheritdoc}
   */
  public function setConfiguration(array $configuration) {
    // Merge in defaults.
    $this->configuration = NestedArray::mergeDeep(
      $this->defaultConfiguration(),
      $configuration
    );
  }

  /**
   * {@inheritdoc}
   */
+2 −25
Original line number Diff line number Diff line
@@ -2,18 +2,17 @@

namespace Drupal\Core\Layout;

use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContextAwarePluginAssignmentTrait;
use Drupal\Core\Plugin\ContextAwarePluginTrait;
use Drupal\Core\Plugin\PluginBase;
use Drupal\Core\Plugin\ConfigurablePluginBase;
use Drupal\Core\Plugin\PluginFormInterface;
use Drupal\Core\Plugin\PreviewAwarePluginInterface;

/**
 * Provides a default class for Layout plugins.
 */
class LayoutDefault extends PluginBase implements LayoutInterface, PluginFormInterface, PreviewAwarePluginInterface {
class LayoutDefault extends ConfigurablePluginBase implements LayoutInterface, PluginFormInterface, PreviewAwarePluginInterface {

  use ContextAwarePluginAssignmentTrait;
  use ContextAwarePluginTrait;
@@ -32,14 +31,6 @@ class LayoutDefault extends PluginBase implements LayoutInterface, PluginFormInt
   */
  protected $pluginDefinition;

  /**
   * {@inheritdoc}
   */
  public function __construct(array $configuration, $plugin_id, $plugin_definition) {
    parent::__construct($configuration, $plugin_id, $plugin_definition);
    $this->setConfiguration($configuration);
  }

  /**
   * {@inheritdoc}
   */
@@ -61,20 +52,6 @@ public function build(array $regions) {
    return $build;
  }

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

  /**
   * {@inheritdoc}
   */
  public function setConfiguration(array $configuration) {
    $this->configuration = NestedArray::mergeDeep($this->defaultConfiguration(), $configuration);
  }

  /**
   * {@inheritdoc}
   */
Loading