_View = $view; } /** * Loads/constructs a helper. Will return the instance in the registry if it already exists. * * @param string $helper Helper name to load * @param array $settings Settings for the helper. * @param boolean $enable Whether or not this helper should be enabled by default * @return Helper A helper object, Either the existing loaded helper or a new one. * @throws MissingHelperFileException, MissingHelperClassException when the helper could not be found */ public function load($helper, $settings = array(), $enable = true) { list($plugin, $name) = pluginSplit($helper, true); if (isset($this->_loaded[$name])) { return $this->_loaded[$name]; } $helperClass = $name . 'Helper'; if (!class_exists($helperClass)) { if (!App::import('Helper', $helper)) { throw new MissingHelperFileException(array( 'class' => $helperClass, 'file' => Inflector::underscore($name) . '.php' )); } if (!class_exists($helperClass)) { throw new MissingHelperClassException(array( 'class' => $helperClass, 'file' => Inflector::underscore($name) . '.php' )); } } $this->_loaded[$name] = new $helperClass($this->_View, $settings); $vars = array('request', 'theme', 'plugin'); foreach ($vars as $var) { $this->_loaded[$name]->{$var} = $this->_View->{$var}; } if ($enable === true) { $this->_enabled[] = $name; } return $this->_loaded[$name]; } }