Beispiel #1
0
 public function testChecksNormalizingReturn()
 {
     $this->assertEquals('.', Path::normalize(''));
     $this->assertEquals('tmp/test', Path::normalize('./tmp/test'));
     $this->assertEquals('/tmp/test', Path::normalize('/tmp/../tmp/test'));
     $this->assertEquals('test/', Path::normalize('./test/'));
 }
Beispiel #2
0
 /**
  * @param array $modules
  * @param Router $router
  * @return Router
  */
 public function autoload(array $modules, Router $router)
 {
     foreach ($modules as $moduleName => $moduleConfig) {
         $routesPath = Path::join($moduleConfig['dir'], ModuleManager::MODULE_CONFIG_DIR, self::ROUTES_FILE);
         if (file_exists($routesPath)) {
             require $routesPath;
         }
     }
     return $router;
 }
Beispiel #3
0
 /**
  * @param array $modules
  * @return Config
  */
 public function getConfigs(array $modules)
 {
     $config = new Config();
     foreach ($modules as $moduleName => $moduleConfig) {
         $configPath = Path::join($moduleConfig['dir'], self::MODULE_CONFIG_DIR, 'config.php');
         if (file_exists($configPath)) {
             $moduleConfig = (require $configPath);
             if (!$moduleConfig instanceof Config) {
                 $moduleConfig = new Config($moduleConfig);
             }
             $config->merge($moduleConfig);
         }
     }
     return $config;
 }
Beispiel #4
0
 public function testShouldCreatePathFromArgs()
 {
     $this->assertEquals('/tmp/test/value/foo.bar', Path::join('/tmp/test', 'value', 'foo.bar'));
 }
Beispiel #5
0
 /**
  * Retrieves default view path - which is PATH_TO_COMPONENT/View/__CLASS__/
  * @return string
  */
 protected function getDefaultViewPath()
 {
     $reflection = new \ReflectionObject($this);
     return Path::join(dirname($reflection->getFileName()), self::VIEW_DIR, $reflection->getShortName());
 }