New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have a pattern to select a method among a list of values #113

Closed
jbrenaudin opened this Issue Jan 16, 2014 · 2 comments

Comments

2 participants
@jbrenaudin

=> We would like : only this methods (create, get, update, delete) are matched
execution(public ***Controller->(create|get|update|delete)(*) )

=> Actually, we have :
execution(public ***Controller->create() )
|| execution(public ***Controller->get(
) )
|| execution(public ***Controller->update() )
|| execution(public ***Controller->delete(
) )

@lisachenko

This comment has been minimized.

Show comment
Hide comment
@lisachenko

lisachenko Jan 16, 2014

Member

Hello, thank you for the report. I will have a look on weekends. Probably, this will require only minimal changes in the pointcut parser, but not sure...

However, can I recommend you to use an annotation marker (eg. Loggable) for your needs instead of hard-coded pointcuts. And then just add this marker where needed.

Additional way for readable pointcuts is to use @pointcut annotation:

class SomeAspect
{
    /**
     * Pointcut for create
     *
     * @Pointcut("execution(public **\*Controller->create(*))")
     */
    protected function onCreate() {}

    /**
     * Logic here, refer to $this->onCreate
     *
     * @Before("$this->onCreate")
     */
    protected function beforeLogic(MethodInvocation $invocation) {}

}
Member

lisachenko commented Jan 16, 2014

Hello, thank you for the report. I will have a look on weekends. Probably, this will require only minimal changes in the pointcut parser, but not sure...

However, can I recommend you to use an annotation marker (eg. Loggable) for your needs instead of hard-coded pointcuts. And then just add this marker where needed.

Additional way for readable pointcuts is to use @pointcut annotation:

class SomeAspect
{
    /**
     * Pointcut for create
     *
     * @Pointcut("execution(public **\*Controller->create(*))")
     */
    protected function onCreate() {}

    /**
     * Logic here, refer to $this->onCreate
     *
     * @Before("$this->onCreate")
     */
    protected function beforeLogic(MethodInvocation $invocation) {}

}
@lisachenko

This comment has been minimized.

Show comment
Hide comment
@lisachenko

lisachenko Jan 19, 2014

Member

Pointcut syntax was extended. To specify multiple values for method names, just separate them with "|" symbol, e.g. execution(public Demo\Example\General->publicHello|protectedHello(*))

Member

lisachenko commented Jan 19, 2014

Pointcut syntax was extended. To specify multiple values for method names, just separate them with "|" symbol, e.g. execution(public Demo\Example\General->publicHello|protectedHello(*))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment