kdyby / aop Goto Github PK
View Code? Open in Web Editor NEWAOP for Nette Framework Dependency Injection Container
Home Page: https://packagist.org/packages/kdyby/aop
License: Other
AOP for Nette Framework Dependency Injection Container
Home Page: https://packagist.org/packages/kdyby/aop
License: Other
I have one aspect, that defines one pointcut for first class and one pointcut for second class. Is it bug or feature, that kdyby/aop create 2 instances of Aspect class?
Is there any reason, why kdyby/aop is not used at non autowired services?
Currently I'm not able to use kdyby/aop on presenters becouse of combination of:
https://github.com/Kdyby/Aop/blob/master/src/Kdyby/Aop/DI/AopExtension.php#L220
and
https://github.com/nette/application/blob/master/src/Bridges/ApplicationDI/ApplicationExtension.php#L111
Currently, master version is compatible with nette 2.3, but there is not tagged release with nette 2.3 support.
There should be a tag for it, because otherwise installing via composer does not offer stable compatible version.
With nette 2.3 AOP ends with parse error at generated cache.
Problem is with that resolving class name of container ends with NULL, so whole cache is surrounded by "namespace Kdyby\Aop_CG\ { }" instead of "namespace Kdyby\Aop_CG\ContainerClassName { }".
Solution is to replace line https://github.com/Kdyby/Aop/blob/master/src/Kdyby/Aop/DI/AopExtension.php#L77 with
$cg = $file->getNamespace('Kdyby\Aop_CG\' . $builder->getClassName());
I have no idea how to prepare patch as there is no 2.3 branch. Do you plann it? Or should I check for existence of method getClassName?
It would be great if the generated proxy classes implement some interface. Then you will be able to test it as:
$isProxy = $instance instanceof SOME_INTERFACE;
Page not found. Missing template 'temp/cache/templates/Homepage/default.latte'.
I want to access the annotation in the aspect when using methodAnnotatedWith with the annotation in a namespace. The adviced method file uses a use statement importing the annotation, but the use statement is not generated in the PHP file when compiling.
use MyAnnotation\DoThings;
...
/**
* @DoThings
*/
public function method() { ... }
Accessing the annotation on the target results in an exception:
[Semantical Error] The annotation "@DoThings" in method Service::method() was never imported. Did you maybe forget to add a "use" statement for this annotation?
The usecase is to get the information stored in the annotation and process it in the aspect using the AnnotationReader (since Nette annotation doesn't support use statements imports of annotation classes), like this:
$reader->getMethodAnnotation($around->getTargetReflection(), 'MyAnnotation\DoThings');
Or is there a way to get the annotation object defined by the pointcut?
[Semantical Error] The annotation "@Kdyby\Aop\Around" in method Aspect::method() does not exist, or could not be auto-loaded.
If I want to specify arguments of the aspect myself and not by autowiring, the standard way doesn't work:
aspects:
- MyAspect(@dep)
will throw exception:
The service definition {"value":"Aspect","attributes":["@dep"]} is expected to be an array or Neon entity.
Shouldn't the following condition on line AspectsConfig:62
if (!is_string($def) && (!$def instanceof \stdClass || empty($def->entity))) {
be
if (!is_string($def) && (!$def instanceof \stdClass || empty($def->value))) {
(changing $def->entity to $def->value)?
I'm trying to install this package but I'm not able to install since all other packages I'm using are up to date while this package requires old/obsolete packages. I can't even use version on master because symphony property accessor:
Installation request for kdyby/aop dev-master -> satisfiable by kdyby/aop[dev-master].
- Conclusion: remove symfony/property-access v3.2.4
- Conclusion: don't install symfony/property-access v3.2.4
- kdyby/aop dev-master requires symfony/property-access ~2.6 -> satisfiable by symfony/property-access[v2.6.0, v2.6.1, v2.6.10, v2.6.11, v2.6.12, v2.6.13, v2.6.2, v2.6.3, v2.6.4, v2.6.5, v2.6.6, v2.6.7, v2.6.8, v
2.6.9, v2.7.0, v2.7.1, v2.7.10, v2.7.11, v2.7.12, v2.7.13, v2.7.14, v2.7.15, v2.7.16, v2.7.17, v2.7.18, v2.7.19, v2.7.2, v2.7.20, v2.7.21, v2.7.22, v2.7.23, v2.7.24, v2.7.3, v2.7.4, v2.7.5, v2.7.6, v2.7.7, v2.7.8, v2
.7.9, v2.8.0, v2.8.1, v2.8.10, v2.8.11, v2.8.12, v2.8.13, v2.8.14, v2.8.15, v2.8.16, v2.8.17, v2.8.2, v2.8.3, v2.8.4, v2.8.5, v2.8.6, v2.8.7, v2.8.8, v2.8.9].
Im not sure if is this bug or i m just doing things in wrong way.
My problem is this:
/**
* @Aop\Before("methodAnnotatedWith(app\Model\Anotations\Resource)")
*/
public function resource(Aop\JoinPoint\BeforeMethod $beforeMethod) {
$annotations = $this->annotationReader->getMethodAnnotations($beforeMethod->getTargetReflection());
//Throws Err
//[Semantical Error] The annotation "@resource" in method presenter::actionDefault() was never imported.
// Did you maybe forget to add a "use" statement for this annotation?
}
When i try to get annotation from generated class i get error cause
use namespace\to\Resource statement for annotation is missing in generated presenter
When you try create advice on constructor, it's thrown Call to a member function createService() on a non-object.
The problem is that the container is injected after creation of proxy class.
Possible selutions are constructor injection or disabling creation advice on constructor (including ns\class->*()
)
If the target method have default arguments the generated method will throw Notice about undefined offset:
public function link($destination, $args = array())
{
$__arguments = func_get_args(); $__exception = $__result = NULL;
$this->__getAdvice(295)->covertParameters($__before = new \Kdyby\Aop\JoinPoint\BeforeMethod($this, __FUNCTION__, $__arguments));
$__arguments = $__before->getArguments();
$__result = parent::link($__arguments[0], $__arguments[1]);
return $__result;
}
if you call method as $this->link('default')
, because func_get_args()
returns a copy of the passed arguments only, and does not account for default (non-passed) arguments.
The problem is line:
$__result = parent::link($__arguments[0], $__arguments[1]);
where the $__arguments
contains only one element.
[] operator not supported for strings in ...\libs\nette\nette\Nette\common\ObjectMixin.php:90
Is there a reason why limit aspects only to services? Viz. condition on the line https://github.com/Kdyby/Aop/blob/master/src/Kdyby/Aop/DI/AopExtension.php#L219
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.