xp-forge / inject

Dependency injection for the XP Framework
0 stars 0 forks source link

Feature: AOP #2

Closed thekid closed 5 years ago

thekid commented 10 years ago

This pull request adds AOP possibilities to injection:

$inject->bind('inject.unittest.fixture.Storage', new ProxyProvider(
  'inject.unittest.fixture.FileSystem',
  Methods::$ALL,
  newinstance('inject.aop.Interception', [], [
    'invoke' => function($invocation) use($log) {
      $log[]= $invocation;
      return $invocation->proceed();
    }
  ])
));

The log contains inject.aop.MethodInvocation instances after the invocation.

Usecases

e.g. by subclassing Bindings and adding "syntax" which would read $this->bind('users')->toService('http://...')->withProfiling() and bind RestClient instances by the given name.

thekid commented 10 years ago

Requires xp-framework/core@1d09cc1

Included in XP 6.0.0 Beta 1

thekid commented 10 years ago

Currently only Methods::$ALL is supported as a selection, we should add matchers like annotatedWith() and more like Guice does or get some ideas from Spring.