Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Drupal\Component\Plugin;
|
||||
|
||||
use \Drupal\Component\Plugin\Context\ContextInterface;
|
||||
use Drupal\Component\Plugin\Context\ContextInterface;
|
||||
|
||||
/**
|
||||
* Interface for defining context aware plugins.
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Component\Plugin\Definition;
|
||||
|
||||
use Drupal\Component\Plugin\Context\ContextDefinitionInterface;
|
||||
|
||||
/**
|
||||
* Provides an interface for plugin definitions which use contexts.
|
||||
*
|
||||
* @ingroup Plugin
|
||||
*/
|
||||
interface ContextAwarePluginDefinitionInterface extends PluginDefinitionInterface {
|
||||
|
||||
/**
|
||||
* Checks if the plugin defines a particular context.
|
||||
*
|
||||
* @param string $name
|
||||
* The context name.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the plugin defines the given context, otherwise FALSE.
|
||||
*/
|
||||
public function hasContextDefinition($name);
|
||||
|
||||
/**
|
||||
* Returns all context definitions for this plugin.
|
||||
*
|
||||
* @return \Drupal\Component\Plugin\Context\ContextDefinitionInterface[]
|
||||
* The context definitions.
|
||||
*/
|
||||
public function getContextDefinitions();
|
||||
|
||||
/**
|
||||
* Returns a particular context definition for this plugin.
|
||||
*
|
||||
* @param string $name
|
||||
* The context name.
|
||||
*
|
||||
* @return \Drupal\Component\Plugin\Context\ContextDefinitionInterface
|
||||
* The context definition.
|
||||
*
|
||||
* @throws \Drupal\Component\Plugin\Exception\ContextException
|
||||
* Thrown if the plugin does not define the given context.
|
||||
*/
|
||||
public function getContextDefinition($name);
|
||||
|
||||
/**
|
||||
* Adds a context to this plugin definition.
|
||||
*
|
||||
* @param string $name
|
||||
* The context name.
|
||||
* @param \Drupal\Component\Plugin\Context\ContextDefinitionInterface $definition
|
||||
* The context definition.
|
||||
*
|
||||
* @return $this
|
||||
* The called object.
|
||||
*/
|
||||
public function addContextDefinition($name, ContextDefinitionInterface $definition);
|
||||
|
||||
/**
|
||||
* Removes a context definition from this plugin.
|
||||
*
|
||||
* @param string $name
|
||||
* The context name.
|
||||
*
|
||||
* @return $this
|
||||
* The called object.
|
||||
*/
|
||||
public function removeContextDefinition($name);
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Component\Plugin\Definition;
|
||||
|
||||
use Drupal\Component\Plugin\Context\ContextDefinitionInterface;
|
||||
use Drupal\Component\Plugin\Exception\ContextException;
|
||||
|
||||
/**
|
||||
* Provides a trait for context-aware object-based plugin definitions.
|
||||
*/
|
||||
trait ContextAwarePluginDefinitionTrait {
|
||||
|
||||
/**
|
||||
* The context definitions for this plugin definition.
|
||||
*
|
||||
* @var \Drupal\Component\Plugin\Context\ContextDefinitionInterface[]
|
||||
*/
|
||||
protected $contextDefinitions = [];
|
||||
|
||||
/**
|
||||
* Implements \Drupal\Component\Plugin\Definition\ContextAwarePluginDefinitionInterface::hasContextDefinition().
|
||||
*/
|
||||
public function hasContextDefinition($name) {
|
||||
return array_key_exists($name, $this->contextDefinitions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements \Drupal\Component\Plugin\Definition\ContextAwarePluginDefinitionInterface::getContextDefinitions().
|
||||
*/
|
||||
public function getContextDefinitions() {
|
||||
return $this->contextDefinitions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements \Drupal\Component\Plugin\Definition\ContextAwarePluginDefinitionInterface::getContextDefinition().
|
||||
*/
|
||||
public function getContextDefinition($name) {
|
||||
if ($this->hasContextDefinition($name)) {
|
||||
return $this->contextDefinitions[$name];
|
||||
}
|
||||
throw new ContextException($this->id() . " does not define a '$name' context");
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements \Drupal\Component\Plugin\Definition\ContextAwarePluginDefinitionInterface::addContextDefinition().
|
||||
*/
|
||||
public function addContextDefinition($name, ContextDefinitionInterface $definition) {
|
||||
$this->contextDefinitions[$name] = $definition;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements \Drupal\Component\Plugin\Definition\ContextAwarePluginDefinitionInterface::removeContextDefinition().
|
||||
*/
|
||||
public function removeContextDefinition($name) {
|
||||
unset($this->contextDefinitions[$name]);
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
|
@ -33,6 +33,8 @@ interface DiscoveryInterface {
|
|||
* @return mixed[]
|
||||
* An array of plugin definitions (empty array if no definitions were
|
||||
* found). Keys are plugin IDs.
|
||||
*
|
||||
* @see \Drupal\Core\Plugin\FilteredPluginManagerInterface::getFilteredDefinitions()
|
||||
*/
|
||||
public function getDefinitions();
|
||||
|
||||
|
|
|
@ -5,4 +5,4 @@ namespace Drupal\Component\Plugin\Exception;
|
|||
/**
|
||||
* An exception class to be thrown for context plugin exceptions.
|
||||
*/
|
||||
class ContextException extends \Exception implements ExceptionInterface { }
|
||||
class ContextException extends \Exception implements ExceptionInterface {}
|
||||
|
|
|
@ -5,4 +5,4 @@ namespace Drupal\Component\Plugin\Exception;
|
|||
/**
|
||||
* Exception interface for all exceptions thrown by the Plugin component.
|
||||
*/
|
||||
interface ExceptionInterface { }
|
||||
interface ExceptionInterface {}
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
|
||||
namespace Drupal\Component\Plugin\Exception;
|
||||
|
||||
use \BadMethodCallException;
|
||||
use BadMethodCallException;
|
||||
|
||||
/**
|
||||
* Exception thrown when a decorator's _call() method is triggered, but the
|
||||
* decorated object does not contain the requested method.
|
||||
*/
|
||||
class InvalidDecoratedMethod extends BadMethodCallException implements ExceptionInterface { }
|
||||
class InvalidDecoratedMethod extends BadMethodCallException implements ExceptionInterface {}
|
||||
|
|
|
@ -5,4 +5,4 @@ namespace Drupal\Component\Plugin\Exception;
|
|||
/**
|
||||
* Exception to be thrown if a plugin tries to use an invalid deriver.
|
||||
*/
|
||||
class InvalidDeriverException extends PluginException { }
|
||||
class InvalidDeriverException extends PluginException {}
|
||||
|
|
|
@ -8,4 +8,4 @@ namespace Drupal\Component\Plugin\Exception;
|
|||
* Extended interface for exceptions thrown specifically by the Mapper subsystem
|
||||
* within the Plugin component.
|
||||
*/
|
||||
interface MapperExceptionInterface extends ExceptionInterface { }
|
||||
interface MapperExceptionInterface extends ExceptionInterface {}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Component\Plugin\Exception;
|
||||
|
||||
/**
|
||||
* An exception class thrown when contexts exist but are missing a value.
|
||||
*/
|
||||
class MissingValueContextException extends ContextException {
|
||||
|
||||
/**
|
||||
* MissingValueContextException constructor.
|
||||
*
|
||||
* @param string[] $contexts_without_value
|
||||
* List of contexts with missing value.
|
||||
*/
|
||||
public function __construct(array $contexts_without_value = []) {
|
||||
$message = 'Required contexts without a value: ' . implode(', ', $contexts_without_value);
|
||||
parent::__construct($message);
|
||||
}
|
||||
|
||||
}
|
|
@ -6,4 +6,4 @@ namespace Drupal\Component\Plugin\Exception;
|
|||
* Generic Plugin exception class to be thrown when no more specific class
|
||||
* is applicable.
|
||||
*/
|
||||
class PluginException extends \Exception implements ExceptionInterface { }
|
||||
class PluginException extends \Exception implements ExceptionInterface {}
|
||||
|
|
|
@ -63,7 +63,7 @@ class DefaultFactory implements FactoryInterface {
|
|||
* @param \Drupal\Component\Plugin\Definition\PluginDefinitionInterface|mixed[] $plugin_definition
|
||||
* The plugin definition associated with the plugin ID.
|
||||
* @param string $required_interface
|
||||
* (optional) THe required plugin interface.
|
||||
* (optional) The required plugin interface.
|
||||
*
|
||||
* @return string
|
||||
* The appropriate class name.
|
||||
|
|
|
@ -22,7 +22,7 @@ interface MapperInterface {
|
|||
*
|
||||
* @return object|false
|
||||
* A fully configured plugin instance. The interface of the plugin instance
|
||||
* will depends on the plugin type. If no instance can be retrieved, FALSE
|
||||
* will depend on the plugin type. If no instance can be retrieved, FALSE
|
||||
* will be returned.
|
||||
*/
|
||||
public function getInstance(array $options);
|
||||
|
|
|
@ -41,7 +41,7 @@ abstract class PluginBase implements PluginInspectionInterface, DerivativeInspec
|
|||
protected $configuration;
|
||||
|
||||
/**
|
||||
* Constructs a Drupal\Component\Plugin\PluginBase object.
|
||||
* Constructs a \Drupal\Component\Plugin\PluginBase object.
|
||||
*
|
||||
* @param array $configuration
|
||||
* A configuration array containing information about the plugin instance.
|
||||
|
|
|
@ -29,7 +29,7 @@ abstract class PluginManagerBase implements PluginManagerInterface {
|
|||
/**
|
||||
* The object that returns the preconfigured plugin instance appropriate for a particular runtime condition.
|
||||
*
|
||||
* @var \Drupal\Component\Plugin\Mapper\MapperInterface
|
||||
* @var \Drupal\Component\Plugin\Mapper\MapperInterface|null
|
||||
*/
|
||||
protected $mapper;
|
||||
|
||||
|
@ -76,8 +76,7 @@ abstract class PluginManagerBase implements PluginManagerInterface {
|
|||
return $this->getFactory()->createInstance($plugin_id, $configuration);
|
||||
}
|
||||
catch (PluginNotFoundException $e) {
|
||||
$fallback_id = $this->getFallbackPluginId($plugin_id, $configuration);
|
||||
return $this->getFactory()->createInstance($fallback_id, $configuration);
|
||||
return $this->handlePluginNotFound($plugin_id, $configuration);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -85,10 +84,29 @@ abstract class PluginManagerBase implements PluginManagerInterface {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows plugin managers to specify custom behavior if a plugin is not found.
|
||||
*
|
||||
* @param string $plugin_id
|
||||
* The ID of the missing requested plugin.
|
||||
* @param array $configuration
|
||||
* An array of configuration relevant to the plugin instance.
|
||||
*
|
||||
* @return object
|
||||
* A fallback plugin instance.
|
||||
*/
|
||||
protected function handlePluginNotFound($plugin_id, array $configuration) {
|
||||
$fallback_id = $this->getFallbackPluginId($plugin_id, $configuration);
|
||||
return $this->getFactory()->createInstance($fallback_id, $configuration);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getInstance(array $options) {
|
||||
if (!$this->mapper) {
|
||||
throw new \BadMethodCallException(sprintf('%s does not support this method unless %s::$mapper is set.', static::class, static::class));
|
||||
}
|
||||
return $this->mapper->getInstance($options);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
"description": "Base building block for a scalable and extensible plug-in system for PHP components and application framework extensions.",
|
||||
"keywords": ["drupal", "plugin", "plugins"],
|
||||
"homepage": "https://www.drupal.org/project/drupal",
|
||||
"license": "GPL-2.0+",
|
||||
"license": "GPL-2.0-or-later",
|
||||
"require": {
|
||||
"php": ">=5.5.9",
|
||||
"symfony/validator": "~2.7"
|
||||
"symfony/validator": ">=2.7 <4.0.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
|
Reference in a new issue