$sub_path =
$iterator->
getSubIterator()->
getSubPath();
$sub_path =
$sub_path ?
str_replace(DIRECTORY_SEPARATOR, '\\',
$sub_path) . '\\' : '';
$class =
$namespace . '\\' .
$sub_path .
$fileinfo->
getBasename('.php'
);
// The filename is already known, so there is no need to find the
// file. However, StaticReflectionParser needs a finder, so use a
// mock version.
$finder = MockFileFinder::
create($fileinfo->
getPathName());
$parser =
new StaticReflectionParser($class,
$finder, TRUE
);
/** @var \Drupal\Component\Annotation\AnnotationInterface $annotation */
if ($annotation =
$reader->
getClassAnnotation($parser->
getReflectionClass(),
$this->pluginDefinitionAnnotationName
)) { $this->
prepareAnnotationDefinition($annotation,
$class);
$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
]);
}