예제 #1
0
 /**
  * startup - add in necessary helpers
  *
  * @param Controller $controller
  * @return void
  */
 public function startup(Controller $controller)
 {
     if (!in_array('Number', array_keys(HelperCollection::normalizeObjectArray($controller->helpers)))) {
         $controller->helpers[] = 'Number';
     }
     if (!in_array('SimpleGraph', array_keys(HelperCollection::normalizeObjectArray($controller->helpers)))) {
         $controller->helpers[] = 'DebugKit.SimpleGraph';
     }
 }
 /**
  * Interact with the HelperCollection to load all the helpers.
  *
  * @return void
  */
 public function loadHelpers()
 {
     $this->_helpers = HelperCollection::normalizeObjectArray($this->helpers);
     foreach ($this->_helpers as $name => $properties) {
         list($plugin, $class) = pluginSplit($properties['class']);
         if (isset($properties['settings']['load']) && $properties['settings']['load'] === false) {
             continue;
         }
         if ($plugin) {
             $this->{$class} = $this->Helpers->load($properties['class'], $properties['settings']);
         } elseif (isset($properties['settings']['load']) && $properties['settings']['load'] === true) {
             $this->{$class} = $this->Helpers->load($properties['class'], $properties['settings']);
         }
     }
     $this->_helpersLoaded = true;
 }
예제 #3
0
 public function loadHelpers()
 {
     parent::loadHelpers();
     $helpers = HelperCollection::normalizeObjectArray($this->helpers);
     foreach ($helpers as $properties) {
         list(, $class) = pluginSplit($properties['class']);
         $helper = $this->{$class};
         $class = Inflector::variable($class);
         if (!isset($this->viewVars[$class])) {
             $this->viewVars[$class] = $helper;
         }
         $this->Phptal->set($class, $helper);
         $this->_createHelperModifier($class);
     }
     unset($class, $helpers, $helper);
 }
예제 #4
0
 public function loadHelpers()
 {
     $helpers = HelperCollection::normalizeObjectArray($this->helpers);
     foreach ($helpers as $name => $properties) {
         list($plugin, $class) = pluginSplit($properties['class']);
         $this->{$class} = $this->Helpers->load($properties['class'], $properties['settings']);
         $this->Smarty->assign(strtolower($name), $this->{$class});
     }
 }
예제 #5
0
 /**
  * Loads a helper. Delegates to the `HelperCollection::load()` to load the helper
  *
  * @param string $helperName Name of the helper to load.
  * @param array $settings Settings for the helper
  * @return Helper a constructed helper object.
  * @see HelperCollection::load()
  */
 public function loadHelper($helperName, $settings = array())
 {
     return $this->Helpers->load($helperName, $settings);
 }