Esempio n. 1
0
 /**
  * @load
  * @param ReflectionMethod $reflection
  */
 protected function _createFromReflection($reflection)
 {
     $this->_type = Method::ControllerMethod;
     parent::_createFromReflection($reflection);
     //{ Add Views
     if ($this->isPublic()) {
         $viewPath = \Path::instance()->evaluate(':' . $this->controller()->project()->name() . '.apps.view.+' . $this->controller()->name() . '.-' . $this->name());
         if (file_exists($viewPath)) {
             $this->setViewDirectoryCreated();
             $dh = opendir($viewPath);
             $viewsFound = array();
             while (false !== ($file = readdir($dh))) {
                 if ($file != "." && $file != ".." && strtolower(pathinfo($file, PATHINFO_EXTENSION)) == 'php') {
                     $viewFilePath = rtrim($viewPath, '/') . "/{$file}";
                     if ($file == 'layout.php') {
                         $this->setHasLayout();
                         $this->_layout = ControllerLayout::create($viewPath . '/layout.php');
                     } else {
                         if ($file == 'params.php') {
                             $this->setHasParams();
                             $this->_params = Params::create($viewPath . '/params.php');
                         } else {
                             $viewsFound[$file] = $viewFilePath;
                             $this->addView(ControllerView::create($this, pathinfo($file, PATHINFO_FILENAME)));
                         }
                     }
                 }
             }
             closedir($dh);
             if (array_key_exists('view.php', $viewsFound)) {
                 $this->setHasDefaultView();
             }
         }
     }
     //}
 }
Esempio n. 2
0
File: Method.php Progetto: neel/bong
 /**
  * @load
  * @param ReflectionMethod $reflection
  */
 private function _createFromReflection($reflection)
 {
     $this->_name = $reflection->getName();
     $this->_public = $reflection->isPublic();
     $this->_inherited = !($reflection->getDeclaringClass()->getName() == $this->_controller->className());
     foreach ($reflection->getParameters() as $paramReflection) {
         //Argument::create($this, $paramReflection);
         $this->addArgument(Argument::create($this, $paramReflection));
     }
     //{ Add Views
     if ($this->isAction()) {
         $viewPath = \Path::instance()->evaluate(':' . $this->controller()->project()->name() . '.apps.view.+' . $this->controller()->name() . '.-' . $this->name());
         if (file_exists($viewPath)) {
             $this->setViewDirectoryCreated();
             $dh = opendir($viewPath);
             $viewsFound = array();
             while (false !== ($file = readdir($dh))) {
                 if ($file != "." && $file != ".." && strtolower(pathinfo($file, PATHINFO_EXTENSION)) == 'php') {
                     $viewFilePath = rtrim($viewPath, '/') . "/{$file}";
                     if ($file == 'layout.php') {
                         $this->setHasLayout();
                     } else {
                         if ($file == 'params.php') {
                             $this->setHasParams();
                         } else {
                             $viewsFound[$file] = $viewFilePath;
                             $this->addView(ControllerView::create($this, pathinfo($file, PATHINFO_FILENAME)));
                         }
                     }
                 }
             }
             closedir($dh);
             if (array_key_exists('view.php', $viewsFound)) {
                 $this->setHasDefaultView();
             }
         }
     }
     //}
 }
Esempio n. 3
0
 /**
  * Supports a simple form Fluent Interfaces. Allows you to set the request properties by using the request property
  * name as the method name.
  *
  * For example : $controller->limit(10)->browse();
  *
  * @param   string  $method Method name
  * @param   array   $args   Array containing all the arguments for the original call
  * @return  ControllerModel
  *
  * @see http://martinfowler.com/bliki/FluentInterface.html
  */
 public function __call($method, $args)
 {
     //Handle action alias method
     if (in_array($method, $this->getActions())) {
         //Get the data
         $data = !empty($args) ? $args[0] : array();
         //Set the data in the request
         if (!$data instanceof CommandInterface) {
             //Make sure the data is cleared on HMVC calls
             $this->getRequest()->getData()->clear();
             //Automatic set the data in the request if an associative array is passed
             if (is_array($data) && !is_numeric(key($data))) {
                 $this->getRequest()->getData()->add($data);
             }
         }
     }
     //Check first if we are calling a mixed in method to prevent the model being
     //loaded during object instantiation.
     if (!$this->isMixedMethod($method)) {
         //Check for model state properties
         if (isset($this->getModel()->getState()->{$method})) {
             $this->getRequest()->getQuery()->set($method, $args[0]);
             $this->getModel()->getState()->set($method, $args[0]);
             return $this;
         }
     }
     return parent::__call($method, $args);
 }
Esempio n. 4
0
 /**
  * Supports a simple form Fluent Interfaces. Allows you to set the request properties by using the request property
  * name as the method name.
  *
  * For example : $controller->limit(10)->browse();
  *
  * @param	string	$method Method name
  * @param	array	$args   Array containing all the arguments for the original call
  * @return	ControllerView
  *
  * @see http://martinfowler.com/bliki/FluentInterface.html
  */
 public function __call($method, $args)
 {
     //Check first if we are calling a mixed in method to prevent the model being
     //loaded during object instantiation.
     if (!isset($this->_mixed_methods[$method])) {
         //Check for model state properties
         if (isset($this->getModel()->getState()->{$method})) {
             $this->getRequest()->query->set($method, $args[0]);
             $this->getModel()->getState()->set($method, $args[0]);
             return $this;
         }
     }
     return parent::__call($method, $args);
 }