public function __construct()
{
// Register all services in the container
$this->share('aspect.loader', function (Container $container) {
$aspectLoader = new AspectLoader($container, $container->get('aspect.annotation.reader'));
$lexer = $container->get('aspect.pointcut.lexer');
$parser = $container->get('aspect.pointcut.parser');
// Register general aspect loader extension
$aspectLoader->registerLoaderExtension(new GeneralAspectLoaderExtension($lexer, $parser));
$aspectLoader->registerLoaderExtension(new IntroductionAspectExtension($lexer, $parser));
return $aspectLoader;
});
$this->share('aspect.cached.loader', function (Container $container) {
$cachedAspectLoader = new CachedAspectLoader($container, 'aspect.loader', $container->get('kernel.options'));
return $cachedAspectLoader;
});
$this->share('aspect.advisor.accessor', function (Container $container) {
return new LazyAdvisorAccessor($container, $container->get('aspect.cached.loader'));
});
$this->share('aspect.advice_matcher', function (Container $container) {
return new AdviceMatcher($container->get('aspect.loader'), $container->get('kernel.interceptFunctions'));
});
$this->share('aspect.annotation.reader', function (Container $container) {
$options = $container->get('kernel.options');
$reader = new AnnotationReader();
if (!empty($options['cacheDir'])) {
$reader = new FileCacheReader($reader, $options['cacheDir'] . DIRECTORY_SEPARATOR . '_annotations' . DIRECTORY_SEPARATOR, $options['debug'], 0777 & ~$options['cacheFileMode']);
}
return $reader;
});
$this->share('aspect.cache.path.manager', function (Container $container) {
return new CachePathManager($container->get('kernel'));
});
// Pointcut services
$this->share('aspect.pointcut.lexer', function () {
return new PointcutLexer();
});
$this->share('aspect.pointcut.parser', function (Container $container) {
return new PointcutParser(new PointcutGrammar($container, $container->get('aspect.annotation.reader')));
});
}