diff --git a/src/Core/Config/CoreConfigFactory.php b/src/Core/Config/CoreConfigFactory.php index 4a0cc7073..87bc3b550 100644 --- a/src/Core/Config/CoreConfigFactory.php +++ b/src/Core/Config/CoreConfigFactory.php @@ -1,4 +1,4 @@ -transform([ $this->buildStaticTransformer(), - $this->buildYamlTransformer() + $this->buildYamlTransformer(), + $this->buildAnnotationTransformer(), ]); return $config; @@ -118,11 +123,7 @@ class CoreConfigFactory */ public function buildStaticTransformer() { - return new PrivateStaticTransformer(function () { - return ClassLoader::inst() - ->getManifest() - ->getClassNames(); - }); + return new PrivateStaticTransformer($this->getClassResolver()); } /** @@ -184,4 +185,34 @@ class CoreConfigFactory return ModuleLoader::inst()->getManifest()->moduleExists($module); }); } + + public function buildAnnotationTransformer(): AnnotationTransformer + { + return new AnnotationTransformer( + $this->getClassResolver(), + $this->getAnnotationDefinitions() + ); + } + + /** + * @return callable + */ + protected function getClassResolver(): callable + { + return function () { + return ClassLoader::inst() + ->getManifest() + ->getClassNames(); + }; + } + + /** + * @return AnnotationDefinitionInterface[] + */ + protected function getAnnotationDefinitions(): array + { + return array_map(function($className) { + return new $className; + }, ClassInfo::implementorsOf(AnnotationDefinitionInterface::class)); + } }