/**
  * Returns routes to connect to the given application.
  *
  * @param SilexApplication $app An Application instance
  *
  * @return ControllerCollection A ControllerCollection instance
  */
 public function connect(SilexApplication $app)
 {
     $app = AdzeApplication::assertAdzeApplication($app);
     $controllers = $app->getControllerFactory();
     $resourceController = $this;
     // For all files, use the prefixMap to see if the file specified is present in the given directory
     $controllers->get('/{path}', function (AdzeApplication $app, $path) use($resourceController) {
         $out = null;
         $file = $resourceController->getFileForUri($path);
         if ($file) {
             $extension = strtolower($file->getExtension());
             switch ($extension) {
                 // determine manually a couple of file types that we can't get from magic
                 case 'js':
                     $mimeType = 'text/javascript';
                     break;
                 case 'css':
                     $mimeType = 'text/css';
                     break;
                 default:
                     $mimeType = null;
             }
             if ($mimeType) {
                 $out = $app->sendFile($file, 200, ['Content-Type' => $mimeType]);
             } else {
                 $out = $app->sendFile($file);
             }
         }
         return $out;
     })->assert('path', '.+');
     // match slashes too
     return $controllers;
 }
 /**
  * Registers services on the given app.
  *
  * This method should only be used to configure services and parameters.
  * It should not get services.
  *
  * @param SilexApplication $app An Application instance
  */
 public function register(SilexApplication $app)
 {
     $app = AdzeApplication::assertAdzeApplication($app);
     $extensionProvider = $this;
     $app['twig'] = $app->share($app->extend('twig', function (\Twig_Environment $twig, $app) use($extensionProvider) {
         // add custom globals, filters, tags, ...
         $filter = new \Twig_SimpleFilter('truncateAtSentence', array($extensionProvider, 'truncateAtSentence'));
         $twig->addFilter($filter);
         return $twig;
     }));
 }
 /**
  * Bootstraps the application. Here, adds our own local user template path
  *
  * This method is called after all services are registered
  * and should be used for "dynamic" configuration (whenever
  * a service must be requested).
  */
 public function boot(SilexApplication $app)
 {
     $moduleRoot = dirname(dirname(dirname(dirname(__DIR__))));
     // really need neater ways of getting path roots...
     parent::boot($app);
     $app = AdzeApplication::assertAdzeApplication($app);
     //prepend our own template path for user templates
     $app->getTwigFilesystemLoader()->addPath($moduleRoot . '/templates/user/default', 'user');
     //Identify parent path so that we can refer directly to @user/default if required
     $app->getTwigFilesystemLoader()->addPath($moduleRoot . '/templates/user', 'user');
 }