Skip to content
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
Closed

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

jbrenaudin opened this issue Jan 16, 2014 · 2 comments
Labels
Milestone

Comments

@jbrenaudin
Copy link

@jbrenaudin jbrenaudin commented Jan 16, 2014

=> 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
Copy link
Member

@lisachenko 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
Copy link
Member

@lisachenko 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
Labels
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants