2.5. Auto Aspect

You are able to register Aspect with the s2aspect function. In the following example, TraceInterceptor is aspected to the add method of Service class. When Action component is taken out by the get method of S2ApplicationContext and the indexAction method is performed, the trace log at the time of the add method of Service class being performed will be outputted.

require_once('S2Container.php');

s2import(dirname(__FILE__) . '/classes');
s2aspect('new seasar\aop\interceptor\TraceInterceptor')
  ->setPattern('/^Service$/')
  ->setPointcut('/^add$/');

$action = s2get('Action');
$action->indexAction();
[Note]NOTE

This Example is located at "examples/quickstart/quickstart030.php".



© Copyright The Seasar Foundation and the others 2005-2010, all rights reserved.