Get a template helper

@param    mixed $helper ObjectIdentifierInterface
@param    array $config An optional associative array of configuration settings
@throws  \UnexpectedValueException
@return  TemplateHelperInterface
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;
    }
1248031
public function getFormat($config)
    {
        $result = $this->format;
        if ($this->useFormat) {
            $result = $config->get(Option::FORMAT);
        }

        return $result;
    }
1057933
protected function createPartOfStructure(array $config)
  {
    $return_properties    = array();
    $return_configuration = array();

    foreach ($config as $configuration)
    {
      $value = null;
      switch ($configuration->getType())
      {
        case TypeEnum::COLLECTION_TYPE:
          $value = array($this->createPartOfStructure($configuration->getChildren()));
          break;
        case TypeEnum::OBJECT_TYPE:
          $value = $this->createPartOfStructure($configuration->getChildren());
          break;
        case TypeEnum::ARRAY_TYPE:
          $value = array();
          break;
        default:
          break;
      }
      $this->modifyConfiguration($configuration);
      $parameter = new Parameter($configuration->getKey(), $value);

      $return_properties[$configuration->getKey()]    = $parameter;
      $return_configuration[$configuration->getKey()] = $configuration;
    }

    return $this->classBuilder->build('\stdClass', $return_configuration, $return_properties);
  }
1005819
public function load($config = array())
    {
        $identifier = $this->getTemplate()->getIdentifier();

        $config = new KObjectConfigJson($config);
        $config->append(array(
            'debug' => false,
            'package' => $identifier->package,
            'domain'  => $identifier->domain,
            'type'    => $identifier->type,
            'styles' => array(),
        ))->append(array(
            'k_ui_container' => ($config->domain === 'admin' || $config->domain === '') && $config->type === 'com'
        ))->append(array(
            'wrapper_class' => array(
                // Only add k-ui-container for top-level component templates
                ($config->k_ui_container ? 'k-ui-container'.($config->debug ? '' : ' k-no-css-errors') : ''),
                'k-ui-namespace',
                $identifier->type.'_'.$identifier->package
            ),
        ))->append(array(
            'wrapper' => sprintf('<div class="%s">
                <!--[if lte IE 8 ]><div class="old-ie"><![endif]-->
                %%s
                <!--[if lte IE 8 ]></div><![endif]-->
                </div>', implode(' ', KObjectConfig::unbox($config->wrapper_class))
            )
        ));


        $html = '';

        if ($config->styles !== false)
        {
            if ($config->package) {
                $config->styles->package = $config->package;
            }

            if ($config->domain) {
                $config->styles->domain = $config->domain;
            }

            $config->styles->debug = $config->debug;

            $html .= $this->styles($config->styles);
        }

        $html .= $this->scripts($config);

        if ($config->wrapper) {
            $html .= $this->wrapper($config);
        }

        return $html;
    }
973561
protected function _paramsComponent($config)
    {
        $entity = $config->entity;
        $package = $entity->option;
        $config_file_path = ANPATH_SITE.DS.'components'.DS.$package.DS.'config.json';

        if(!file_exists($config_file_path)) {
           return AnTranslator::_('COM-SETTINGS-PROMPT-NO-CONFIGURATION-AVAILABLE');
        }

        $this->getService('anahita:language')->load($package);
        $app_config = json_decode(file_get_contents($config_file_path));

        return $this->_renderForm($app_config->fields, $entity);
    }
1348813
protected function applyRelatedFieldConfig(array $config)
    {
        if (!isset($config['relatedField']) || !is_string($config['relatedField'])) {
            throw new UnexpectedValueException($this->translate(
                'Relation field configuration should contain related field name and name should be a string.'
            ));
        }
        $this->relatedFieldName = $config['relatedField'];
    }
179540
public function getConfiguration(array $config, ContainerBuilder $container)
    {
        $configuration = parent::getConfiguration($config, $container);
        if (null === $configuration) {
            throw new \RuntimeException('No configuration found');
        }

        return $configuration;
    }
294889
public function getTemplate()
    {
        if(!$this->__template instanceof TemplateInterface)
        {
            $this->__template = $this->getObject($this->__template);

            if(!$this->__template instanceof TemplateInterface)
            {
                throw new \UnexpectedValueException(
                    'Template: '.get_class($this->_model).' does not implement TemplateInterface'
                );
            }
        }

        return $this->__template;
    }
222731
protected function setup(array $config = [])
    {
        if (isset($config['renderer']) && (!($config['renderer'] instanceof \Closure) && !is_callable($config['renderer']))) {
            throw new Exception(translate('{renderer} must be callable'), 500, Exception::BADARGUMENTS);
        }

        if (isset($config['template']) && !is_string($config['template'])) {
            throw new Exception(translate('{template} must be a string'), 500, Exception::BADARGUMENTS);
        }

        if (isset($config['html_options']) && !is_array($config['html_options'])) {
            throw new Exception(translate('{html_options} must be an array'), 500, Exception::BADARGUMENTS);
        }

        foreach ($config as $property => $data) {
            if (property_exists($this, $property)) {
                $this->{$property} = $data;
            } elseif (property_exists($this, '_'.$property)) {
                $this->{'_'.$property} = $data;
            }
        }

        if (!$this->id) {
            $this->id = 'widget_'.static::$_counter;
        }

        if (isset($this->_html_options['id'])) {
            $this->id = $this->_html_options['id'];
        } else {
            $this->_html_options['id'] = $this->id;
        }
    }
517460
public function load($config = array())
    {
        $identifier = $this->getIdentifier();

        $config = new ObjectConfigJson($config);
        $config->append(array(
            'debug' => \Kodekit::getInstance()->isDebug(),
            'package' => $identifier->package,
            'domain'  => $identifier->domain,
            'type'    => $identifier->type,
            'styles' => array(),
        ))->append(array(
            'k_ui_container' => ($config->domain === 'admin' || $config->domain === '') && $config->type === 'com'
        ))->append(array(
            'wrapper_class' => array(
                // Only add k-ui-container for top-level component templates
                ($config->k_ui_container ? 'k-ui-container'.($config->debug ? '' : ' k-no-css-errors') : ''),
                'k-ui-namespace',
                $identifier->type.'_'.$identifier->package
            ),
        ))->append(array(
            'wrapper' => sprintf('<div class="%s">
                <!--[if lte IE 8 ]><div class="old-ie"><![endif]-->
                %%s
                <!--[if lte IE 8 ]></div><![endif]-->
                </div>', implode(' ', ObjectConfig::unbox($config->wrapper_class))
            )
        ));

        $html = '';

        if ($config->styles !== false)
        {
            if ($config->package) {
                $config->styles->package = $config->package;
            }

            if ($config->domain) {
                $config->styles->domain = $config->domain;
            }

            $config->styles->debug = $config->debug;
            $config->styles->decorator = $config->decorator;

            $html .= $this->styles($config->styles);
        }

        $html .= $this->scripts($config);

        if ($config->wrapper) {
            $html .= $this->wrapper($config);
        }

        return $html;
    }
963119
public static function config($config = null)
	{
		if(is_array($config)) {

            # Setting Configurations
			static::$config = $config + static::$config;
			$pathWithoutTrailingSlash = rtrim(static::$config['directory'], '/');
			static::$config['directory'] = $pathWithoutTrailingSlash.'/';

		} elseif(is_string($config)) {

            # Getting Single Config item
			return isset(static::$config[$config]) ? static::$config[$config] : null;

		} elseif(!$config) {

            # Getting All configurations
			return static::$config;
		} else {
			throw new CacheException('Invalid parameter provided for Cache::config()');
		}
	}
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;
    }
1101803
protected function instantiateConfig($config = null)
    {
        if (is_null($this->config) || ! is_null($config)) {
            $this->config = ! is_null($config)
                ? $config
                : new Config($this->helper);
        }

        return $this->config;
    }
462473
public function getTemplate()
    {
        if (!$this->__template instanceof TemplateInterface)
        {
            //Make sure we have a template identifier
            if (!($this->__template instanceof ObjectIdentifier)) {
                $this->setTemplate($this->__template);
            }

            $options = array(
                'filters'   => $this->getConfig()->template_filters,
                'functions' => $this->getConfig()->template_functions,
            );

            $this->__template = $this->getObject($this->__template, $options);

            if(!$this->__template instanceof TemplateInterface)
            {
                throw new \UnexpectedValueException(
                    'Template: '.get_class($this->__template).' does not implement TemplateInterface'
                );
            }
        }

        return $this->__template;
    }
1014389
public static function load(string $token, array $config): Token
    {
        $fields = ['id', 'h', 'e'];
        $params = [];

        parse_str(self::base64url_decode($token), $params);
        foreach ($fields as $f) {
            if (!array_key_exists($f, $params)) {
                throw new \UnexpectedValueException('"'. $f .'" should exists in token attributes.');
            }
        }

        $id = Identificator::load($params['id'], $config['idFields']);
        $token = new Token($id, $config);
        $token->setHash($params['h']);
        $token->setExpiration($params['e']);

        return $token;
    }
343045
protected function getConfig(Helper $component)
    {
        if ($component->config === null) {
            if ($this->getDetector()->detect() === false) {
                throw new InvalidCallException('Unable to determine application type');
            }
            $configList = $this->getDetector()->getConfig();
        } else {
            if ($this->config === null) {
                if (isset($component->config[0])) {
                    $configList = $component->config;
                } else {
                    throw new InvalidCallException('Default config list not found in component config data');
                }
            } else {
                if (isset($component->config[$this->config])) {
                    $configList = $component->config[$this->config];
                } else {
                    throw new InvalidCallException("Scope '{$this->config}' not found in component config data");
                }
            }
        }

        return $configList;
    }
1078163
public function user_templateLayout(array &$config)
    {
        $pageId = 0;
        $currentColPos = $config['flexParentDatabaseRow']['colPos'];
        $pageId = $this->getPageId($config['flexParentDatabaseRow']['pid']);
        if ($pageId > 0) {
            $templateLayouts = $this->templateLayoutsUtility->getAvailableTemplateLayouts($pageId);
            $templateLayouts = $this->reduceTemplateLayouts($templateLayouts, $currentColPos);
            foreach ($templateLayouts as $layout) {
                $additionalLayout = [
          htmlspecialchars($this->getLanguageService()->sL($layout[0])),
          $layout[1]
        ];
                array_push($config['items'], $additionalLayout);
            }
        }
    }