Update core 8.3.0

This commit is contained in:
Rob Davies 2017-04-13 15:53:35 +01:00
parent da7a7918f8
commit cd7a898e66
6144 changed files with 132297 additions and 87747 deletions

View file

@ -79,7 +79,7 @@ class Context implements ContextInterface {
if (empty($this->contextDefinition['class'])) {
throw new ContextException("An error was encountered while trying to validate the context.");
}
return array(new Type($this->contextDefinition['class']));
return [new Type($this->contextDefinition['class'])];
}
/**

View file

@ -67,7 +67,7 @@ abstract class ContextAwarePluginBase extends PluginBase implements ContextAware
*/
public function getContextDefinitions() {
$definition = $this->getPluginDefinition();
return !empty($definition['context']) ? $definition['context'] : array();
return !empty($definition['context']) ? $definition['context'] : [];
}
/**
@ -114,7 +114,7 @@ abstract class ContextAwarePluginBase extends PluginBase implements ContextAware
* {@inheritdoc}
*/
public function getContextValues() {
$values = array();
$values = [];
foreach ($this->getContextDefinitions() as $name => $definition) {
$values[$name] = isset($this->context[$name]) ? $this->context[$name]->getContextValue() : NULL;
}

View file

@ -28,7 +28,7 @@ interface ContextAwarePluginInterface extends PluginInspectionInterface {
* @param string $name
* The name of the context in the plugin definition.
*
* @return \Drupal\Component\Plugin\Context\ContextDefinitionInterface.
* @return \Drupal\Component\Plugin\Context\ContextDefinitionInterface
* The definition against which the context value must validate.
*
* @throws \Drupal\Component\Plugin\Exception\PluginException
@ -103,7 +103,7 @@ interface ContextAwarePluginInterface extends PluginInspectionInterface {
* The value to set the context to. The value has to validate against the
* provided context definition.
*
* @return \Drupal\Component\Plugin\ContextAwarePluginInterface.
* @return \Drupal\Component\Plugin\ContextAwarePluginInterface
* A context aware plugin object for chaining.
*
* @throws \Drupal\Component\Plugin\Exception\PluginException

View file

@ -0,0 +1,31 @@
<?php
namespace Drupal\Component\Plugin\Definition;
/**
* Provides an interface for a derivable plugin definition.
*
* @see \Drupal\Component\Plugin\Derivative\DeriverInterface
*/
interface DerivablePluginDefinitionInterface extends PluginDefinitionInterface {
/**
* Gets the name of the deriver of this plugin definition, if it exists.
*
* @return string|null
* Either the deriver class name, or NULL if the plugin is not derived.
*/
public function getDeriver();
/**
* Sets the deriver of this plugin definition.
*
* @param string|null $deriver
* Either the name of a class that implements
* \Drupal\Component\Plugin\Derivative\DeriverInterface, or NULL.
*
* @return $this
*/
public function setDeriver($deriver);
}

View file

@ -0,0 +1,60 @@
<?php
namespace Drupal\Component\Plugin\Definition;
/**
* Provides object-based plugin definitions.
*/
class PluginDefinition implements PluginDefinitionInterface {
/**
* The plugin ID.
*
* @var string
*/
protected $id;
/**
* A fully qualified class name.
*
* @var string
*/
protected $class;
/**
* The plugin provider.
*
* @var string
*/
protected $provider;
/**
* {@inheritdoc}
*/
public function id() {
return $this->id;
}
/**
* {@inheritdoc}
*/
public function setClass($class) {
$this->class = $class;
return $this;
}
/**
* {@inheritdoc}
*/
public function getClass() {
return $this->class;
}
/**
* {@inheritdoc}
*/
public function getProvider() {
return $this->provider;
}
}

View file

@ -11,6 +11,14 @@ namespace Drupal\Component\Plugin\Definition;
*/
interface PluginDefinitionInterface {
/**
* Gets the unique identifier of the plugin.
*
* @return string
* The unique identifier of the plugin.
*/
public function id();
/**
* Sets the class.
*
@ -32,4 +40,15 @@ interface PluginDefinitionInterface {
*/
public function getClass();
/**
* Gets the plugin provider.
*
* The provider is the name of the module that provides the plugin, or "core',
* or "component".
*
* @return string
* The provider.
*/
public function getProvider();
}

View file

@ -12,7 +12,7 @@ abstract class DeriverBase implements DeriverInterface {
*
* @var array
*/
protected $derivatives = array();
protected $derivatives = [];
/**
* {@inheritdoc}

View file

@ -2,6 +2,7 @@
namespace Drupal\Component\Plugin\Discovery;
use Drupal\Component\Plugin\Definition\DerivablePluginDefinitionInterface;
use Drupal\Component\Plugin\Exception\InvalidDeriverException;
/**
@ -20,7 +21,7 @@ class DerivativeDiscoveryDecorator implements DiscoveryInterface {
* @var \Drupal\Component\Plugin\Derivative\DeriverInterface[]
* Keys are base plugin IDs.
*/
protected $derivers = array();
protected $derivers = [];
/**
* The decorated plugin discovery.
@ -93,7 +94,7 @@ class DerivativeDiscoveryDecorator implements DiscoveryInterface {
* DiscoveryInterface::getDefinitions().
*/
protected function getDerivatives(array $base_plugin_definitions) {
$plugin_definitions = array();
$plugin_definitions = [];
foreach ($base_plugin_definitions as $base_plugin_id => $plugin_definition) {
$deriver = $this->getDeriver($base_plugin_id, $plugin_definition);
if ($deriver) {
@ -136,7 +137,7 @@ class DerivativeDiscoveryDecorator implements DiscoveryInterface {
return explode(':', $plugin_id, 2);
}
return array($plugin_id, NULL);
return [$plugin_id, NULL];
}
/**
@ -203,12 +204,21 @@ class DerivativeDiscoveryDecorator implements DiscoveryInterface {
*/
protected function getDeriverClass($base_definition) {
$class = NULL;
if ((is_array($base_definition) || ($base_definition = (array) $base_definition)) && (isset($base_definition['deriver']) && $class = $base_definition['deriver'])) {
$id = NULL;
if ($base_definition instanceof DerivablePluginDefinitionInterface) {
$class = $base_definition->getDeriver();
$id = $base_definition->id();
}
if ((is_array($base_definition) || ($base_definition = (array) $base_definition)) && (isset($base_definition['deriver']))) {
$class = $base_definition['deriver'];
$id = $base_definition['id'];
}
if ($class) {
if (!class_exists($class)) {
throw new InvalidDeriverException(sprintf('Plugin (%s) deriver "%s" does not exist.', $base_definition['id'], $class));
throw new InvalidDeriverException(sprintf('Plugin (%s) deriver "%s" does not exist.', $id, $class));
}
if (!is_subclass_of($class, '\Drupal\Component\Plugin\Derivative\DeriverInterface')) {
throw new InvalidDeriverException(sprintf('Plugin (%s) deriver "%s" must implement \Drupal\Component\Plugin\Derivative\DeriverInterface.', $base_definition['id'], $class));
throw new InvalidDeriverException(sprintf('Plugin (%s) deriver "%s" must implement \Drupal\Component\Plugin\Derivative\DeriverInterface.', $id, $class));
}
}
return $class;
@ -229,7 +239,7 @@ class DerivativeDiscoveryDecorator implements DiscoveryInterface {
// Use this definition as defaults if a plugin already defined itself as
// this derivative, but filter out empty values first.
$filtered_base = array_filter($base_plugin_definition);
$derivative_definition = $filtered_base + ($derivative_definition ?: array());
$derivative_definition = $filtered_base + ($derivative_definition ?: []);
// Add back any empty keys that the derivative didn't have.
return $derivative_definition + $base_plugin_definition;
}
@ -238,7 +248,7 @@ class DerivativeDiscoveryDecorator implements DiscoveryInterface {
* Passes through all unknown calls onto the decorated object.
*/
public function __call($method, $args) {
return call_user_func_array(array($this->decorated, $method), $args);
return call_user_func_array([$this->decorated, $method], $args);
}
}

View file

@ -15,7 +15,7 @@ class StaticDiscovery implements DiscoveryInterface {
*/
public function getDefinitions() {
if (!$this->definitions) {
$this->definitions = array();
$this->definitions = [];
}
return $this->definitions;
}

View file

@ -61,7 +61,7 @@ class StaticDiscoveryDecorator extends StaticDiscovery {
* Passes through all unknown calls onto the decorated object
*/
public function __call($method, $args) {
return call_user_func_array(array($this->decorated, $method), $args);
return call_user_func_array([$this->decorated, $method], $args);
}
}

View file

@ -49,7 +49,7 @@ class DefaultFactory implements FactoryInterface {
/**
* {@inheritdoc}
*/
public function createInstance($plugin_id, array $configuration = array()) {
public function createInstance($plugin_id, array $configuration = []) {
$plugin_definition = $this->discovery->getDefinition($plugin_id);
$plugin_class = static::getPluginClass($plugin_id, $plugin_definition, $this->interface);
return new $plugin_class($configuration, $plugin_id, $plugin_definition);

View file

@ -21,6 +21,6 @@ interface FactoryInterface {
* @throws \Drupal\Component\Plugin\Exception\PluginException
* If the instance cannot be created, such as if the ID is invalid.
*/
public function createInstance($plugin_id, array $configuration = array());
public function createInstance($plugin_id, array $configuration = []);
}

View file

@ -13,7 +13,7 @@ class ReflectionFactory extends DefaultFactory {
/**
* {@inheritdoc}
*/
public function createInstance($plugin_id, array $configuration = array()) {
public function createInstance($plugin_id, array $configuration = []) {
$plugin_definition = $this->discovery->getDefinition($plugin_id);
$plugin_class = static::getPluginClass($plugin_id, $plugin_definition, $this->interface);
@ -51,7 +51,7 @@ class ReflectionFactory extends DefaultFactory {
*/
protected function getInstanceArguments(\ReflectionClass $reflector, $plugin_id, $plugin_definition, array $configuration) {
$arguments = array();
$arguments = [];
foreach ($reflector->getMethod('__construct')->getParameters() as $param) {
$param_name = $param->getName();

View file

@ -18,6 +18,6 @@ interface FallbackPluginManagerInterface {
* @return string
* The id of an existing plugin to use when the plugin does not exist.
*/
public function getFallbackPluginId($plugin_id, array $configuration = array());
public function getFallbackPluginId($plugin_id, array $configuration = []);
}

View file

@ -14,14 +14,14 @@ abstract class LazyPluginCollection implements \IteratorAggregate, \Countable {
*
* @var array
*/
protected $pluginInstances = array();
protected $pluginInstances = [];
/**
* Stores the IDs of all potential plugin instances.
*
* @var array
*/
protected $instanceIDs = array();
protected $instanceIDs = [];
/**
* Initializes and stores a plugin.
@ -53,7 +53,7 @@ abstract class LazyPluginCollection implements \IteratorAggregate, \Countable {
* Clears all instantiated plugins.
*/
public function clear() {
$this->pluginInstances = array();
$this->pluginInstances = [];
}
/**

View file

@ -68,7 +68,7 @@ abstract class PluginManagerBase implements PluginManagerInterface {
/**
* {@inheritdoc}
*/
public function createInstance($plugin_id, array $configuration = array()) {
public function createInstance($plugin_id, array $configuration = []) {
// If this PluginManager has fallback capabilities catch
// PluginNotFoundExceptions.
if ($this instanceof FallbackPluginManagerInterface) {