getHelper

The Factory
Looks for a helper in the xen library or in the application path

@param string    $helper
@param array     $params

@throws exception\HelperNotFoundException
196518
protected function getHelper($helper, $params=array())
    {
        if ($this->isLibraryHelper($helper)) $this->_helperClassName = $this->_libNamespace . $helper;
        else if ($this->isApplicationHelper($helper)) $this->_helperClassName = $this->_appNamespace . $helper;
        else throw new HelperNotFoundException('The helper ' . $helper . ' does not exist');

        $this->_helperParams = $params;
    }
745336
public function createHelper($method, $argv)
    {
        $helper = null;
        $helperClass = 'BackBee\Renderer\Helper\\'.$method;
        if (true === class_exists($helperClass)) {
            $this->helpers->set($method, new $helperClass($this, $argv));
            $helper = $this->helpers->get($method);
        }

        return $helper;
    }
933298
public function helpers()
    {
        if ($this->_helpers === null) {
            $this->_helpers = new HelperRegistry($this);
        }

        return $this->_helpers;
    }
1117743
public function loadHelper($helperName, $config = array())
    {
        $helper = Helper::factory($helperName, $config);
        $name = array_key_exists("name", (array)$config) ? $config["name"] : $helper->getShortName();
        $this->set($name, $helper);
    }
423770
public function createHelper($helper, array $config = array())
    {
        if(is_string($helper) && strpos($helper, '.') === false )
        {
            $identifier = $this->getIdentifier()->toArray();
            $identifier['name'] = $helper;
        }
        else $identifier = $helper;

        //Create the template helper
        $helper = $this->getObject($identifier, $config);

        //Check the helper interface
        if (!($helper instanceof TemplateHelperInterface))
        {
            throw new \UnexpectedValueException(
                "Template helper $identifier does not implement TemplateHelperInterface"
            );
        }

        return $helper;
    }
1355482
public function getHelpTos(array $parameters = array(), $multipart = false, $appOnlyAuth = false)
    {
        return $this->get("help/tos", $parameters, $multipart, $appOnlyAuth);
    }
1081867
public function __isset($helper)
  {
    if (isset($this->_helpers[$helper])) {
      $isset = true;
    } else {
      $isset = !is_null($this->_getHelper($helper));
    }
    return $isset;
  }
1312277
public function createHelper($helper, $config = array())
    {
        //Create the complete identifier if a partial identifier was passed
        if (is_string($helper) && strpos($helper, '.') === false)
        {
            $identifier = $this->getIdentifier()->toArray();

            if($identifier['type'] != 'lib') {
                $identifier['path'] = array('template', 'helper');
            } else {
                $identifier['path'] = array('helper');
            }

            $identifier['name'] = $helper;
        }
        else $identifier = $this->getIdentifier($helper);

        $config = array_merge(ObjectConfig::unbox($config), ['template' => $this->getTemplate()]);

        return $this->getObject('template.helper.factory')->createHelper($identifier, $config);
    }
1126663
protected function _findClassName($helper) {
		$className = App::className($helper, 'View/Helper', 'Helper');
		if ($className) {
			return $className;
		}

		$plugins = Plugin::loaded();
		foreach ($plugins as $plugin) {
			$className = App::className($plugin . '.' . $helper, 'View/Helper', 'Helper');
			if ($className) {
				return $className;
			}
		}

		return null;
	}
1344763
public function getHelperPath($helper)
    {
        if ($this->finder) {
            if (file_exists($file = $this->finder->find($helper))) {
                return $file;
            }
        }

        if (file_exists($helper)) {
            return $helper;
        } elseif (file_exists($helper . '.helper.php')) {
            return $helper . '.helper.php';
        }

        foreach ($this->viewPaths as $viewPath) {
            if (file_exists($viewPath . '/helpers/' . $helper . '.helper.php')) {
                return $viewPath . '/helpers/' . $helper . '.helper.php';
            }
        }

        return null;
    }
600589
public function get($name)
    {
        if (! $this->has($name)) {
            throw new Exception\HelperNotFoundException("Helper '$name' not found");
        }

        if (! isset($this->helpers[$name])) {
            $factory = $this->factories[$name];
            $this->helpers[$name] = $factory();
        }

        return $this->helpers[$name];
    }
1215297
public function helper($helper)
    {
        if (isset($this->aliases[$helper])) {
            $helper = $this->aliases[$helper];
        }

        $helper = $this->normalizeName($helper);

        $args = func_get_args();
        $args[0] = $helper;

        return call_user_func_array([$this->factory, 'helper'], $args);
    }
1124583
public function getHelper($name)
    {
        if (null === $this->helperSet) {
            throw new LogicException(sprintf('Cannot retrieve helper "%s" because there is no HelperSet defined. Did you forget to add your command to the application or to set the application on the command using the setApplication() method? You can also set the HelperSet directly using the setHelperSet() method.', $name));
        }

        return $this->helperSet->get($name);
    }
1164855
private function add_helpers( $helpers ) {
		foreach( $helpers as $helper ) {
			$helper = $this->validate_helper_input( $helper );
			if ( is_array( $helper ) ) {
				$this->add_helper( $helper );
			}

		}

	}
27115
public static function loadHelper($helperName, $dirs = null)
    {
        if (isset(self::$loadedHelpers[$helperName])) {
            return;
        }
        
        self::fireEvent('Atomik::Loadhelper::Before', array(&$helperName, &$dirs));
        $functionName = $helperName;
        $camelizedHelperName = str_replace(' ', '', ucwords(str_replace('_', ' ', $helperName)));
        $className = $camelizedHelperName . 'Helper';
        
        if (!function_exists($functionName) && !class_exists($className)) {
            $dirs = self::path($dirs ?: self::get('atomik.dirs.helpers'));
            if (($include = self::findFile("$helperName.php", $dirs, true)) === false) {
                throw new AtomikException("Helper '$helperName' not found");
            }
            list($filename, $ns) = $include;
            include $filename;
            $functionName = ltrim("$ns\\$functionName", '\\');
            $className = ltrim("$ns\\$className", '\\');
        }
        
        if (function_exists($functionName)) {
            self::$loadedHelpers[$helperName] = $functionName;
        } else if (class_exists($className, false)) {
            self::$loadedHelpers[$helperName] = array(new $className(), $camelizedHelperName);
        } else {
            throw new AtomikException("Helper '$helperName' file found but no function or class matching the helper name");
        }
        
        self::fireEvent('Atomik::Loadhelper::After', array($helperName, $dirs));
    }
1337571
protected function findHelper($name)
    {
        $name = ucfirst($name);

        $package = $this->view->getPackage();

        $namespace = MvcHelper::getPackageNamespace($package, 1);

        $class = sprintf($namespace . '\Helper\%sHelper', $name);

        if (!class_exists($class)) {
            foreach (static::$namespaces as $ns) {
                $class = sprintf($ns . '\%sHelper', $name);

                if (class_exists($class)) {
                    break;
                }
            }
        }

        if (!class_exists($class)) {
            $class = 'Windwalker\Core\View\Helper\\' . ucfirst($name) . 'Helper';
        }

        if (!class_exists($class)) {
            return false;
        }

        return $class;
    }
1162416
protected function getHelperMethodValue($helperMethodString, $args = null)
    {
        $helperName = explode('/', (string)$helperMethodString);
        $helperMethod = array_pop($helperName);
        $helperName = implode('/', $helperName);
        $helperArgs = [];

        if (!is_array($args)) {
            $helperArgs[] = $args;
        } else {
            $helperArgs = $args;
        }

        return call_user_func_array([Mage::helper($helperName), $helperMethod], $helperArgs);
    }