diff --git a/core/lib/Drupal/Core/Action/ActionBag.php b/core/lib/Drupal/Core/Action/ActionBag.php deleted file mode 100644 index a8210fe..0000000 --- a/core/lib/Drupal/Core/Action/ActionBag.php +++ /dev/null @@ -1,52 +0,0 @@ -manager = $manager; - $this->instanceIDs = drupal_map_assoc($instance_ids); - $this->configuration = $configuration; - } - - /** - * {@inheritdoc} - */ - protected function initializePlugin($instance_id) { - if (isset($this->pluginInstances[$instance_id])) { - return; - } - - $this->pluginInstances[$instance_id] = $this->manager->createInstance($instance_id, $this->configuration); - } - -} diff --git a/core/lib/Drupal/Core/Action/ConfigurableActionBase.php b/core/lib/Drupal/Core/Action/ConfigurableActionBase.php index 04ca4fe..b2c389a 100644 --- a/core/lib/Drupal/Core/Action/ConfigurableActionBase.php +++ b/core/lib/Drupal/Core/Action/ConfigurableActionBase.php @@ -7,13 +7,13 @@ namespace Drupal\Core\Action; -use Drupal\Core\Action\ConfigurableActionInterface; +use Drupal\Core\Plugin\ConfigurablePluginInterface; use Drupal\Core\Action\ActionBase; /** * Provides a base implementation for a configurable Action plugin. */ -abstract class ConfigurableActionBase extends ActionBase implements ConfigurableActionInterface { +abstract class ConfigurableActionBase extends ActionBase implements ConfigurablePluginInterface { /** * {@inheritdoc} @@ -43,7 +43,7 @@ public function getConfiguration() { /** * {@inheritdoc} */ - public function validate(array &$form, array &$form_state) { + public function validateConfigurationForm(array &$form, array &$form_state) { } } diff --git a/core/lib/Drupal/Core/Action/ConfigurableActionInterface.php b/core/lib/Drupal/Core/Plugin/ConfigurablePluginInterface.php similarity index 58% rename from core/lib/Drupal/Core/Action/ConfigurableActionInterface.php rename to core/lib/Drupal/Core/Plugin/ConfigurablePluginInterface.php index c0a66a9..ec5519b 100644 --- a/core/lib/Drupal/Core/Action/ConfigurableActionInterface.php +++ b/core/lib/Drupal/Core/Plugin/ConfigurablePluginInterface.php @@ -2,26 +2,22 @@ /** * @file - * Contains \Drupal\Core\Action\ConfigurableActionInterface. + * Contains \Drupal\Core\Plugin\ConfigurablePluginInterface. */ -namespace Drupal\Core\Action; +namespace Drupal\Core\Plugin; -use Drupal\Core\Action\ActionInterface; /** - * Provides an interface for an Action plugin. - * - * @see \Drupal\Core\Annotation\Operation - * @see \Drupal\Core\Action\OperationManager + * Provides an interface for a configurable plugin. */ -interface ConfigurableActionInterface extends ActionInterface { +interface ConfigurablePluginInterface { /** * Returns this plugin's configuration. * * @return array - * An array of this action plugin's configuration. + * An array of this plugin's configuration. */ public function getConfiguration(); @@ -36,7 +32,7 @@ public function getConfiguration(); * @return array * The form structure. */ - public function form(array $form, array &$form_state); + public function buildConfigurationForm(array $form, array &$form_state); /** * Form validation handler. @@ -46,16 +42,21 @@ public function form(array $form, array &$form_state); * @param array $form_state * An associative array containing the current state of the form. */ - public function validate(array &$form, array &$form_state); + public function validateConfigurationForm(array &$form, array &$form_state); /** * Form submission handler. * + * To properly store submitted form values store them in $this->configuration. + * @code + * $this->configuration['some_value'] = $form_state['values']['some_value']; + * @endcode + * * @param array $form * An associative array containing the structure of the form. * @param array $form_state * An associative array containing the current state of the form. */ - public function submit(array &$form, array &$form_state); + public function submitConfigurationForm(array &$form, array &$form_state); } diff --git a/core/lib/Drupal/Core/Plugin/DefaultSinglePluginBag.php b/core/lib/Drupal/Core/Plugin/DefaultSinglePluginBag.php new file mode 100644 index 0000000..561dc99 --- /dev/null +++ b/core/lib/Drupal/Core/Plugin/DefaultSinglePluginBag.php @@ -0,0 +1,63 @@ +manager = $manager; + $this->instanceIDs = drupal_map_assoc($instance_ids); + $this->configuration = $configuration; + } + + /** + * {@inheritdoc} + */ + protected function initializePlugin($instance_id) { + if (!isset($this->pluginInstances[$instance_id])) { + $this->pluginInstances[$instance_id] = $this->manager->createInstance($instance_id, $this->configuration); + } + } + +} diff --git a/core/modules/action/lib/Drupal/action/ActionFormControllerBase.php b/core/modules/action/lib/Drupal/action/ActionFormControllerBase.php index ff48164..3655e7b 100644 --- a/core/modules/action/lib/Drupal/action/ActionFormControllerBase.php +++ b/core/modules/action/lib/Drupal/action/ActionFormControllerBase.php @@ -10,7 +10,7 @@ use Drupal\Core\Entity\EntityControllerInterface; use Drupal\Core\Entity\EntityFormController; use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\Core\Action\ConfigurableActionInterface; +use Drupal\Core\Plugin\ConfigurablePluginInterface; use Drupal\Core\Entity\EntityStorageControllerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -97,8 +97,8 @@ public function form(array $form, array &$form_state) { '#value' => $this->entity->getType(), ); - if ($this->plugin instanceof ConfigurableActionInterface) { - $form += $this->plugin->form($form, $form_state); + if ($this->plugin instanceof ConfigurablePluginInterface) { + $form += $this->plugin->buildConfigurationForm($form, $form_state); } return parent::form($form, $form_state); @@ -133,8 +133,8 @@ protected function actions(array $form, array &$form_state) { public function validate(array $form, array &$form_state) { parent::validate($form, $form_state); - if ($this->plugin instanceof ConfigurableActionInterface) { - $this->plugin->validate($form, $form_state); + if ($this->plugin instanceof ConfigurablePluginInterface) { + $this->plugin->validateConfigurationForm($form, $form_state); } } @@ -144,8 +144,8 @@ public function validate(array $form, array &$form_state) { public function submit(array $form, array &$form_state) { parent::submit($form, $form_state); - if ($this->plugin instanceof ConfigurableActionInterface) { - $this->plugin->submit($form, $form_state); + if ($this->plugin instanceof ConfigurablePluginInterface) { + $this->plugin->submitConfigurationForm($form, $form_state); } return $this->entity; } diff --git a/core/modules/action/lib/Drupal/action/Form/ActionAdminManageForm.php b/core/modules/action/lib/Drupal/action/Form/ActionAdminManageForm.php index d0244b1..3fbdda7 100644 --- a/core/modules/action/lib/Drupal/action/Form/ActionAdminManageForm.php +++ b/core/modules/action/lib/Drupal/action/Form/ActionAdminManageForm.php @@ -57,7 +57,7 @@ public function getFormID() { public function buildForm(array $form, array &$form_state) { $actions = array(); foreach ($this->manager->getDefinitions() as $id => $definition) { - if (is_subclass_of($definition['class'], '\Drupal\Core\Action\ConfigurableActionInterface')) { + if (is_subclass_of($definition['class'], '\Drupal\Core\Plugin\ConfigurablePluginInterface')) { $key = Crypt::hashBase64($id); $actions[$key] = $definition['label'] . '...'; } diff --git a/core/modules/action/lib/Drupal/action/Plugin/Action/EmailAction.php b/core/modules/action/lib/Drupal/action/Plugin/Action/EmailAction.php index 43908b0..77e5f21 100644 --- a/core/modules/action/lib/Drupal/action/Plugin/Action/EmailAction.php +++ b/core/modules/action/lib/Drupal/action/Plugin/Action/EmailAction.php @@ -116,7 +116,7 @@ protected function getDefaultConfiguration() { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, array &$form_state) { $form['recipient'] = array( '#type' => 'textfield', '#title' => t('Recipient'), @@ -145,7 +145,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validate(array &$form, array &$form_state) { + public function validateConfigurationForm(array &$form, array &$form_state) { if (!valid_email_address($form_state['values']['recipient']) && strpos($form_state['values']['recipient'], ':mail') === FALSE) { // We want the literal %author placeholder to be emphasized in the error message. form_set_error('recipient', t('Enter a valid email address or use a token e-mail address such as %author.', array('%author' => '[node:author:mail]'))); @@ -155,7 +155,7 @@ public function validate(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array &$form, array &$form_state) { + public function submitConfigurationForm(array &$form, array &$form_state) { $this->configuration['recipient'] = $form_state['values']['recipient']; $this->configuration['subject'] = $form_state['values']['subject']; $this->configuration['message'] = $form_state['values']['message']; diff --git a/core/modules/action/lib/Drupal/action/Plugin/Action/GotoAction.php b/core/modules/action/lib/Drupal/action/Plugin/Action/GotoAction.php index 93a4c87..fd158fb 100644 --- a/core/modules/action/lib/Drupal/action/Plugin/Action/GotoAction.php +++ b/core/modules/action/lib/Drupal/action/Plugin/Action/GotoAction.php @@ -96,7 +96,7 @@ protected function getDefaultConfiguration() { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, array &$form_state) { $form['url'] = array( '#type' => 'textfield', '#title' => t('URL'), @@ -110,7 +110,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array &$form, array &$form_state) { + public function submitConfigurationForm(array &$form, array &$form_state) { $this->configuration['url'] = $form_state['values']['url']; } diff --git a/core/modules/action/lib/Drupal/action/Plugin/Action/MessageAction.php b/core/modules/action/lib/Drupal/action/Plugin/Action/MessageAction.php index b7f25a2..fef9ab9 100644 --- a/core/modules/action/lib/Drupal/action/Plugin/Action/MessageAction.php +++ b/core/modules/action/lib/Drupal/action/Plugin/Action/MessageAction.php @@ -70,7 +70,7 @@ protected function getDefaultConfiguration() { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, array &$form_state) { $form['message'] = array( '#type' => 'textarea', '#title' => t('Message'), @@ -85,7 +85,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array &$form, array &$form_state) { + public function submitConfigurationForm(array &$form, array &$form_state) { $this->configuration['message'] = $form_state['values']['message']; unset($this->configuration['node']); } diff --git a/core/modules/block/lib/Drupal/block/BlockBase.php b/core/modules/block/lib/Drupal/block/BlockBase.php index b438dc1..05a90a8 100644 --- a/core/modules/block/lib/Drupal/block/BlockBase.php +++ b/core/modules/block/lib/Drupal/block/BlockBase.php @@ -61,7 +61,7 @@ public function settings() { * * @see \Drupal\Component\Plugin\PluginBase::$configuration */ - public function getConfig() { + public function getConfiguration() { return $this->configuration; } @@ -102,7 +102,7 @@ public function access() { } /** - * Implements \Drupal\block\BlockPluginInterface::form(). + * {@inheritdoc} * * Creates a generic configuration form for all block types. Individual * block plugins can add elements to this form by overriding @@ -111,7 +111,7 @@ public function access() { * * @see \Drupal\block\BlockBase::blockForm() */ - public function form($form, &$form_state) { + public function buildConfigurationForm(array $form, array &$form_state) { $definition = $this->getPluginDefinition(); $form['module'] = array( '#type' => 'value', @@ -151,14 +151,14 @@ public function form($form, &$form_state) { * @return array $form * The renderable form array representing the entire configuration form. * - * @see \Drupal\block\BlockBase::form() + * @see \Drupal\block\BlockBase::buildConfigurationForm() */ public function blockForm($form, &$form_state) { return array(); } /** - * Implements \Drupal\block\BlockPluginInterface::validate(). + * {@inheritdoc} * * Most block plugins should not override this method. To add validation * for a specific block type, override BlockBase::blockValdiate(). @@ -167,7 +167,7 @@ public function blockForm($form, &$form_state) { * * @see \Drupal\block\BlockBase::blockValidate() */ - public function validate($form, &$form_state) { + public function validateConfigurationForm(array &$form, array &$form_state) { $this->blockValidate($form, $form_state); } @@ -185,12 +185,12 @@ public function validate($form, &$form_state) { * * @see \Drupal\block\BlockBase::blockForm() * @see \Drupal\block\BlockBase::blockSubmit() - * @see \Drupal\block\BlockBase::validate() + * @see \Drupal\block\BlockBase::validateConfigurationForm() */ public function blockValidate($form, &$form_state) {} /** - * Implements \Drupal\block\BlockPluginInterface::submit(). + * {@inheritdoc} * * Most block plugins should not override this method. To add submission * handling for a specific block type, override BlockBase::blockSubmit(). @@ -199,7 +199,7 @@ public function blockValidate($form, &$form_state) {} * * @see \Drupal\block\BlockBase::blockSubmit() */ - public function submit($form, &$form_state) { + public function submitConfigurationForm(array &$form, array &$form_state) { if (!form_get_errors()) { $this->configuration['label'] = $form_state['values']['label']; $this->configuration['label_display'] = $form_state['values']['label_display']; @@ -222,7 +222,7 @@ public function submit($form, &$form_state) { * * @see \Drupal\block\BlockBase::blockForm() * @see \Drupal\block\BlockBase::blockValidate() - * @see \Drupal\block\BlockBase::submit() + * @see \Drupal\block\BlockBase::submitConfigurationForm() */ public function blockSubmit($form, &$form_state) {} } diff --git a/core/modules/block/lib/Drupal/block/BlockFormController.php b/core/modules/block/lib/Drupal/block/BlockFormController.php index f562a68..7789c02 100644 --- a/core/modules/block/lib/Drupal/block/BlockFormController.php +++ b/core/modules/block/lib/Drupal/block/BlockFormController.php @@ -25,7 +25,7 @@ public function form(array $form, array &$form_state) { '#type' => 'value', '#value' => $entity->id(), ); - $form['settings'] = $entity->getPlugin()->form(array(), $form_state); + $form['settings'] = $entity->getPlugin()->buildConfigurationForm(array(), $form_state); $form['machine_name'] = array( '#type' => 'machine_name', @@ -208,7 +208,7 @@ public function validate(array $form, array &$form_state) { 'values' => &$form_state['values']['settings'] ); // Call the plugin validate handler. - $entity->getPlugin()->validate($form, $settings); + $entity->getPlugin()->validateConfigurationForm($form, $settings); } /** @@ -224,7 +224,7 @@ public function submit(array $form, array &$form_state) { 'values' => &$form_state['values']['settings'] ); // Call the plugin submit handler. - $entity->getPlugin()->submit($form, $settings); + $entity->getPlugin()->submitConfigurationForm($form, $settings); // Save the settings of the plugin. $entity->save(); diff --git a/core/modules/block/lib/Drupal/block/BlockPluginBag.php b/core/modules/block/lib/Drupal/block/BlockPluginBag.php index 5a68beb..3bdb911 100644 --- a/core/modules/block/lib/Drupal/block/BlockPluginBag.php +++ b/core/modules/block/lib/Drupal/block/BlockPluginBag.php @@ -7,38 +7,30 @@ namespace Drupal\block; -use Drupal\block\Plugin\Core\Entity\Block; -use Drupal\Component\Plugin\PluginBag; -use Drupal\Component\Plugin\PluginManagerInterface; use Drupal\Component\Plugin\Exception\PluginException; +use Drupal\Component\Plugin\PluginManagerInterface; +use Drupal\Component\Utility\String; +use Drupal\Core\Plugin\DefaultSinglePluginBag; /** * Provides a collection of block plugins. */ -class BlockPluginBag extends PluginBag { +class BlockPluginBag extends DefaultSinglePluginBag { /** - * The manager used to instantiate the plugins. + * The block ID this plugin bag belongs to. * - * @var \Drupal\Component\Plugin\PluginManagerInterface + * @var string */ - protected $manager; + protected $blockId; /** - * Constructs a BlockPluginBag object. - * - * @param \Drupal\Component\Plugin\PluginManagerInterface $manager - * The manager to be used for instantiating plugins. - * @param array $instance_ids - * The ids of the plugin instances with which we are dealing. - * @param \Drupal\block\Plugin\Core\Entity\Block $entity - * The Block entity that holds our configuration. + * {@inheritdoc} */ - public function __construct(PluginManagerInterface $manager, array $instance_ids, Block $entity) { - $this->manager = $manager; - $this->entity = $entity; + public function __construct(PluginManagerInterface $manager, array $instance_ids, array $configuration, $block_id) { + parent::__construct($manager, $instance_ids, $configuration); - $this->instanceIDs = drupal_map_assoc($instance_ids); + $this->blockId = $block_id; } /** @@ -46,18 +38,14 @@ public function __construct(PluginManagerInterface $manager, array $instance_ids */ protected function initializePlugin($instance_id) { if (!$instance_id) { - throw new PluginException(format_string("The block '@block' did not specify a plugin.", array('@block' => $this->entity->id()))); - } - if (isset($this->pluginInstances[$instance_id])) { - return; + throw new PluginException(String::format("The block '@block' did not specify a plugin.", array('@block' => $this->blockId))); } - $settings = $this->entity->get('settings'); try { - $this->pluginInstances[$instance_id] = $this->manager->createInstance($instance_id, $settings); + parent::initializePlugin($instance_id); } catch (PluginException $e) { - $module = $settings['module']; + $module = $this->configuration['module']; // Ignore blocks belonging to disabled modules, but re-throw valid // exceptions when the module is enabled and the plugin is misconfigured. if (!$module || \Drupal::moduleHandler()->moduleExists($module)) { diff --git a/core/modules/block/lib/Drupal/block/BlockPluginInterface.php b/core/modules/block/lib/Drupal/block/BlockPluginInterface.php index 1887816..9706763 100644 --- a/core/modules/block/lib/Drupal/block/BlockPluginInterface.php +++ b/core/modules/block/lib/Drupal/block/BlockPluginInterface.php @@ -7,6 +7,8 @@ namespace Drupal\block; +use Drupal\Core\Plugin\ConfigurablePluginInterface; + /** * Defines the required interface for all block plugins. * @@ -17,7 +19,7 @@ * * @see \Drupal\block\BlockBase */ -interface BlockPluginInterface { +interface BlockPluginInterface extends ConfigurablePluginInterface { /** * Returns the default settings for this block plugin. @@ -45,54 +47,6 @@ public function settings(); public function access(); /** - * Constructs the block configuration form. - * - * This method allows base implementations to add a generic configuration - * form for extending block plugins. - * - * @param array $form - * The form definition array for the block configuration form. - * @param array $form_state - * An array containing the current state of the configuration form. - * - * @return array $form - * The renderable form array representing the entire configuration form. - * - * @see \Drupal\block\BlockFormController::form() - * @see \Drupal\block\BlockInterace::validate() - * @see \Drupal\block\BlockInterace::submit() - */ - public function form($form, &$form_state); - - /** - * Handles form validation for the block configuration form. - * - * @param array $form - * The form definition array for the block configuration form. - * @param array $form_state - * An array containing the current state of the configuration form. - * - * @see \Drupal\block\BlockFormController::validate() - * @see \Drupal\block\BlockInterace::form() - * @see \Drupal\block\BlockInterace::submit() - */ - public function validate($form, &$form_state); - - /** - * Handles form submissions for the block configuration form. - * - * @param array $form - * The form definition array for the block configuration form. - * @param array $form_state - * An array containing the current state of the configuration form. - * - * @see \Drupal\block\BlockFormController::submit() - * @see \Drupal\block\BlockInterace::form() - * @see \Drupal\block\BlockInterace::validate() - */ - public function submit($form, &$form_state); - - /** * Builds and returns the renderable array for this block plugin. * * @return array diff --git a/core/modules/block/lib/Drupal/block/BlockRenderController.php b/core/modules/block/lib/Drupal/block/BlockRenderController.php index 45a85d9..57a5d62 100644 --- a/core/modules/block/lib/Drupal/block/BlockRenderController.php +++ b/core/modules/block/lib/Drupal/block/BlockRenderController.php @@ -40,7 +40,7 @@ public function viewMultiple(array $entities = array(), $view_mode = 'full', $la $plugin_id = $plugin->getPluginId(); if ($content = $plugin->build()) { - $configuration = $plugin->getConfig(); + $configuration = $plugin->getConfiguration(); $build[$entity_id] = array( '#theme' => 'block', 'content' => $content, diff --git a/core/modules/block/lib/Drupal/block/Plugin/Core/Entity/Block.php b/core/modules/block/lib/Drupal/block/Plugin/Core/Entity/Block.php index 1d3cca8..bb3a1d4 100644 --- a/core/modules/block/lib/Drupal/block/Plugin/Core/Entity/Block.php +++ b/core/modules/block/lib/Drupal/block/Plugin/Core/Entity/Block.php @@ -105,7 +105,7 @@ class Block extends ConfigEntityBase implements BlockInterface { public function __construct(array $values, $entity_type) { parent::__construct($values, $entity_type); - $this->pluginBag = new BlockPluginBag(\Drupal::service('plugin.manager.block'), array($this->plugin), $this); + $this->pluginBag = new BlockPluginBag(\Drupal::service('plugin.manager.block'), array($this->plugin), $this->get('settings'), $this->id()); } /** @@ -169,7 +169,7 @@ public function getExportProperties() { * {@inheritdoc} */ public function preSave(EntityStorageControllerInterface $storage_controller) { - $this->set('settings', $this->getPlugin()->getConfig()); + $this->set('settings', $this->getPlugin()->getConfiguration()); } } diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockInterfaceTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockInterfaceTest.php index 327cf45..b3093d9 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockInterfaceTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockInterfaceTest.php @@ -52,12 +52,12 @@ public function testBlockInterface() { ); // Initial configuration of the block at construction time. $display_block = $manager->createInstance('test_block_instantiation', $configuration); - $this->assertIdentical($display_block->getConfig(), $expected_configuration, 'The block was configured correctly.'); + $this->assertIdentical($display_block->getConfiguration(), $expected_configuration, 'The block was configured correctly.'); // Updating an element of the configuration. $display_block->setConfig('display_message', 'My custom display message.'); $expected_configuration['display_message'] = 'My custom display message.'; - $this->assertIdentical($display_block->getConfig(), $expected_configuration, 'The block configuration was updated correctly.'); + $this->assertIdentical($display_block->getConfiguration(), $expected_configuration, 'The block configuration was updated correctly.'); $expected_form = array( 'module' => array( @@ -85,7 +85,7 @@ public function testBlockInterface() { ); $form_state = array(); // Ensure there are no form elements that do not belong to the plugin. - $this->assertIdentical($display_block->form(array(), $form_state), $expected_form, 'Only the expected form elements were present.'); + $this->assertIdentical($display_block->buildConfigurationForm(array(), $form_state), $expected_form, 'Only the expected form elements were present.'); $expected_build = array( '#children' => 'My custom display message.', diff --git a/core/modules/block/lib/Drupal/block/Tests/BlockTemplateSuggestionsUnitTest.php b/core/modules/block/lib/Drupal/block/Tests/BlockTemplateSuggestionsUnitTest.php index 51630ba..3042b5b 100644 --- a/core/modules/block/lib/Drupal/block/Tests/BlockTemplateSuggestionsUnitTest.php +++ b/core/modules/block/lib/Drupal/block/Tests/BlockTemplateSuggestionsUnitTest.php @@ -45,7 +45,7 @@ function testBlockThemeHookSuggestions() { $variables = array(); $variables['elements']['#block'] = $block; - $variables['elements']['#configuration'] = $block->getPlugin()->getConfig(); + $variables['elements']['#configuration'] = $block->getPlugin()->getConfiguration(); $variables['elements']['#plugin_id'] = $block->get('plugin'); $variables['elements']['content'] = array(); // Test adding a class to the block content. diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/Action/UnpublishByKeywordComment.php b/core/modules/comment/lib/Drupal/comment/Plugin/Action/UnpublishByKeywordComment.php index d123cfc..d669db4 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/Action/UnpublishByKeywordComment.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/Action/UnpublishByKeywordComment.php @@ -49,7 +49,7 @@ protected function getDefaultConfiguration() { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, array &$form_state) { $form['keywords'] = array( '#title' => t('Keywords'), '#type' => 'textarea', @@ -62,7 +62,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array &$form, array &$form_state) { + public function submitConfigurationForm(array &$form, array &$form_state) { $this->configuration['keywords'] = drupal_explode_tags($form_state['values']['keywords']); } diff --git a/core/modules/node/lib/Drupal/node/Plugin/Action/AssignOwnerNode.php b/core/modules/node/lib/Drupal/node/Plugin/Action/AssignOwnerNode.php index 76bc6d6..59255e2 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/Action/AssignOwnerNode.php +++ b/core/modules/node/lib/Drupal/node/Plugin/Action/AssignOwnerNode.php @@ -79,7 +79,7 @@ protected function getDefaultConfiguration() { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, array &$form_state) { $description = t('The username of the user to which you would like to assign ownership.'); $count = $this->connection->query("SELECT COUNT(*) FROM {users}")->fetchField(); $owner_name = ''; @@ -119,7 +119,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validate(array &$form, array &$form_state) { + public function validateConfigurationForm(array &$form, array &$form_state) { $exists = (bool) $this->connection->queryRange('SELECT 1 FROM {users} WHERE name = :name', 0, 1, array(':name' => $form_state['values']['owner_name']))->fetchField(); if (!$exists) { form_set_error('owner_name', t('Enter a valid username.')); @@ -129,7 +129,7 @@ public function validate(array &$form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array &$form, array &$form_state) { + public function submitConfigurationForm(array &$form, array &$form_state) { $this->configuration['owner_uid'] = $this->connection->query('SELECT uid from {users} WHERE name = :name', array(':name' => $form_state['values']['owner_name']))->fetchField(); } diff --git a/core/modules/node/lib/Drupal/node/Plugin/Action/UnpublishByKeywordNode.php b/core/modules/node/lib/Drupal/node/Plugin/Action/UnpublishByKeywordNode.php index 2d0f4ed..2ad65f8 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/Action/UnpublishByKeywordNode.php +++ b/core/modules/node/lib/Drupal/node/Plugin/Action/UnpublishByKeywordNode.php @@ -48,7 +48,7 @@ protected function getDefaultConfiguration() { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, array &$form_state) { $form['keywords'] = array( '#title' => t('Keywords'), '#type' => 'textarea', @@ -61,7 +61,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array &$form, array &$form_state) { + public function submitConfigurationForm(array &$form, array &$form_state) { $this->configuration['keywords'] = drupal_explode_tags($form_state['values']['keywords']); } diff --git a/core/modules/system/lib/Drupal/system/Plugin/Core/Entity/Action.php b/core/modules/system/lib/Drupal/system/Plugin/Core/Entity/Action.php index fe8f537..d50b68e 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/Core/Entity/Action.php +++ b/core/modules/system/lib/Drupal/system/Plugin/Core/Entity/Action.php @@ -11,9 +11,9 @@ use Drupal\Core\Entity\Annotation\EntityType; use Drupal\Core\Annotation\Translation; use Drupal\Core\Entity\EntityStorageControllerInterface; +use Drupal\Core\Plugin\DefaultSinglePluginBag; use Drupal\system\ActionConfigEntityInterface; -use Drupal\Core\Action\ActionBag; -use Drupal\Core\Action\ConfigurableActionInterface; +use Drupal\Core\Plugin\ConfigurablePluginInterface; /** * Defines the configured action entity. @@ -81,7 +81,7 @@ class Action extends ConfigEntityBase implements ActionConfigEntityInterface { /** * The plugin bag that stores action plugins. * - * @var \Drupal\Core\Action\ActionBag + * @var \Drupal\Core\Plugin\DefaultSinglePluginBag */ protected $pluginBag; @@ -91,7 +91,7 @@ class Action extends ConfigEntityBase implements ActionConfigEntityInterface { public function __construct(array $values, $entity_type) { parent::__construct($values, $entity_type); - $this->pluginBag = new ActionBag(\Drupal::service('plugin.manager.action'), array($this->plugin), $this->configuration); + $this->pluginBag = new DefaultSinglePluginBag(\Drupal::service('plugin.manager.action'), array($this->plugin), $this->configuration); } /** @@ -127,7 +127,7 @@ public function execute(array $entities) { * {@inheritdoc} */ public function isConfigurable() { - return $this->getPlugin() instanceof ConfigurableActionInterface; + return $this->getPlugin() instanceof ConfigurablePluginInterface; } /** @@ -184,7 +184,7 @@ public function getExportProperties() { public function preSave(EntityStorageControllerInterface $storage_controller) { $plugin = $this->getPlugin(); // If this plugin has any configuration, ensure that it is set. - if ($plugin instanceof ConfigurableActionInterface) { + if ($plugin instanceof ConfigurablePluginInterface) { $this->set('configuration', $plugin->getConfiguration()); } } diff --git a/core/modules/user/lib/Drupal/user/Plugin/Action/ChangeUserRoleBase.php b/core/modules/user/lib/Drupal/user/Plugin/Action/ChangeUserRoleBase.php index 9dfb056..079f066 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/Action/ChangeUserRoleBase.php +++ b/core/modules/user/lib/Drupal/user/Plugin/Action/ChangeUserRoleBase.php @@ -26,7 +26,7 @@ protected function getDefaultConfiguration() { /** * {@inheritdoc} */ - public function form(array $form, array &$form_state) { + public function buildConfigurationForm(array $form, array &$form_state) { $roles = user_role_names(TRUE); unset($roles[DRUPAL_AUTHENTICATED_RID]); $form['rid'] = array( @@ -42,7 +42,7 @@ public function form(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function submit(array &$form, array &$form_state) { + public function submitConfigurationForm(array &$form, array &$form_state) { $this->configuration['rid'] = $form_state['values']['rid']; } diff --git a/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php b/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php index 8a0c919..d36f2bf 100644 --- a/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php +++ b/core/modules/views/lib/Drupal/views/Plugin/Block/ViewsBlock.php @@ -61,8 +61,8 @@ public function access() { /** * Overrides \Drupal\block\BlockBase::form(). */ - public function form($form, &$form_state) { - $form = parent::form($form, $form_state); + public function buildConfigurationForm(array $form, array &$form_state) { + $form = parent::buildConfigurationForm($form, $form_state); // Set the default label to '' so the views internal title is used. $form['label']['#default_value'] = '';