Esempio n. 1
0
 /**
  * Dynamically handle calls to the class.
  *
  * @param   string  $method
  * @param   array   $parameters
  * @return  mixed
  * @throws  \BadMethodCallException
  * @since   1.3.1
  */
 public function __call($method, $parameters)
 {
     if (!static::hasHelper($method)) {
         foreach ($this->_path['helper'] as $path) {
             $file = $path . DS . $method . '.php';
             if (file_exists($file)) {
                 include_once $file;
                 break;
             }
         }
         $option = $this->option ? $this->option : \Request::getCmd('option');
         $option = ucfirst(substr($option, 4));
         // Namespaced
         $invokable1 = '\\Components\\' . $option . '\\Helpers\\' . ucfirst($method);
         // Old naming scheme "OptionHelperMethod"
         $invokable2 = $option . 'Helper' . ucfirst($method);
         $callback = null;
         if (class_exists($invokable1)) {
             $callback = new $invokable1();
         } else {
             if (class_exists($invokable2)) {
                 $callback = new $invokable2();
             }
         }
         if (is_callable($callback)) {
             $callback->setView($this);
             $this->helper($method, $callback);
         }
     }
     return parent::__call($method, $parameters);
 }
Esempio n. 2
0
 /**
  * Dynamically handle calls to the class.
  *
  * @param   string  $method
  * @param   array   $parameters
  * @return  mixed
  * @throws  \BadMethodCallException
  * @since   1.3.1
  */
 public function __call($method, $parameters)
 {
     if (!static::hasHelper($method)) {
         foreach ($this->_path['helper'] as $path) {
             $file = $path . DS . $method . '.php';
             if (file_exists($file)) {
                 include_once $file;
                 break;
             }
         }
         // Namespaced
         $invokable1 = '\\Plugins\\' . ucfirst($this->_folder) . '\\' . ucfirst($this->_element) . '\\Helpers\\' . ucfirst($method);
         // Old naming scheme "PluginFolderElementHelperMethod"
         $invokable2 = 'Plugin' . ucfirst($this->_folder) . ucfirst($this->_element) . 'Helper' . ucfirst($method);
         $callback = null;
         if (class_exists($invokable1)) {
             $callback = new $invokable1();
         } else {
             if (class_exists($invokable2)) {
                 $callback = new $invokable2();
             }
         }
         if (is_callable($callback)) {
             $callback->setView($this);
             $this->helper($method, $callback);
         }
     }
     return parent::__call($method, $parameters);
 }