예제 #1
0
파일: Ship.php 프로젝트: clancats/core
 /**
  * create new ship with given data
  *
  * @param array 				$data
  * @return CCOrbit_Ship
  */
 public static function blueprint($data, $path)
 {
     if (!is_array($data)) {
         throw new \InvalidArgumentException("CCOrbit_Ship::blueprint - first argument has to be an array.");
     }
     $ship = new static();
     $name = $data['name'];
     $namespace = $data['namespace'];
     // check if we have a name if not use dir name
     if (is_null($name)) {
         $name = basename($path);
     }
     // get ship namespace
     if ($namespace === true) {
         $namespace = $name;
     }
     // try to load other ship class
     if (is_string($namespace)) {
         // register the namespace
         \CCFinder::bundle($namespace, $path);
         $class = $namespace . '\\Ship';
         if (class_exists($class)) {
             $ship = new $class();
         }
     }
     // set the path
     $ship->name = $name;
     $ship->path = $path;
     $ship->namespace = $namespace;
     // assign the data
     foreach ($data as $key => $item) {
         if (property_exists($ship, $key)) {
             $ship->{$key} = $item;
         }
     }
     // check the namespace
     if ($ship->namespace === false) {
         if (is_null($ship->wake)) {
             $ship->wake = 'shipyard/wake' . EXT;
         }
         if (is_null($ship->install)) {
             $ship->install = 'shipyard/install' . EXT;
         }
         if (is_null($ship->uninstall)) {
             $ship->uninstall = 'shipyard/uninstall' . EXT;
         }
     } elseif (is_string($ship->namespace)) {
         if (is_null($ship->wake)) {
             $ship->wake = 'Ship::wake';
         }
         if (is_null($ship->install)) {
             $ship->install = 'Ship::install';
         }
         if (is_null($ship->uninstall)) {
             $ship->uninstall = 'Ship::uninstall';
         }
     }
     return $ship;
 }
예제 #2
0
파일: wake.php 프로젝트: clancats/core
 *---------------------------------------------------------------
 * 
 * Register the autoloader with spl_autoload_register. And define
 * the core namespace ( CCCORE_NAMESPACE ) for global use.
 */
\CCFinder::register();
define('CCCORE_NAMESPACE', 'Core');
/*
 *---------------------------------------------------------------
 * core namespace
 *---------------------------------------------------------------
 * 
 * Add the core namespace so the autoloader knows where he finds
 * core classes.
 */
\CCFinder::bundle(CCCORE_NAMESPACE, COREPATH);
/*
 *---------------------------------------------------------------
 * core package
 *---------------------------------------------------------------
 * 
 * Add a core shadow containing a map of our core classes this 
 * way the auoloader wil alias core class into the global
 * namespace when they are required.
 */
\CCFinder::shadow_package(COREPATH . CCDIR_CLASS, CCCORE_NAMESPACE, require COREPATH . "coremap" . EXT);
/*
 *---------------------------------------------------------------
 * core bundles
 *---------------------------------------------------------------
 *