Generate an array of sortable attribute defintions from a ngrest config object.

@param Config $config The Ngrest Config object
@return array
@since 2.0.0
176199
public function generateSortAttributes(Config $config)
    {
        $sortAttributes = [];
        foreach ($config->getPointerPlugins('list') as $plugin) {
            $sortAttributes = ArrayHelper::merge($plugin->getSortField(), $sortAttributes);
        }

        return $sortAttributes;
    }
1202924
public function addFieldsFromConfig(array $config)
    {
        $i = 1;
        foreach ($config as $name => $field) {
            if (is_numeric($name) && !isset($field[$name]['type'])) {
                $fields = [];
                foreach ($field as $n => $f) {
                    $fields[$n] = Fields::create($n, $f);
                }
                if ($i > 1) {
                    $this->fieldsets[$this->current]->createGroup();
                }
                $this->fieldsets[$this->current]->addFields($fields);
                $i++;
            } else {
                $this->addField(Fields::create($name, $field));
            }
        }
        return $this;
    }
1358321
protected function parseDescriptorField($config)
    {
        if (is_array($config)) {
            $descriptor = [];
            foreach ($config as $field) {
                if (!empty($this->{$field})) {
                    $descriptor[] = $this->{$field};
                }
            }

            return implode(' ', $descriptor);
        } else {
            return $this->{$config};
        }
    }
1081956
public static function createFromConfig(array $config)
    {
        $fields = [];
        foreach ($config as $name => $field) {
            $fields[$name] = Fields::create($name, $field);
        }
        return new static($fields);
    }
36038
private function getServiceParams(array $config)
    {
        return [
            'endpoint' => $this->getParamOrFail($config, 'endpoint'),
            'headers'  => $this->getParam($config, 'headers', []),
            'query'    => $this->getParam($config, 'query', []),
            'body'     => $this->getParam($config, 'body', []),
            'version'  => $this->getParam($config, 'version', '1.1'),
            'retries'  => $this->getParam($config, 'retries', 0),
            'options'  => $this->getParam($config, 'options', []),
        ];
    }
320392
protected function normalizeConfig(array $config)
    {
        $final = [];
        foreach ($config as $key => $value) {
            if (is_array($value)) {
                $final[$key] = $this->normalizeConfig($value);
            } else {
                $final[$value] = [];
            }
        }

        return $final;
    }
940451
private function configureOptions(array $config): array
    {
        $resolver = new OptionsResolver();
        $resolver->setDefaults([
            'device' => [],
        ]);

        $resolver->setRequired(['message']);
        $resolver->setAllowedTypes('message', 'array');
        $resolver->setAllowedTypes('device', 'array');

        $options = $resolver->resolve($config);

        $deviceResolver = new OptionsResolver();
        $options['device'] = $deviceResolver->resolve($options['device']);

        $messageResolver = new OptionsResolver();
        $messageResolver->setRequired(['defaultTitle', 'defaultMediaUrl', 'defaultActionUrl']);

        $messageResolver->setAllowedTypes('defaultTitle', 'string');
        $messageResolver->setAllowedTypes('defaultMediaUrl', 'string');
        $messageResolver->setAllowedTypes('defaultActionUrl', 'string');

        $options['message'] = $messageResolver->resolve($options['message']);

        return $options;
    }
607765
protected function getParametrizationValues(array $config)
    {
        $result = [
            'elcodi.entity.currency.class' => $config['mapping']['currency']['class'],
            'elcodi.entity.currency.mapping_file' => $config['mapping']['currency']['mapping_file'],
            'elcodi.entity.currency.manager' => $config['mapping']['currency']['manager'],
            'elcodi.entity.currency.enabled' => $config['mapping']['currency']['enabled'],

            'elcodi.entity.currency_exchange_rate.class' => $config['mapping']['currency_exchange_rate']['class'],
            'elcodi.entity.currency_exchange_rate.mapping_file' => $config['mapping']['currency_exchange_rate']['mapping_file'],
            'elcodi.entity.currency_exchange_rate.manager' => $config['mapping']['currency_exchange_rate']['manager'],
            'elcodi.entity.currency_exchange_rate.enabled' => $config['mapping']['currency_exchange_rate']['enabled'],

            'elcodi.default_currency' => $config['currency']['default_currency'],
            'elcodi.currency_session_field_name' => $config['currency']['session_field_name'],
        ];

        return $result;
    }
836713
protected function getOptionsFromConfig(Config $config)
    {
        $options = new CreateBlobOptions();

        foreach (static::$metaOptions as $option) {
            if ( ! $config->has($option)) {
                continue;
            }

            call_user_func([$options, "set$option"], $config->get($option));
        }

        if ($mimetype = $config->get('mimetype')) {
            $options->setContentType($mimetype);
        }

        return $options;
    }
1234909
protected function buildColumns(array $config)
    {
        $columns = [];

        foreach (isset($config['columns']) ? $config['columns'] : [] as $name => $column) {
            $column = $this->buildColumn(array_merge(['name' => $name], $column), $config);
            $columns[$column->getName()] = $column;
        }

        return $columns;
    }
1162523
public function optionlist($config = array())
    {
        $config = new ObjectConfigJson($config);
        $config->append(array(
            'options'   => array(),
            'name'      => 'id',
            'selected'  => null,
            'disabled'  => null,
            'translate' => false,
            'attribs'   => array('size' => 1),
        ));

        $html = array();

        $html[] = '<select name="'. $config->name .'" '. $this->buildAttributes($config->attribs) .'>';

        foreach($config->options as $group => $options)
        {
            if (is_numeric($group)) {
                $options = array($options);
            } else {
                $html[] = '<optgroup label="' . StringEscaper::attr($group) . '">';
            }

            foreach ($options as $option)
            {
                $value = $option->value;
                $label = $config->translate ? $this->getObject('translator')->translate( $option->label ) : $option->label;

                $extra = '';
                if(isset($option->disabled) && $option->disabled) {
                    $extra .= 'disabled="disabled"';
                }

                if(isset($option->attribs)) {
                    $extra .= ' '.$this->buildAttributes($option->attribs);
                }

                if(!is_null($config->selected))
                {
                    if ($config->selected instanceof ObjectConfig)
                    {
                        foreach ($config->selected as $selected)
                        {
                            $sel = is_object($selected) ? $selected->value : $selected;
                            if ((string) $value == (string) $sel)
                            {
                                $extra .= 'selected="selected"';
                                break;
                            }
                        }
                    }
                    else $extra .= ((string) $value == (string) $config->selected ? ' selected="selected"' : '');
                }

                $html[] = '<option value="'. $value .'" '.$extra.'>' . $label . '</option>';
            }

            if (!is_numeric($group)) {
                $html[] = '</optgroup>';
            }
        }

        $html[] = '</select>';

        return implode(PHP_EOL, $html);
    }
565416
protected function encodeConfiguration($config = [])
    {
        $value = [];
        ksort($config);
        foreach ($config as $directive => $values) {
            $values = array_unique($values);
            sort($values);
            array_unshift($values, $directive);
            $string = implode($this->sourceSeparator, $values);

            if ($string) {
                $value[] = $string;
            }
        }

        return implode($this->directiveSeparator . ' ', $value);
    }
1097158
public function getOptions(array $config)
    {
        $options = array_get($config, 'options', array());

        return array_diff_key($this->options, $options) + $options;
    }
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);
  }
1213370
public function option($config = array())
    {
        $config = new ObjectConfigJson($config);
        $config->append(array(
            'id'        => null,
            'name'      => 'id',
            'value'     => null,
            'label'     => '',
            'disabled'  => false,
            'level'     => 1,
            'attribs'   => array(),
        ));

        $option = new \stdClass;
        $option->id       = $config->id;
        $option->name     = $config->name;
        $option->value 	  = $config->value;
        $option->label    = trim( $config->label ) ? $config->label : $config->value;
        $option->disabled = $config->disabled;
        $option->level    = $config->level;
        $option->attribs  = ObjectConfig::unbox($config->attribs);

        if($config->level) {
            $option->attribs['class'] = array('level'.$config->level);
        }

        if($config->disabled) {
            $option->attribs['class'] = array('k-is-disabled', 'disabled');
        }

        return $option;
    }
407487
public function transform(string $config = ''): array
    {
        $parsed = [];

        if (!\extension_loaded('php_yaml')) {
            return $parsed;
        }
        if (!empty($config)) {
            $parsed = \yaml_parse($config);
            $parsed = $parsed !== null ? $parsed : [];
        }

        return $parsed;
    }
137948
public function getIdList( $config = [] ) {

		$modelClass	= static::$modelClass;
		$modelTable	= $this->getModelTable();

		$config[ 'conditions' ][ "$modelTable.type" ] = static::$parentType;

		return parent::getIdList( $config );
	}