Пример #1
0
 /**
  * 
  * @param string $param
  * @return mixed
  */
 public function get($param)
 {
     $result = NULL;
     if (strpos($param, '::') !== FALSE) {
         $result = Callback::invoke_static_class($param);
     } else {
         if (($start = strpos($param, '[')) !== FALSE and ($end = strpos($param, ']')) == strlen($param) - 1) {
             $path = substr($param, $start + 1, -1);
             $param = substr($param, 0, $start);
             return Arr::path($this->_params, $param . '.' . $path);
         } else {
             if (strpos($param, '$page->') !== FALSE) {
                 list($class, $method) = explode('->', $param, 2);
                 if (strpos($method, '()') !== FALSE) {
                     $method = substr($method, 0, strpos($method, '()'));
                     $result = $this->get_page()->{$method}();
                 } else {
                     $result = $this->get_page()->{$method};
                 }
             } else {
                 if (strpos($param, '$user->') !== FALSE) {
                     $user = Auth::instance()->get_user();
                     list($class, $method) = explode('->', $param, 2);
                     if (!$user instanceof ORM) {
                         return $result;
                     }
                     if (strpos($method, '()') !== FALSE) {
                         $method = substr($method, 0, strpos($method, '()'));
                         $result = $user->{$method}();
                     } else {
                         $result = $user->{$method};
                     }
                 } else {
                     if (isset($this->_params[$param])) {
                         $result = $this->_params[$param];
                     } elseif ($this->request()->query($param) !== NULL) {
                         $result = $this->request()->query($param);
                     } else {
                         if ($this->request()->post($param) !== NULL) {
                             $result = $this->request()->post($param);
                         } elseif ($this->behavior_router() instanceof Behavior_Route and $this->behavior_router()->param($param) !== NULL) {
                             $result = $this->behavior_router()->param($param);
                         } else {
                             if ($this->request()->param($param) !== NULL) {
                                 $result = $this->request()->param($param);
                             }
                         }
                     }
                 }
             }
         }
     }
     return $result;
 }