Esempio n. 1
0
 /**
  * @author Damien Lasserre <*****@*****.**>
  */
 private function __construct()
 {
     if (!$this->_db) {
         /** @var \PDO _db */
         $this->_db = registry::getInstance()->get('db');
     }
 }
Esempio n. 2
0
 /**
  * @author Damien Lasserre <*****@*****.**>
  * @param string $path
  * @param string $_file_name
  * @param callback $_callback
  * @param int $_depth
  * @param array $_extensions
  * @return ZipParser
  */
 public function explore($path, $_file_name = null, $_callback = null, $_depth = null, array $_extensions = null)
 {
     /** @var int $current_depth */
     static $current_depth = 0;
     /** @var resource $fd */
     $fd = opendir($path);
     if ($fd) {
         /** @var string $file */
         while (($file = readdir($fd)) !== false) {
             if ($_file_name == null or $_file_name == $file) {
                 if (!in_array($file, array('.', '..'))) {
                     if (is_dir($path . '/' . $file)) {
                         if (null == $_depth or $current_depth <= $_depth) {
                             $current_depth++;
                             self::explore($path . '/' . $file, $_file_name, $_callback, $_depth, $_extensions);
                         } else {
                             continue;
                         }
                     } else {
                         /** @var int $pos */
                         $pos = (int) strrpos($file, '.') + 1;
                         if (null == $_extensions or in_array(substr($file, $pos), $_extensions)) {
                             /** @var string $id */
                             $id = uniqid('', true);
                             /** @var string $datas */
                             $datas = file_get_contents($path . '/' . $file);
                             if (null !== $_callback) {
                                 $datas = $_callback($datas);
                             }
                             registry::getInstance()->add($id, $datas);
                             $this->_zip_resources[substr($file, $pos)][] = array('name' => $file, 'resource' => $id);
                         }
                     }
                 }
             }
         }
     }
     /** return */
     return $this;
 }
Esempio n. 3
0
 /**
  * @author Damien Lasserre <*****@*****.**>
  * @param $resource
  * @return bool|string
  */
 protected function _read($resource)
 {
     return registry::getInstance()->get($resource['resource']);
 }
Esempio n. 4
0
 /**
  * @author Damien Lasserre <*****@*****.**>
  * @param array $_route
  * @throws \Exception
  */
 protected function setAction(array &$_route)
 {
     /** @var \stdClass $_config */
     $_config = registry::getInstance()->get('config');
     /** @var string $_controller */
     $_controller = 'application\\module\\' . $this->_module . '\\controller\\' . $this->_controller;
     /** @var \ReflectionClass $_reflection */
     $_reflection = new \ReflectionClass($_controller);
     /** @var \ReflectionClass $_parent */
     if ($_parent = $_reflection->getParentClass()) {
         if ($_parent->getName() == 'library\\uranium\\core\\controller') {
             if (isset($_route[0]) and !empty($_route[0]) and $_reflection->hasMethod($_route[0] . 'Action')) {
                 $this->_action = $_route[0];
                 /** @var array $_route */
                 $_route = array_slice($_route, 1);
             } else {
                 if ($_reflection->hasMethod($_config->default_action . 'Action')) {
                     $this->_action = $_config->default_action;
                 } else {
                     throw new \Exception('Action not found');
                 }
             }
         } else {
             throw new \Exception('Class must be extend library\\uranium\\core\\controller');
         }
     } else {
         throw new \Exception('Class must be extend library\\uranium\\core\\controller');
     }
 }
Esempio n. 5
0
 /**
  * @author Damien Lasserre <*****@*****.**>
  * @param $name
  * @return table
  */
 public function __get($name)
 {
     /** @var table $model */
     $model = registry::getInstance()->get('model_' . $name);
     if (!$model or $model->_prefix !== $this->_prefix) {
         /** @var string $_name */
         $_class = '\\application\\module\\root\\model\\exchange\\' . $name;
         if (class_exists($_class)) {
             /** @var table $model */
             $model = new $_class($this->_prefix);
             registry::getInstance()->add('model_' . $name, $model);
         }
     }
     /** Return */
     return $model;
 }