Exemplo n.º 1
0
 public function __construct($originalRouter)
 {
     parent::__construct();
     $this->routes = $originalRouter->routes;
     $this->namedRoutes = $originalRouter->namedRoutes;
     $this->routeGroups = $originalRouter->routeGroups;
 }
 /**
  * @param \Slim\App $slimInstance
  * @param string|string[] $controllerDirs
  * @param string $cacheDir
  * @throws \Exception
  */
 public function __construct(\Slim\App $slimInstance, $controllerDirs, $cacheDir, RouteParser $parser = null, DataGenerator $generator = null)
 {
     parent::__construct($parser, $generator);
     // We save current Slim instance
     self::$_slimInstance = $slimInstance;
     // We save controller dirs
     if (is_string($controllerDirs)) {
         $controllerDirs = [$controllerDirs];
     }
     if (!is_array($controllerDirs)) {
         throw new \InvalidArgumentException('Controllers directory must be either string or array');
     }
     $this->_controllerDirs = [];
     foreach ($controllerDirs as $d) {
         $realPath = realPath($d);
         if ($realPath !== false) {
             $this->_controllerDirs[] = $realPath;
         }
     }
     // We save the cache dir
     if (!is_dir($cacheDir)) {
         $result = @mkdir($cacheDir, 0777, true);
         if ($result === false) {
             throw new \RuntimeException('Can\'t create cache directory');
         }
     }
     if (!is_writable($cacheDir)) {
         throw new \RuntimeException('Cache directory must be writable by web server');
     }
     $this->_cacheDir = rtrim($cacheDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
     $this->_generateRoutes();
 }
Exemplo n.º 3
0
 /**
  * Create new router
  * 
  * @param RouteParser $parser
  * @param AclInterface $acl
  */
 public function __construct(RouteParser $parser = null, &$acl = null)
 {
     $this->acl =& $acl;
     parent::__construct($parser);
 }
Exemplo n.º 4
0
 /**
  * Constructor
  *
  * @param \Spore\Spore $app
  */
 public function __construct(Spore $app)
 {
     parent::__construct();
     $this->app = $app;
 }