Update core 8.3.0
This commit is contained in:
parent
da7a7918f8
commit
cd7a898e66
6144 changed files with 132297 additions and 87747 deletions
|
@ -52,7 +52,7 @@ class Plugin implements AnnotationInterface {
|
|||
* The parsed annotation as a definition.
|
||||
*/
|
||||
protected function parse(array $values) {
|
||||
$definitions = array();
|
||||
$definitions = [];
|
||||
foreach ($values as $key => $value) {
|
||||
if ($value instanceof AnnotationInterface) {
|
||||
$definitions[$key] = $value->get();
|
||||
|
|
|
@ -10,6 +10,7 @@ use Doctrine\Common\Annotations\SimpleAnnotationReader;
|
|||
use Doctrine\Common\Annotations\AnnotationRegistry;
|
||||
use Doctrine\Common\Reflection\StaticReflectionParser;
|
||||
use Drupal\Component\Plugin\Discovery\DiscoveryTrait;
|
||||
use Drupal\Component\Utility\Crypt;
|
||||
|
||||
/**
|
||||
* Defines a discovery mechanism to find annotated plugins in PSR-0 namespaces.
|
||||
|
@ -68,13 +69,13 @@ class AnnotatedClassDiscovery implements DiscoveryInterface {
|
|||
* @param string[] $annotation_namespaces
|
||||
* (optional) Additional namespaces to be scanned for annotation classes.
|
||||
*/
|
||||
function __construct($plugin_namespaces = array(), $plugin_definition_annotation_name = 'Drupal\Component\Annotation\Plugin', array $annotation_namespaces = []) {
|
||||
public function __construct($plugin_namespaces = [], $plugin_definition_annotation_name = 'Drupal\Component\Annotation\Plugin', array $annotation_namespaces = []) {
|
||||
$this->pluginNamespaces = $plugin_namespaces;
|
||||
$this->pluginDefinitionAnnotationName = $plugin_definition_annotation_name;
|
||||
$this->annotationNamespaces = $annotation_namespaces;
|
||||
|
||||
$file_cache_suffix = str_replace('\\', '_', $plugin_definition_annotation_name);
|
||||
$file_cache_suffix .= ':' . hash('crc32b', serialize($annotation_namespaces));
|
||||
$file_cache_suffix .= ':' . Crypt::hashBase64(serialize($annotation_namespaces));
|
||||
$this->fileCache = FileCacheFactory::get('annotation_discovery:' . $file_cache_suffix);
|
||||
}
|
||||
|
||||
|
@ -104,7 +105,7 @@ class AnnotatedClassDiscovery implements DiscoveryInterface {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDefinitions() {
|
||||
$definitions = array();
|
||||
$definitions = [];
|
||||
|
||||
$reader = $this->getAnnotationReader();
|
||||
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Component\Annotation\Plugin\Discovery;
|
||||
|
||||
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
|
||||
use Drupal\Component\Plugin\Discovery\DiscoveryTrait;
|
||||
|
||||
/**
|
||||
* Ensures that all definitions are run through the annotation process.
|
||||
*/
|
||||
class AnnotationBridgeDecorator implements DiscoveryInterface {
|
||||
|
||||
use DiscoveryTrait;
|
||||
|
||||
/**
|
||||
* The decorated plugin discovery.
|
||||
*
|
||||
* @var \Drupal\Component\Plugin\Discovery\DiscoveryInterface
|
||||
*/
|
||||
protected $decorated;
|
||||
|
||||
/**
|
||||
* The name of the annotation that contains the plugin definition.
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $pluginDefinitionAnnotationName;
|
||||
|
||||
/**
|
||||
* ObjectDefinitionDiscoveryDecorator constructor.
|
||||
*
|
||||
* @param \Drupal\Component\Plugin\Discovery\DiscoveryInterface $decorated
|
||||
* The discovery object that is being decorated.
|
||||
* @param string $plugin_definition_annotation_name
|
||||
* The name of the annotation that contains the plugin definition. The class
|
||||
* corresponding to this name must implement
|
||||
* \Drupal\Component\Annotation\AnnotationInterface.
|
||||
*/
|
||||
public function __construct(DiscoveryInterface $decorated, $plugin_definition_annotation_name) {
|
||||
$this->decorated = $decorated;
|
||||
$this->pluginDefinitionAnnotationName = $plugin_definition_annotation_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDefinitions() {
|
||||
$definitions = $this->decorated->getDefinitions();
|
||||
foreach ($definitions as $id => $definition) {
|
||||
// Annotation constructors expect an array of values. If the definition is
|
||||
// not an array, it usually means it has been processed already and can be
|
||||
// ignored.
|
||||
if (is_array($definition)) {
|
||||
$definitions[$id] = (new $this->pluginDefinitionAnnotationName($definition))->get();
|
||||
}
|
||||
}
|
||||
return $definitions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes through all unknown calls onto the decorated object.
|
||||
*
|
||||
* @param string $method
|
||||
* The method to call on the decorated plugin discovery.
|
||||
* @param array $args
|
||||
* The arguments to send to the method.
|
||||
*
|
||||
* @return mixed
|
||||
* The method result.
|
||||
*/
|
||||
public function __call($method, $args) {
|
||||
return call_user_func_array([$this->decorated, $method], $args);
|
||||
}
|
||||
|
||||
}
|
|
@ -22,11 +22,11 @@ class PluginID extends AnnotationBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function get() {
|
||||
return array(
|
||||
return [
|
||||
'id' => $this->value,
|
||||
'class' => $this->class,
|
||||
'provider' => $this->provider,
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Reference in a new issue