Update to Drupal 8.2.0. For more information, see https://www.drupal.org/project/drupal/releases/8.2.0

This commit is contained in:
Pantheon Automation 2016-10-06 15:16:20 -07:00 committed by Greg Anderson
parent 2f563ab520
commit f1c8716f57
1732 changed files with 52334 additions and 11780 deletions

View file

@ -3,6 +3,7 @@
namespace Drupal\Component\Annotation\Plugin\Discovery;
use Drupal\Component\Annotation\AnnotationInterface;
use Drupal\Component\FileCache\FileCacheFactory;
use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
use Drupal\Component\Annotation\Reflection\MockFileFinder;
use Doctrine\Common\Annotations\SimpleAnnotationReader;
@ -48,6 +49,13 @@ class AnnotatedClassDiscovery implements DiscoveryInterface {
*/
protected $annotationNamespaces = [];
/**
* The file cache object.
*
* @var \Drupal\Component\FileCache\FileCacheInterface
*/
protected $fileCache;
/**
* Constructs a new instance.
*
@ -64,6 +72,10 @@ class AnnotatedClassDiscovery implements DiscoveryInterface {
$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));
$this->fileCache = FileCacheFactory::get('annotation_discovery:' . $file_cache_suffix);
}
/**
@ -110,6 +122,14 @@ class AnnotatedClassDiscovery implements DiscoveryInterface {
);
foreach ($iterator as $fileinfo) {
if ($fileinfo->getExtension() == 'php') {
if ($cached = $this->fileCache->get($fileinfo->getPathName())) {
if (isset($cached['id'])) {
// Explicitly unserialize this to create a new object instance.
$definitions[$cached['id']] = unserialize($cached['content']);
}
continue;
}
$sub_path = $iterator->getSubIterator()->getSubPath();
$sub_path = $sub_path ? str_replace(DIRECTORY_SEPARATOR, '\\', $sub_path) . '\\' : '';
$class = $namespace . '\\' . $sub_path . $fileinfo->getBasename('.php');
@ -123,7 +143,16 @@ class AnnotatedClassDiscovery implements DiscoveryInterface {
/** @var $annotation \Drupal\Component\Annotation\AnnotationInterface */
if ($annotation = $reader->getClassAnnotation($parser->getReflectionClass(), $this->pluginDefinitionAnnotationName)) {
$this->prepareAnnotationDefinition($annotation, $class);
$definitions[$annotation->getId()] = $annotation->get();
$id = $annotation->getId();
$content = $annotation->get();
$definitions[$id] = $content;
// Explicitly serialize this to create a new object instance.
$this->fileCache->set($fileinfo->getPathName(), ['id' => $id, 'content' => serialize($content)]);
}
else {
// Store a NULL object, so the file is not reparsed again.
$this->fileCache->set($fileinfo->getPathName(), [NULL]);
}
}
}

View file

@ -8,8 +8,9 @@
"php": ">=5.5.9",
"doctrine/common": "2.5.*",
"doctrine/annotations": "1.2.*",
"drupal/core-plugin": "~8.1",
"drupal/core-utility": "~8.1"
"drupal/core-fileCache": "~8.2",
"drupal/core-plugin": "~8.2",
"drupal/core-utility": "~8.2"
},
"autoload": {
"psr-4": {