Ejemplo n.º 1
0
 /**
  * @param	array	$params		config params 
  * @return	null
  */
 public function execute(array $params = null)
 {
     $mapFile = 'app/domains.php';
     $err = 'OrmStartupTask failed: ';
     if (isset($params['orm-domain-map'])) {
         $mapFile = $params['orm-domain-map'];
         if (!is_string($mapFile) || empty($mapFile)) {
             $err .= '-(orm-domain-map) must be a non empty string';
             throw new InvalidArgumentException($err);
         }
     }
     if (false !== strpos($mapFile, '../')) {
         $err .= "file path is invalid";
         throw new LogicException($err);
     }
     $file = AF_BASE_PATH . "/{$mapFile}";
     if (!file_exists($file)) {
         $err .= "could not find -({$file})";
         throw new RunTimeException($err);
     }
     $map = (require $file);
     if (!is_array($map)) {
         $err = "domain must is not an array";
         throw new LogicException($err);
     }
     OrmManager::setRegisteredDomains($map);
     return "registered " . count($map) . " domains";
 }