Aspectの登録はs2aspect関数で行います。 次の例では、ServiceクラスのaddメソッドにTraceInterceptorをAspectしています。 S2ApplicationContext::getメソッドでActionコンポーネントを取得し、indexActionメソッドを実行すると、Serviceクラスの addメソッドが実行された際のトレースログが出力されます。
require_once('S2Container.php');
s2import(dirname(__FILE__) . '/classes');
s2aspect('new seasar\aop\interceptor\TraceInterceptor')
->setPattern('/^Service$/')
->setPointcut('/^add$/');
$action = s2get('Action');
$action->indexAction();
![]() | NOTE |
|---|---|
|
このExampleは examples/quickstart/quickstart030.php にあります。 |
| © Copyright The Seasar Foundation and the others 2005-2010, all rights reserved. |