Given an annotation:
/**
* @Annotation
* @Target("METHOD")
*/
class MyAnnotation extends Annotation
{
/**
* @var string
*/
public $name = null;
/**
* @var string
*/
public $tag = null;
}
Given an aspect:
/**
*
* @param MethodInvocation $invocation
*
* @Around("@execution(MyAnnotation)")
*/
public function aroundInvocation(MethodInvocation $invocation)
{
/** @var MyAnnotation $annotation */
$annotation = $invocation->getMethod()->getAnnotation(MyAnnotation::class);
$name = $annotation->name;
}
The problem is that a call to $invocation->getMethod()->getAnnotation(MyAnnotation::class); results in a call to FileCacheReader::getAnnotations. Which will get the className like so: $class = $method->getDeclaringClass();
The declaring class in this case is always Class__AopProxied which is not cached. By the way, I'm using Features::PREBUILT_CACHE as I have a read-only file systems.
Error:
The directory "/var/www/html/docroot/bootstrap/cache/aspect/_annotations" is not writable. Both, the webserver and the console user need access. You can manage access rights for multiple users with "chmod +a". If your system does not support this, check out the acl package.
Is there any workaround for this issue? Thanks
Given an annotation:
Given an aspect:
The problem is that a call to
$invocation->getMethod()->getAnnotation(MyAnnotation::class);results in a call toFileCacheReader::getAnnotations. Which will get the className like so:$class = $method->getDeclaringClass();The declaring class in this case is always
Class__AopProxiedwhich is not cached. By the way, I'm usingFeatures::PREBUILT_CACHEas I have a read-only file systems.Error:
The directory "/var/www/html/docroot/bootstrap/cache/aspect/_annotations" is not writable. Both, the webserver and the console user need access. You can manage access rights for multiple users with "chmod +a". If your system does not support this, check out the acl package.Is there any workaround for this issue? Thanks