Processes the given JavaScript template config and answers an array suitable for loading requirements.

@param array $config

@return array
495831
protected function processJSTemplateConfig($config)
    {
        $templates = [];
        
        foreach ($config as $key => $value) {
            
            if (is_integer($key)) {
                
                $templates[$value] = [
                    'vars' => $this->getJSVars(),
                    'id'   => $this->getHTMLID()
                ];
                
            } else {
                
                $templates[$key] = [
                    'vars' => $this->getJSTemplateVars(array_shift($value)),
                    'id'   => $this->getJSTemplateID(array_shift($value))
                ];
                
            }
            
        }
        
        return $templates;
    }
1333213
protected function processCSSConfig($config)
    {
        if (!ArrayLib::is_associative($config)) {
            return array_fill_keys(array_values($config), null); 
        }
        
        return $config;
    }
1293287
public function load($config = array())
    {
        foreach ($config as $specId => $spec) {
            if (is_string($spec)) {
                $spec = array('class' => $spec);
            }

            $file = isset($spec['src']) ? $spec['src'] : null;

            // class is whatever's explicitly set,
            $class = isset($spec['class']) ? $spec['class'] : null;

            // or the specid if nothing else available.
            if (!$class && is_string($specId)) {
                $class = $specId;
            }

            // make sure the class is set...
            if (empty($class)) {
                throw new InvalidArgumentException('Missing spec class');
            }
            $spec['class'] = $class;

            $id = is_string($specId)
                ? $specId
                : (isset($spec['id']) ? $spec['id'] : $class);

            $priority = isset($spec['priority']) ? $spec['priority'] : 1;

            // see if we already have this defined. If so, check priority weighting
            if (isset($this->specs[$id]) && isset($this->specs[$id]['priority'])) {
                if ($this->specs[$id]['priority'] > $priority) {
                    return $this;
                }
            }

            // okay, actually include it now we know we're going to use it
            if (file_exists($file)) {
                require_once $file;
            }

            // make sure to set the id for later when instantiating
            // to ensure we get cached
            $spec['id'] = $id;

//          We've removed this check because new functionality means that the 'class' field doesn't need to refer
//          specifically to a class anymore - it could be a compound statement, ala SilverStripe's old Object::create
//          functionality
//
//          if (!class_exists($class)) {
//              throw new Exception("Failed to load '$class' from $file");
//          }

            // store the specs for now - we lazy load on demand later on.
            $this->specs[$id] = $spec;

            // EXCEPT when there's already an existing instance at this id.
            // if so, we need to instantiate and replace immediately
            if (isset($this->serviceCache[$id])) {
                $this->updateSpecConstructor($spec);
                $this->instantiate($spec, $id);
            }
        }

        return $this;
    }
1335136
private function parseConfig(array $config = [])
    {
        $this->apiConfig = $this->extractGuzzleConfig($config);

        if (ConfigUtils::configurationExists($this->apiConfig, 'apiDescription')) {
            $this->apiDescription = $this->apiConfig['apiDescription'];
        }
        if (ConfigUtils::configurationExists($this->apiConfig, 'authType')) {
            $this->authType = $this->apiConfig['authType'];
        }
        if (ConfigUtils::configurationExists($this->apiConfig, 'debug')) {
            $this->debugMode = $this->apiConfig['debug'];
            if (ConfigUtils::configurationExists($this->apiConfig, 'debugLogger')) {
                $this->debugLogger = $this->apiConfig['debugLogger'];
            }
        }
    }
1185299
public function access($config = array())
    {
        $config = new KObjectConfigJson($config);
        $config->append(array(
            'name'      => 'access',
            'attribs'   => array(),
            'deselect_value' => '',
            'deselect'  => true,
            'select2' => false,
            'prompt'    => '- '.$this->getObject('translator')->translate('Select').' -'
        ))->append(array(
            'selected'  => $config->{$config->name}
        ));

        $prompt = false;

        // without &nbsp; Joomla strips the last hyphen of the prompt
        if ($config->deselect)  {
            $prompt = array((object) array('value' => $config->deselect_value, 'text'  => $config->prompt.'&nbsp;'));
        }

        $html = JHtml::_('access.level', $config->name, $config->selected, $config->attribs->toArray(), $prompt);

        if ($config->select2)
        {
            $html .= $this->getTemplate()->helper('behavior.select2', array(
                'element' => 'select[name=\"'.$config->name.'\"]'
            ));
        }
    
        return $html;
    }
1364783
public function load($config = array())
    {
        $config = new KObjectConfigJson($config);
        $config->append(array(
            'debug' => JFactory::getApplication()->getCfg('debug'),
            'wrapper_class' => array(
                JFactory::getLanguage()->isRtl() ? 'k-ui-rtl' : 'k-ui-ltr'
            )
        ));
        
        if($this->getTemplate()->decorator() === 'koowa')
        {
            $layout = $this->getTemplate()->getParameters()->layout;

            if (JFactory::getApplication()->isSite() && $layout === 'form') {
                $config->domain = 'admin';
            }
        }

        $identifier = $this->getTemplate()->getIdentifier();
        $menu       = JFactory::getApplication()->getMenu()->getActive();

        if ($identifier->type === 'com' && $menu)
        {
            if ($suffix = htmlspecialchars($menu->params->get('pageclass_sfx')))
            {
                $config->append(array(
                    'wrapper_class' => array($suffix)
                ));
            }
        }

        $html = parent::load($config);

        return $html;
    }
1109087
private function getMergedConfigValues(array $config)
    {
        $mergedConfig = array();

        foreach ($config as $paymentConfig) {
            $mergedConfig[$paymentConfig->getName()] = $paymentConfig->getValue();
        }

        return $mergedConfig;
    }
438112
public function process(array $data, array $config)
	{
		// Merge default or built-in configurations.
		$config = array_merge($this->config, $config);

		// Intersect the data given the with the data keys provided.
		$data = array_intersect_key($data, array_flip(array_keys($config)));

		// Validate and set our errors if they exist.
		$payload = $this->validator->validate($data, $config);

		// Return sanitized data if no validation errors exist.
		if( ! $payload->isStatus(Payload::STATUS_VALID))
		{
			return $payload;
		}

		// Grab payload data for more modification.
		$data = $payload->getData();

		if(array_key_exists(CrudRepository::PAGE_KEY, $data) && array_key_exists(CrudRepository::PER_KEY, $data))
		{
			$data[CrudRepository::PAGINATION_KEY] = [$data[CrudRepository::PAGE_KEY] => $data[CrudRepository::PER_KEY]];
		}

		if(array_key_exists(CrudRepository::FILTER_KEY, $data))
		{
			$data[CrudRepository::FILTER_KEY] = $data[CrudRepository::FILTER_KEY];
		}

		if(array_key_exists(CrudRepository::ORDER_KEY, $data))
		{
			$data[CrudRepository::ORDER_KEY] = $data[CrudRepository::ORDER_KEY];
		}

		if(array_key_exists(CrudRepository::EMBED_KEY, $data))
		{
			$data[CrudRepository::EMBED_KEY] = $data[CrudRepository::EMBED_KEY];
		}

		return new Payload($data, Payload::STATUS_VALID);
	}
1116728
public function loadConfig(array $config)
    {
        $this->config            = $config;
        $this->config['storage'] = rtrim($this->config['storage'], '/').'/';
    }
118034
public function process(array $backendConfig): array
    {
        if (!isset($backendConfig['entities'])) {
            return $backendConfig;
        }

        foreach ($backendConfig['entities'] as $entityName => $entityConfig) {
            foreach (['form', 'edit', 'new'] as $section) {
                if (!isset($entityConfig[$section]['exclude_fields'])) {
                    continue;
                }

                $this->ensureFieldConfigurationIsValid($entityConfig, $entityName, $section);

                $propertyNames = $this->getPropertyNamesForEntity($entityConfig, $entityName);

                // filter fields to be displayed
                $fields = [];
                foreach ($propertyNames as $propertyName) {
                    if ($this->shouldSkipField($propertyName, $entityConfig[$section]['exclude_fields'])) {
                        continue;
                    }

                    $fields[] = $propertyName;
                }

                // set it!
                $backendConfig['entities'][$entityName][$section]['fields'] = $fields;
            }
        }

        return $backendConfig;
    }
239534
protected function normalizeConfig(array $config)
    {
        foreach ($this->configModel as $elmt => $settings) {
            if (!isset($config[$elmt])) {
                $config[$elmt] = $settings['default'];
            }
        }

        foreach ($config as $elmtName => $value) {
            if (!isset($this->configModel[$elmtName])) {
                unset($config[$elmtName]);
            }
        }

        return $config;
    }
927475
public function load(IConfig $config = null) {
        if ( ! $config instanceof IConfig) {
            $config = $this->createConfig();
        }

        $configs = [];

        // load config from filesystem
        foreach ($this->getPaths() as $path) {
            $configs[] = $this->loadPath($path);
        }

        // load runtime config
        foreach ($this->getRuntimeConfigs() as $runtimeConfig) {
            $configs[] = $runtimeConfig;
        }

        $config->merge($this->processConfiguration($configs));

        return $config;
    }
499444
public function prepareMenuConfig($config): array
    {
        if (is_string($config)) {
            Configure::load($config);
            $config = Configure::read($this->_defaultConfig['configKey']);
        }

        foreach ($config as $mainItem => &$mainData) {
            if (isset($mainData['url']) && !$this->Auth->urlAllowed($mainData['url'])) {
                unset($config[$mainItem]);
                continue;
            }

            if (!empty($mainData['children']) && !$this->_hasAllowedChildren($mainData['children'])) {
                unset($config[$mainItem]);
                continue;
            }

            if (isset($mainData['shouldRender']) && !$mainData['shouldRender']()) {
                unset($config[$mainItem]);
                continue;
            }

            $this->_isItemActive($mainData);

            $visibleChildCount = 0;
            if (!empty($mainData['children'])) {
                $activeChildCount = 0;
                $visibleChildCount = count($mainData['children']);
                foreach ($mainData['children'] as $subItem => &$subData) {
                    if (isset($subData['shouldRender']) && !$subData['shouldRender']()) {
                        unset($mainData['children'][$subItem]);
                        $visibleChildCount--;
                        continue;
                    }

                    $allowed = (!isset($subData['url']) || (isset($subData['url']) && $this->Auth->urlAllowed($subData['url'])));

                    if ($allowed) {
                        if ($this->_isItemActive($subData)) {
                            $activeChildCount++;
                        }
                    } else {
                        $visibleChildCount--;
                    }
                }
                unset($subData);

                if ($activeChildCount > 1) {
                    foreach ($mainData['children'] as $subItem => &$subData) {
                        $subData['active'] = false;
                    }
                    unset($subData);
                }
            }

            // if the main item has no displayable children, remove it.
            if ($visibleChildCount === 0 && isset($config['children']) && count($config['children']) > 0) {
                unset($config[$mainItem]);
            }
        }
        unset($mainData, $subData);

        //set active status
        if (empty($this->_controllerActive)) {
            $this->_controllerActive = $this->_currentUrl['controller'];
        }
        foreach ($config as &$mainData) {
            $mainData['active'] = '';
            if (!empty($this->_actionActive) && !empty($mainData['url'])) {
                if ($mainData['url']['controller'] == $this->_controllerActive && $mainData['url']['action'] == $this->_actionActive) {
                    $mainData['active'] = true;
                }
            } elseif (!empty($mainData['url']) && $mainData['url']['controller'] == $this->_controllerActive) {
                $mainData['active'] = true;
            }
            if (!empty($mainData['children'])) {
                foreach ($mainData['children'] as &$subData) {
                    $subData['active'] = '';
                    if (!empty($this->_actionActive) && !empty($subData['url'])) {
                        if ($subData['url']['controller'] == $this->_controllerActive && $subData['url']['action'] == $this->_actionActive) {
                            $subData['active'] = true;
                            $mainData['active'] = true;
                        }
                    } elseif (!empty($subData['url']) && $subData['url']['controller'] == $this->_controllerActive) {
                        $mainData['active'] = true;
                    }
                }
            }
        }

        return $config;
    }
768503
protected function _paramsTemplate($config)
    {
        $entity = $config->entity;
        $template = $entity->alias;
        $config_file_path = ANPATH_THEMES.DS.$template.DS.'template.json';

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

        $template_config = json_decode(file_get_contents($config_file_path));

        return $this->_renderForm($template_config->fields, $entity);
    }
1090951
protected function parseConfig($config)
    {
        $parsed = [];

        foreach ($config as $key=>$value) {
            if ($value instanceof XType) {
                $parsed[$key] = $value;
                continue;
            }
            $parsed[$key] = $this->stringToType($value);
        }

        return $parsed;
    }
1041946
public function config($config)
    {
        if (is_array($config)) {
            $this->config = array_merge($this->config, $config);
        } elseif (isset($this->config[$config])) {
            return $this->config[$config];
        } else {
            return;
        }
    }
395944
public static function invoke(
        array $fieldsConfig
    ): array {
        $fieldsConfigByName = [];
        foreach ($fieldsConfig as $fieldConfig) {
            $name = Property::getRequired(
                $fieldConfig,
                FieldConfig::NAME
            );
            $fieldsConfigByName[$name] = $fieldConfig;
        }

        return $fieldsConfigByName;
    }