Issue #2062573 by claudiu.cristea, tim.plunkett, Xano: Change notice: Add method defaultConfiguration() in ConfigurablePluginInterface.
parent
935013e9ae
commit
c435ef8d2b
|
@ -28,4 +28,12 @@ interface ConfigurablePluginInterface {
|
|||
*/
|
||||
public function setConfiguration(array $configuration);
|
||||
|
||||
/**
|
||||
* Returns default configuration for this plugin.
|
||||
*
|
||||
* @return array
|
||||
* An associative array with the default configuration.
|
||||
*/
|
||||
public function defaultConfiguration();
|
||||
|
||||
}
|
||||
|
|
|
@ -22,15 +22,13 @@ abstract class ConfigurableActionBase extends ActionBase implements Configurable
|
|||
public function __construct(array $configuration, $plugin_id, array $plugin_definition) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
|
||||
$this->configuration += $this->getDefaultConfiguration();
|
||||
$this->configuration += $this->defaultConfiguration();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns default configuration for this action.
|
||||
*
|
||||
* @return array
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getDefaultConfiguration() {
|
||||
public function defaultConfiguration() {
|
||||
return array();
|
||||
}
|
||||
|
||||
|
|
|
@ -105,7 +105,7 @@ class EmailAction extends ConfigurableActionBase implements ContainerFactoryPlug
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getDefaultConfiguration() {
|
||||
public function defaultConfiguration() {
|
||||
return array(
|
||||
'recipient' => '',
|
||||
'subject' => '',
|
||||
|
|
|
@ -87,7 +87,7 @@ class GotoAction extends ConfigurableActionBase implements ContainerFactoryPlugi
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getDefaultConfiguration() {
|
||||
public function defaultConfiguration() {
|
||||
return array(
|
||||
'url' => '',
|
||||
);
|
||||
|
|
|
@ -61,7 +61,7 @@ class MessageAction extends ConfigurableActionBase implements ContainerFactoryPl
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getDefaultConfiguration() {
|
||||
public function defaultConfiguration() {
|
||||
return array(
|
||||
'message' => '',
|
||||
);
|
||||
|
|
|
@ -16,6 +16,13 @@ use Drupal\Core\Plugin\PluginFormInterface;
|
|||
*/
|
||||
abstract class AggregatorPluginSettingsBase extends PluginBase implements PluginFormInterface, ConfigurablePluginInterface {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function defaultConfiguration() {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
@ -23,9 +23,9 @@ use Drupal\Core\Annotation\Translation;
|
|||
class AggregatorCategoryBlock extends BlockBase {
|
||||
|
||||
/**
|
||||
* Overrides \Drupal\block\BlockBase::settings().
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function settings() {
|
||||
public function defaultConfiguration() {
|
||||
// By default, the block will contain 10 feed items.
|
||||
return array(
|
||||
'block_count' => 10,
|
||||
|
|
|
@ -23,9 +23,9 @@ use Drupal\Core\Annotation\Translation;
|
|||
class AggregatorFeedBlock extends BlockBase {
|
||||
|
||||
/**
|
||||
* Overrides \Drupal\block\BlockBase::settings().
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function settings() {
|
||||
public function defaultConfiguration() {
|
||||
// By default, the block will contain 10 feed items.
|
||||
return array(
|
||||
'block_count' => 10,
|
||||
|
|
|
@ -75,9 +75,9 @@ class CustomBlockBlock extends BlockBase implements ContainerFactoryPluginInterf
|
|||
}
|
||||
|
||||
/**
|
||||
* Overrides \Drupal\block\BlockBase::settings().
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function settings() {
|
||||
public function defaultConfiguration() {
|
||||
return array(
|
||||
'status' => TRUE,
|
||||
'info' => '',
|
||||
|
|
|
@ -27,7 +27,7 @@ abstract class BlockBase extends PluginBase implements BlockPluginInterface {
|
|||
public function __construct(array $configuration, $plugin_id, array $plugin_definition) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition);
|
||||
|
||||
$this->configuration += $this->settings() + array(
|
||||
$this->configuration += $this->defaultConfiguration() + array(
|
||||
'label' => '',
|
||||
'module' => $plugin_definition['module'],
|
||||
'label_display' => BlockInterface::BLOCK_LABEL_VISIBLE,
|
||||
|
@ -35,22 +35,6 @@ abstract class BlockBase extends PluginBase implements BlockPluginInterface {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns plugin-specific settings for the block.
|
||||
*
|
||||
* Block plugins only need to override this method if they override the
|
||||
* defaults provided in BlockBase::settings().
|
||||
*
|
||||
* @return array
|
||||
* An array of block-specific settings to override the defaults provided in
|
||||
* BlockBase::settings().
|
||||
*
|
||||
* @see \Drupal\block\BlockBase::settings().
|
||||
*/
|
||||
public function settings() {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -65,6 +49,13 @@ abstract class BlockBase extends PluginBase implements BlockPluginInterface {
|
|||
$this->configuration = $configuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function defaultConfiguration() {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
@ -21,18 +21,6 @@ use Drupal\Core\Plugin\PluginFormInterface;
|
|||
*/
|
||||
interface BlockPluginInterface extends ConfigurablePluginInterface, PluginFormInterface, PluginInspectionInterface {
|
||||
|
||||
/**
|
||||
* Returns the default settings for this block plugin.
|
||||
*
|
||||
* @return array
|
||||
* An associative array of block settings for this block, keyed by the
|
||||
* setting name.
|
||||
*
|
||||
* @todo Consider merging this with the general plugin configuration member
|
||||
* variable and its getter/setter in http://drupal.org/node/1764380.
|
||||
*/
|
||||
public function settings();
|
||||
|
||||
/**
|
||||
* Indicates whether the block should be shown.
|
||||
*
|
||||
|
|
|
@ -69,7 +69,7 @@ class Block extends DisplayPluginBase {
|
|||
* An array of block-specific settings to override the defaults provided in
|
||||
* \Drupal\views\Plugin\Block\ViewsBlock::settings().
|
||||
*
|
||||
* @see \Drupal\views\Plugin\Block\ViewsBlock::settings().
|
||||
* @see \Drupal\views\Plugin\Block\ViewsBlock::defaultConfiguration()
|
||||
*/
|
||||
public function blockSettings(array $settings) {
|
||||
$settings['items_per_page'] = 'none';
|
||||
|
|
|
@ -24,7 +24,7 @@ class TestBlockInstantiation extends BlockBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function settings() {
|
||||
public function defaultConfiguration() {
|
||||
return array(
|
||||
'display_message' => 'no message set',
|
||||
);
|
||||
|
|
|
@ -22,11 +22,11 @@ use Drupal\Core\Annotation\Translation;
|
|||
class TestCacheBlock extends BlockBase {
|
||||
|
||||
/**
|
||||
* Overrides \Drupal\block\BlockBase::settings().
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Sets a different caching strategy for testing purposes.
|
||||
*/
|
||||
public function settings() {
|
||||
public function defaultConfiguration() {
|
||||
return array(
|
||||
'cache' => DRUPAL_CACHE_PER_ROLE,
|
||||
);
|
||||
|
|
|
@ -20,11 +20,11 @@ use Drupal\block\Annotation\Block;
|
|||
class TestXSSTitleBlock extends TestCacheBlock {
|
||||
|
||||
/**
|
||||
* Overrides \Drupal\block\BlockBase::settings().
|
||||
* {@inheritdoc}
|
||||
*
|
||||
* Sets a different caching strategy for testing purposes.
|
||||
*/
|
||||
public function settings() {
|
||||
public function defaultConfiguration() {
|
||||
return array(
|
||||
'cache' => DRUPAL_NO_CACHE,
|
||||
);
|
||||
|
|
|
@ -22,9 +22,9 @@ use Drupal\Core\Annotation\Translation;
|
|||
class BookNavigationBlock extends BlockBase {
|
||||
|
||||
/**
|
||||
* Overrides \Drupal\block\BlockBase::settings().
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function settings() {
|
||||
public function defaultConfiguration() {
|
||||
return array(
|
||||
'cache' => DRUPAL_CACHE_PER_PAGE | DRUPAL_CACHE_PER_ROLE,
|
||||
'block_mode' => "all pages",
|
||||
|
|
|
@ -40,7 +40,7 @@ class UnpublishByKeywordComment extends ConfigurableActionBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getDefaultConfiguration() {
|
||||
public function defaultConfiguration() {
|
||||
return array(
|
||||
'keywords' => array(),
|
||||
);
|
||||
|
|
|
@ -22,9 +22,9 @@ use Drupal\Core\Annotation\Translation;
|
|||
class RecentCommentsBlock extends BlockBase {
|
||||
|
||||
/**
|
||||
* Overrides \Drupal\block\BlockBase::settings().
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function settings() {
|
||||
public function defaultConfiguration() {
|
||||
return array(
|
||||
'block_count' => 10,
|
||||
);
|
||||
|
|
|
@ -106,6 +106,13 @@ abstract class FilterBase extends PluginBase implements FilterInterface {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function defaultConfiguration() {
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
@ -15,9 +15,9 @@ use Drupal\block\BlockBase;
|
|||
abstract class ForumBlockBase extends BlockBase {
|
||||
|
||||
/**
|
||||
* Overrides \Drupal\block\BlockBase::settings().
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function settings() {
|
||||
public function defaultConfiguration() {
|
||||
return array(
|
||||
'cache' => DRUPAL_CACHE_CUSTOM,
|
||||
'properties' => array(
|
||||
|
|
|
@ -103,10 +103,17 @@ abstract class ImageEffectBase extends PluginBase implements ImageEffectInterfac
|
|||
'uuid' => '',
|
||||
'weight' => '',
|
||||
);
|
||||
$this->configuration = $configuration['data'];
|
||||
$this->configuration = $configuration['data'] + $this->defaultConfiguration();
|
||||
$this->uuid = $configuration['uuid'];
|
||||
$this->weight = $configuration['weight'];
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function defaultConfiguration() {
|
||||
return array();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,11 +26,6 @@ class CropImageEffect extends ResizeImageEffect {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function applyEffect(ImageInterface $image) {
|
||||
// Set sane default values.
|
||||
$this->configuration += array(
|
||||
'anchor' => 'center-center',
|
||||
);
|
||||
|
||||
list($x, $y) = explode('-', $this->configuration['anchor']);
|
||||
$x = image_filter_keyword($x, $image->getWidth(), $this->configuration['width']);
|
||||
$y = image_filter_keyword($y, $image->getHeight(), $this->configuration['height']);
|
||||
|
@ -54,12 +49,16 @@ class CropImageEffect extends ResizeImageEffect {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getForm() {
|
||||
$this->configuration += array(
|
||||
'width' => '',
|
||||
'height' => '',
|
||||
public function defaultConfiguration() {
|
||||
return parent::defaultConfiguration() + array(
|
||||
'anchor' => 'center-center',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getForm() {
|
||||
$form = parent::getForm();
|
||||
$form['anchor'] = array(
|
||||
'#type' => 'radios',
|
||||
|
|
|
@ -54,6 +54,16 @@ class ResizeImageEffect extends ImageEffectBase implements ConfigurableImageEffe
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function defaultConfiguration() {
|
||||
return array(
|
||||
'width' => NULL,
|
||||
'height' => NULL,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -61,7 +71,7 @@ class ResizeImageEffect extends ImageEffectBase implements ConfigurableImageEffe
|
|||
$form['width'] = array(
|
||||
'#type' => 'number',
|
||||
'#title' => t('Width'),
|
||||
'#default_value' => isset($this->configuration['width']) ? $this->configuration['width'] : '',
|
||||
'#default_value' => $this->configuration['width'],
|
||||
'#field_suffix' => ' ' . t('pixels'),
|
||||
'#required' => TRUE,
|
||||
'#min' => 1,
|
||||
|
@ -69,7 +79,7 @@ class ResizeImageEffect extends ImageEffectBase implements ConfigurableImageEffe
|
|||
$form['height'] = array(
|
||||
'#type' => 'number',
|
||||
'#title' => t('Height'),
|
||||
'#default_value' => isset($this->configuration['height']) ? $this->configuration['height'] : '',
|
||||
'#default_value' => $this->configuration['height'],
|
||||
'#field_suffix' => ' ' . t('pixels'),
|
||||
'#required' => TRUE,
|
||||
'#min' => 1,
|
||||
|
|
|
@ -28,13 +28,6 @@ class RotateImageEffect extends ImageEffectBase implements ConfigurableImageEffe
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function applyEffect(ImageInterface $image) {
|
||||
// Set sane default values.
|
||||
$this->configuration += array(
|
||||
'degrees' => 0,
|
||||
'bgcolor' => NULL,
|
||||
'random' => FALSE,
|
||||
);
|
||||
|
||||
// Convert short #FFF syntax to full #FFFFFF syntax.
|
||||
if (strlen($this->configuration['bgcolor']) == 4) {
|
||||
$c = $this->configuration['bgcolor'];
|
||||
|
@ -89,13 +82,24 @@ class RotateImageEffect extends ImageEffectBase implements ConfigurableImageEffe
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function defaultConfiguration() {
|
||||
return array(
|
||||
'degrees' => 0,
|
||||
'bgcolor' => NULL,
|
||||
'random' => FALSE,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getForm() {
|
||||
$form['degrees'] = array(
|
||||
'#type' => 'number',
|
||||
'#default_value' => (isset($this->configuration['degrees'])) ? $this->configuration['degrees'] : 0,
|
||||
'#default_value' => $this->configuration['degrees'],
|
||||
'#title' => t('Rotation angle'),
|
||||
'#description' => t('The number of degrees the image should be rotated. Positive numbers are clockwise, negative are counter-clockwise.'),
|
||||
'#field_suffix' => '°',
|
||||
|
@ -103,7 +107,7 @@ class RotateImageEffect extends ImageEffectBase implements ConfigurableImageEffe
|
|||
);
|
||||
$form['bgcolor'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => (isset($this->configuration['bgcolor'])) ? $this->configuration['bgcolor'] : '#FFFFFF',
|
||||
'#default_value' => $this->configuration['bgcolor'],
|
||||
'#title' => t('Background color'),
|
||||
'#description' => t('The background color to use for exposed areas of the image. Use web-style hex colors (#FFFFFF for white, #000000 for black). Leave blank for transparency on image types that support it.'),
|
||||
'#size' => 7,
|
||||
|
@ -112,7 +116,7 @@ class RotateImageEffect extends ImageEffectBase implements ConfigurableImageEffe
|
|||
);
|
||||
$form['random'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#default_value' => (isset($this->configuration['random'])) ? $this->configuration['random'] : 0,
|
||||
'#default_value' => $this->configuration['random'],
|
||||
'#title' => t('Randomize'),
|
||||
'#description' => t('Randomize the rotation angle for each image. The angle specified above is used as a maximum.'),
|
||||
);
|
||||
|
|
|
@ -27,13 +27,6 @@ class ScaleImageEffect extends ResizeImageEffect {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function applyEffect(ImageInterface $image) {
|
||||
// Set sane default values.
|
||||
$this->configuration += array(
|
||||
'width' => NULL,
|
||||
'height' => NULL,
|
||||
'upscale' => FALSE,
|
||||
);
|
||||
|
||||
if (!$image->scale($this->configuration['width'], $this->configuration['height'], $this->configuration['upscale'])) {
|
||||
watchdog('image', 'Image scale failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight()), WATCHDOG_ERROR);
|
||||
return FALSE;
|
||||
|
@ -60,6 +53,15 @@ class ScaleImageEffect extends ResizeImageEffect {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function defaultConfiguration() {
|
||||
return parent::defaultConfiguration() + array(
|
||||
'upscale' => FALSE,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -70,7 +72,7 @@ class ScaleImageEffect extends ResizeImageEffect {
|
|||
$form['height']['#required'] = FALSE;
|
||||
$form['upscale'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#default_value' => (isset($this->configuration['upscale'])) ? $this->configuration['upscale'] : 0,
|
||||
'#default_value' => $this->configuration['upscale'],
|
||||
'#title' => t('Allow Upscaling'),
|
||||
'#description' => t('Let scale make images larger than their original size'),
|
||||
);
|
||||
|
|
|
@ -70,7 +70,7 @@ class AssignOwnerNode extends ConfigurableActionBase implements ContainerFactory
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getDefaultConfiguration() {
|
||||
public function defaultConfiguration() {
|
||||
return array(
|
||||
'owner_uid' => '',
|
||||
);
|
||||
|
|
|
@ -39,7 +39,7 @@ class UnpublishByKeywordNode extends ConfigurableActionBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getDefaultConfiguration() {
|
||||
public function defaultConfiguration() {
|
||||
return array(
|
||||
'keywords' => array(),
|
||||
);
|
||||
|
|
|
@ -22,9 +22,9 @@ use Drupal\Core\Annotation\Translation;
|
|||
class RecentContentBlock extends BlockBase {
|
||||
|
||||
/**
|
||||
* Overrides \Drupal\block\BlockBase::settings().
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function settings() {
|
||||
public function defaultConfiguration() {
|
||||
return array(
|
||||
'block_count' => 10,
|
||||
);
|
||||
|
|
|
@ -22,9 +22,9 @@ use Drupal\Core\Annotation\Translation;
|
|||
class SyndicateBlock extends BlockBase {
|
||||
|
||||
/**
|
||||
* Overrides \Drupal\block\BlockBase::settings().
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function settings() {
|
||||
public function defaultConfiguration() {
|
||||
return array(
|
||||
'block_count' => 10,
|
||||
);
|
||||
|
|
|
@ -43,9 +43,9 @@ class StatisticsPopularBlock extends BlockBase {
|
|||
protected $last_list;
|
||||
|
||||
/**
|
||||
* Overrides \Drupal\block\BlockBase::settings().
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function settings() {
|
||||
public function defaultConfiguration() {
|
||||
return array(
|
||||
'top_day_num' => 0,
|
||||
'top_all_num' => 0,
|
||||
|
|
|
@ -17,7 +17,7 @@ abstract class ChangeUserRoleBase extends ConfigurableActionBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getDefaultConfiguration() {
|
||||
public function defaultConfiguration() {
|
||||
return array(
|
||||
'rid' => '',
|
||||
);
|
||||
|
|
|
@ -22,9 +22,9 @@ use Drupal\Core\Annotation\Translation;
|
|||
class UserNewBlock extends BlockBase {
|
||||
|
||||
/**
|
||||
* Overrides \Drupal\block\BlockBase::settings().
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function settings() {
|
||||
public function defaultConfiguration() {
|
||||
return array(
|
||||
'properties' => array(
|
||||
'administrative' => TRUE
|
||||
|
|
|
@ -25,9 +25,9 @@ use Drupal\Core\Annotation\Translation;
|
|||
class UserOnlineBlock extends BlockBase {
|
||||
|
||||
/**
|
||||
* Overrides \Drupal\block\BlockBase::settings().
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function settings() {
|
||||
public function defaultConfiguration() {
|
||||
return array(
|
||||
'properties' => array(
|
||||
'administrative' => TRUE
|
||||
|
|
|
@ -45,7 +45,7 @@ class ViewsBlock extends ViewsBlockBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function settings() {
|
||||
public function defaultConfiguration() {
|
||||
$settings = array();
|
||||
|
||||
if ($this->displaySet) {
|
||||
|
|
Loading…
Reference in New Issue