예제 #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
파일: Ship.php 프로젝트: clancats/framework
 /**
  * initialize the ship
  * 
  * @return void
  */
 public function wake()
 {
     // wrap the assets
     \CCFinder::alias('CCAsset', __DIR__ . '/CCAsset' . EXT);
     // map the other classes
     \CCFinder::package(__DIR__ . '/', array('Packtacular' => 'Packtacular' . EXT, 'Packtacular\\Theme' => 'Theme' . EXT, 'lessc' => 'lib/lessc.inc' . EXT));
     // add writeable directory hook
     \CCEvent::mind('ccdoctor.permissions', function () {
         return PUBLICPATH . \CCConfig::create("Packtacular::packtacular")->path;
     });
 }
예제 #3
0
 /**
  * CCController factory
  *
  * @param string			$path
  * @return CCController
  */
 public static function create($path)
 {
     $class = static::find($path);
     // if class already loaded
     if (!class_exists($class, false)) {
         // register the controller with the autoloader
         \CCFinder::bind($class, CCPath::get($path, CCDIR_CONTROLLER, 'Controller' . EXT));
     }
     // create new controller instance and assign the name
     $controller = new $class();
     $controller->name = $path;
     return $controller;
 }
예제 #4
0
파일: ClanCats.php 프로젝트: clancats/core
 /**
  * start the ccf app lifecycle
  *
  * This method registers the App class and runs the wake events.
  *
  * @param string			$app		The used app class = APPATH/<$app>.php
  * @return void
  */
 public static function wake_app($app)
 {
     static::$runtime_class = $app;
     \CCFinder::bind($app, static::$paths['app'] . $app . EXT);
     // run the application wake
     $response = $app::wake();
     // when the application wake returns an response we display it
     if ($response instanceof CCResponse) {
         if (static::$config->send_app_wake_response) {
             $response->send(true);
             die;
         }
     }
     $response = null;
     // run the environment wake
     if (method_exists($app, 'wake_' . static::$environment)) {
         $response = call_user_func($app . '::wake_' . static::$environment);
         // when the application env wake returns an response we display it
         if ($response instanceof CCResponse) {
             if (static::$config->send_app_wake_response) {
                 $response->send(true);
                 die;
             }
         }
     }
     // add routes from the app
     CCRouter::on($app::routes());
 }
예제 #5
0
파일: map.php 프로젝트: clancats/core
 * Session managment bundle
 */
// namepace
\CCFinder::map('Session', COREPATH . 'bundles/Session/');
// and the shdaow
\CCFinder::shadow('CCSession', 'Session', COREPATH . 'bundles/Session/CCSession' . EXT);
/*
 *---------------------------------------------------------------
 * Authentication Bundle
 *---------------------------------------------------------------
 * 
 * The Authentication bundle for basic a basic user and login
 */
// namepace
\CCFinder::map('Auth', COREPATH . 'bundles/Auth/');
// and the shdaow
\CCFinder::shadow('CCAuth', 'Auth', COREPATH . 'bundles/Auth/CCAuth' . EXT);
/*
 *---------------------------------------------------------------
 * Email Bundle
 *---------------------------------------------------------------
 * 
 * The Email bundle mostly wraps phpmailer
 */
// namepace
\CCFinder::map('Mail', COREPATH . 'bundles/Mail/');
// phpmailer
\CCFinder::bind(array("Mail\\PHPMailer\\PHPMailer" => COREPATH . 'bundles/Mail/PHPMailer/class.phpmailer' . EXT, "Mail\\PHPMailer\\POP3" => COREPATH . 'bundles/Mail/PHPMailer/class.php3' . EXT, "Mail\\PHPMailer\\SMTP" => COREPATH . 'bundles/Mail/PHPMailer/class.smtp' . EXT));
// and the shdaow
\CCFinder::shadow('CCMail', 'Mail', COREPATH . 'bundles/Mail/CCMail' . EXT);
예제 #6
0
 /**
  * Run a console script
  *
  * @param string		$controller
  * @param string		$action	
  * @param array 		$params
  */
 public static function run($controller, $action = null, $params = array())
 {
     // always enable the file infos
     // this allows CCFile to print an info when a file gets created or deleted.
     CCFile::enable_infos();
     // execute by default the help action
     if (empty($action)) {
         $action = 'default';
     }
     $path = CCPath::get($controller, CCDIR_CONSOLE, EXT);
     // check if the file exists, if not try with core path
     if (!file_exists($path)) {
         if (!CCPath::contains_namespace($controller)) {
             $path = CCPath::get(CCCORE_NAMESPACE . '::' . $controller, CCDIR_CONSOLE, EXT);
         }
     }
     // still nothing?
     if (!file_exists($path)) {
         CCCli::line("Could not find controller {$controller}.", 'red');
         return false;
     }
     // all console classes should be on the CCConsole namespace
     // this way you can easly overwrite a console script
     $class = 'CCConsole\\' . $controller;
     // add the class to the autoloader
     \CCFinder::bind($class, $path);
     // create an instance
     $class = new $class($action, $params);
     // run wake function
     if (method_exists($class, 'wake')) {
         call_user_func(array($class, 'wake'), $params);
     }
     // run the execution
     call_user_func(array($class, '_execute'), $action, $params);
     // run sleep
     if (method_exists($class, 'sleep')) {
         call_user_func(array($class, 'sleep'), $params);
     }
 }
예제 #7
0
파일: wake.php 프로젝트: clancats/core
 *---------------------------------------------------------------
 * 
 * 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
 *---------------------------------------------------------------
 * 
 * There are some bundles we seperated on another namespace these
 * are defined in the this map
 */
require COREPATH . "bundles/map" . EXT;
/*
 *---------------------------------------------------------------
 * shortcuts
 *---------------------------------------------------------------
 * 
 * Load the shortcut functions. This file contains mostly