示例#1
0
 public function __construct($name, $path)
 {
     parent::__construct($name, $path);
     $this->time = time();
     $this->setViewPath(ConfigHandler::get('view_path'));
     if (ConfigHandler::has('template')) {
         $this->setTemplate(ConfigHandler::get('template'));
     }
     Loader::setPathOfAlias('template', $this->_viewPath . DIRECTORY_SEPARATOR . $this->_template);
 }
示例#2
0
 /**
  * @param mixed $adapter
  * @param array $config
  */
 public function setAdapter($adapter, $config = array())
 {
     if (is_string($adapter)) {
         Loader::import($adapter);
         $adapter = new $adapter($config);
     }
     if (is_object($adapter) && $adapter instanceof BaseAdapter) {
         $this->_adapter = $adapter;
     }
 }
示例#3
0
 /**
  * @param $path
  * @param $owner
  * @throws Exception
  * @return Widget
  */
 public static function loadWidget($path, $owner)
 {
     $t = explode('.', $path);
     $className = end($t);
     Loader::import($path . '.' . $className, true);
     /** @var Widget $class */
     $class = new $className();
     $class->setName($className);
     if (!$class instanceof Widget) {
         throw new Exception("{$className} not is \\Toxotes\\Widget instance");
     }
     $class->setOwner($owner);
     return $class;
 }
 /**
  * Attaches a behavior to this component.
  * This method will create the behavior object based on the given
  * configuration. After that, the behavior object will be initialized
  * by calling its {@link IBehavior::setOwner} method.
  * @param string $name the behavior's name. It should uniquely identify this behavior.
  * @param mixed $behavior the behavior object or class path of behavior
  * @param array $option
  * @throws Exception
  * @param array $option
  * @internal param array $options optional parameter @see IBehavior::setup
  * @return IBehavior the behavior object
  *
  */
 public function attachBehavior($name, $behavior, $option = array())
 {
     if (is_string($behavior)) {
         Loader::import($behavior);
         $behavior = new $behavior();
         /* @var BaseBehavior $behavior */
     }
     if (!$behavior instanceof IBehavior) {
         throw new Exception("Behavior was attached must extends from \\Flywheel\\Behavior\\BaseBehavior");
     }
     $behavior->setEnable(true);
     $behavior->setOwner($this);
     $behavior->init();
     $behavior->setup($option);
     $this->_behaviors[$name] = $behavior;
 }
 /**
  * @param $alias
  * @param string $namespace
  * @param bool $require
  * @return null
  *
  * @throws Exception
  */
 public static function load($alias, $namespace = 'default', $require = false)
 {
     if (isset(self::$_data[$namespace])) {
         return self::$_data[$namespace];
     }
     if (($path = Loader::getPathOfAlias($alias)) !== false) {
         if (file_exists($path . '.cfg.php')) {
             $config = (require $path . '.cfg.php');
             self::add($config, $namespace);
         } else {
             if (true == $require) {
                 throw new Exception("Alias \"{$alias}\" which was loaded is invalid. Make sure it points to an existing PHP file and the file is readable.");
             } else {
                 return false;
             }
         }
         return $config;
     }
     return false;
 }
 private function _import($aliases)
 {
     if (is_array($aliases) && ($size = sizeof($aliases)) > 0) {
         for ($i = 0; $i < $size; ++$i) {
             Loader::import($aliases[$i]);
         }
     }
 }
 /**
  * @param $class
  * @param null $params
  * @param null $render
  * @return \Flywheel\Controller\Widget
  */
 public static function getWidget($class, $params = null, $render = null)
 {
     $k = 'widget_' . $class;
     if (!isset(self::$_registry[$k])) {
         $class = Loader::import($class, true);
         self::$_registry[$k] = new $class($render);
     }
     if (!empty($params)) {
         foreach ($params as $p => $value) {
             self::$_registry[$k]->{$p} = $value;
         }
     }
     return self::$_registry[$k];
 }
示例#8
0
<?php

defined('APP_PATH') or define('APP_PATH', dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR);
defined('APP_RESOURCES_PATH') or define('APP_RESOURCES_PATH', APP_PATH . 'Resources' . DIRECTORY_SEPARATOR);
\Flywheel\Loader::addNamespace('CMSBackend', dirname(APP_PATH));
return array('i18n' => ['default_locale' => 'en-GB', 'resource' => ['vi-VN' => [APP_RESOURCES_PATH . 'i18n/vi-VN/messages.yml'], 'en-GB' => [APP_RESOURCES_PATH . 'i18n/en-GB/messages.yml']]], 'app_name' => 'CMSBackend', 'app_path' => APP_PATH, 'view_path' => APP_PATH . DIRECTORY_SEPARATOR . 'Template/', 'import' => array('app.Library.*', 'app.Controller.*', 'root.model.*'), 'editor' => 'app.Widget.Editor.SummerNote', 'namespace' => 'CMSBackend', 'timezone' => 'Asia/Ho_Chi_Minh', 'template' => 'Flat', 'css_version' => '1.0', 'js_version' => '1.0');
示例#9
0
<?php

use Flywheel\Loader;
define('ROOT_DIR', dirname(dirname(__DIR__)));
define('MEDIA_DIR', ROOT_DIR . '/public/media');
define('PUBLIC_DIR', ROOT_DIR . '/public/');
require_once __DIR__ . '/../../vendor/autoload.php';
Loader::addNamespace('SFS', ROOT_DIR . '/library/');
Loader::register();
$app = new \Slim\Slim(array('debug' => true, 'mode' => 'development'));
$app->get('/cache/:function/:dimension/:path+', function ($function, $dimension, $path) use($app) {
    $path = implode(DIRECTORY_SEPARATOR, $path);
    $public_dir = rtrim(dirname(MEDIA_DIR), '/');
    //check file exists
    if (!file_exists($public_dir . '/' . $path)) {
        //throw 404
        $app->halt(404, 'File not found!');
    }
    try {
        $dimension = explode('-', $dimension);
        $params = \SFS\Image\Transform::hydrateParameters($dimension);
        $imgTransform = new \SFS\Image\Transform($public_dir . '/' . $path);
        if (!method_exists($imgTransform, $function)) {
            $app->halt(400, 'Not support API "' . $function . '"');
            exit;
        }
        $imgTransform->{$function}($params);
        $dimension = implode('-', $dimension);
        $output = "{$public_dir}/thumbs/cache/{$function}/{$dimension}/{$path}";
        \SFS\Upload::makeFileStorageDir($output);
        $imgTransform->save($output);
示例#10
0
<?php

defined('APP_PATH') or define('APP_PATH', dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR);
\Flywheel\Loader::addNamespace('Frontend', dirname(APP_PATH));
return array('app_name' => 'Frontend', 'app_path' => APP_PATH, 'view_path' => APP_PATH . DIRECTORY_SEPARATOR . 'Template/', 'import' => array('app.Library.*', 'app.Controller.*', 'root.model.*'), 'namespace' => 'Frontend', 'timezone' => 'Asia/Ho_Chi_Minh', 'template' => 'Mobile9');
示例#11
0
<?php

use Flywheel\Loader;
define('ROOT_PATH', dirname(__FILE__));
define('GLOBAL_PATH', ROOT_PATH . DIRECTORY_SEPARATOR . 'global');
define('LIBRARY_PATH', ROOT_PATH . DIRECTORY_SEPARATOR . 'library');
define('RUNTIME_PATH', ROOT_PATH . DIRECTORY_SEPARATOR . 'runtime');
define('PUBLIC_DIR', ROOT_PATH . DIRECTORY_SEPARATOR . 'public');
define('MEDIA_DIR', ROOT_PATH . DIRECTORY_SEPARATOR . 'public' . DIRECTORY_SEPARATOR . 'media');
define('EXTENSION_DIR', ROOT_PATH . DIRECTORY_SEPARATOR . 'extension');
define('FRONTEND_DIR', ROOT_PATH . DIRECTORY_SEPARATOR . 'apps/Frontend');
require_once ROOT_PATH . '/vendor/autoload.php';
//add namespace before register
Loader::addNamespace('Toxotes', LIBRARY_PATH);
Loader::register();
Loader::setPathOfAlias('root', ROOT_PATH);
Loader::setPathOfAlias('global', GLOBAL_PATH);
Loader::setPathOfAlias('library', LIBRARY_PATH);
Loader::setPathOfAlias('extension', EXTENSION_DIR);
Loader::import('global.include.*');
set_error_handler(array('Toxotes\\ErrorHandler', 'errorHandling'));
set_exception_handler(array('Toxotes\\ErrorHandler', 'exceptionHandling'));