Ejemplo n.º 1
0
 public function defineDocument()
 {
     $tmp = explode('\\', get_class($this));
     $document = str_replace('Model', '', $tmp[2]);
     $docName = $tmp[0] . '\\Model\\Document\\' . $document;
     unset($tmp);
     Factory::loadFile($docName);
 }
Ejemplo n.º 2
0
 /**
  * creat tools for controller
  * @return void
  */
 public function _loadTools()
 {
     $def = Config::getTools();
     foreach ($this->tools as $tool => $params) {
         if (is_array($params)) {
             $className = $def[$tool];
             $this->{$tool} = Factory::load($className, $params);
         } else {
             $className = $def[$params];
             $this->{$params} = Factory::load($className);
         }
     }
 }
Ejemplo n.º 3
0
 function __construct()
 {
     $classList = Config::getListener();
     $this->listeners = Config::getListenerList();
     foreach ($this->listeners as $listener => $params) {
         if (is_array($params)) {
             $name = $listener;
             $className = $classList[$listener];
             $this->{$name} = Factory::load($className, $params);
         } else {
             $name = $params;
             $className = $classList[$params];
             $this->{$name} = Factory::load($className);
         }
         $hook = $this->{$name}->infoEvent();
         foreach ($hook as $key => $action) {
             $tmp = $this->arrayGet($key, $this->event);
             $tmp[$name] = $action;
             $this->arraySet($key, $tmp, $this->event);
         }
     }
     $this->ready = true;
     $this->classListe = $classList;
 }
Ejemplo n.º 4
0
 /**
  * load a Collection 
  * @param  string $name the name
  * @return mixed        a collection
  */
 static function load($name)
 {
     $cName = Config::getCurentNamespace() . '\\Model\\Collection\\' . $name . 'Collection';
     return Factory::load($cName, ['name' => $name], false);
 }
Ejemplo n.º 5
0
 public static function loadClass()
 {
     Factory::loadFile(Config::get('Auth.userEntity'));
 }
Ejemplo n.º 6
0
 public function isValid($data)
 {
     $validator = Factory::load($this->validatorName);
     $this->initValidator($validator);
     return $validator->valid($data);
 }
Ejemplo n.º 7
0
 public function getElement($link)
 {
     EventManager::getInstance()->event('router.element.before', $this);
     $cName = $this->makeControllerName($link);
     $controller = Factory::load($cName);
     $method = new \ReflectionMethod($controller, $link['action']);
     if (!isset($this->permission)) {
         $method->invokeArgs($controller, $link['params']);
         return $controller->_getView();
     } else {
         if ($method->isPublic()) {
             if ($this->permission->checkPublicAccess($link)) {
                 $method->invokeArgs($controller, $link['params']);
                 return $controller->_getView();
             }
         } elseif ($method->isProtected()) {
             if ($this->permission->checkProtectedAccess($link)) {
                 $method->setAccessible(true);
                 $method->invokeArgs($controller, $link['params']);
                 return $controller->_getView();
             }
         } elseif ($method->isPrivate()) {
             if ($this->permission->checkPrivateAccess($link)) {
                 $method->setAccessible(true);
                 $method->invokeArgs($controller, $link['params']);
                 return $controller->_getView();
             }
         }
     }
     EventManager::getInstance()->event('router.element.after', $this);
     return false;
 }
Ejemplo n.º 8
0
 public function loadHelper()
 {
     $def = Config::getHelper();
     foreach ($this->helpers as $helper => $params) {
         if (is_array($params)) {
             $className = $def[$helper];
             $this->{$helper} = Factory::load($className, $params);
         } else {
             $className = $def[$params];
             $this->{$params} = Factory::load($className);
         }
     }
 }