Example #1
0
 public function register(Application $app)
 {
     ////
     // Absolute dependencies
     ////
     $app->register(new ServiceControllerServiceProvider());
     ////
     // User Configured Values
     ////
     $app['orlex.cache.dir'] = null;
     $app['orlex.controller.dirs'] = [];
     $app['orlex.annotation.dirs'] = [];
     ////
     // Internal Services
     ////
     $app['orlex.cache'] = $app->share(function ($app) {
         $cache_dir = $app['orlex.cache.dir'];
         if (!$cache_dir) {
             return false;
         }
         $cache = new Cache\FilesystemCache($cache_dir);
         return $cache;
     });
     $app['orlex.annotation.reader'] = $app->share(function ($app) {
         $reader = new Annotations\AnnotationReader();
         if ($cache = $app['orlex.cache']) {
             $reader = new Annotations\CachedReader($reader, $cache);
         }
         return $reader;
     });
     $app['orlex.directoryloader'] = $app->share(function () {
         return new Loader\DirectoryLoader();
     });
     $app['orlex.annotation.registry'] = $app->share(function ($app) {
         AnnotationRegistry::registerAutoloadNamespace('Orlex\\Annotation', dirname(__DIR__));
         foreach ($app['orlex.annotation.dirs'] as $dir => $namespace) {
             AnnotationRegistry::registerAutoloadNamespace($namespace, $dir);
         }
     });
     $app['orlex.route.compiler'] = $app->share(function ($app) {
         $app['orlex.annotation.registry'];
         $compiler = new Compiler\Route($app['orlex.annotation.reader'], $app['orlex.directoryloader']);
         $compiler->setContainer($app);
         return $compiler;
     });
 }
Example #2
0
 public function setUp()
 {
     $this->app = new Application();
     $this->compiler = new Compiler\Route(new Annotations\AnnotationReader(), new FileLoader());
     $this->compiler->setContainer($this->app);
 }