- Added a try/catch for the annotations

This commit is contained in:
Dave Mc Nicoll 2021-10-19 12:43:32 +00:00
parent d3270ba6e7
commit 6cbe043648
1 changed files with 13 additions and 8 deletions

View File

@ -10,22 +10,27 @@ class LanguageHandler {
public function verify(string $className) : ? \Notes\Annotation
{
$annotation = $this->getClassAnnotations($className);
# Should generate an equivalent of Ulmus's object reflection here !
if ( $annotation->key ) {
return $annotation;
if ( $annotation = $this->getClassAnnotations($className) ) {
# Should generate an equivalent of Ulmus's object reflection here !
if ( $annotation->key ) {
return $annotation;
}
}
return null;
}
protected function getClassAnnotations(string $className) : \Notes\Annotation
protected function getClassAnnotations(string $className) : ? \Notes\Annotation
{
$objectResolver = new ObjectResolver($className, true, true, false, true);
if ( null !== ( $object = $objectResolver->getAnnotationFromClassname( Annotation\Language::class ) ) ) {
return $object;
try {
if ( null !== ( $object = $objectResolver->getAnnotationFromClassname( Annotation\Language::class ) ) ) {
return $object;
}
}
catch(\Exception $e) {
return null;
}
}