Provide select options

@param mixed $data Data to use for provision
@param array $options Options to use for provision
@return array
420157
public function provide($data = null, array $options = []) : array
    {
        $spacer = isset($options['spacer']) ? (string)$options['spacer'] : ' - ';
        $flatten = isset($options['flatten']) ? (bool)$options['flatten'] : true;

        list($module, $list) = false !== strpos($data, '.') ?
            explode('.', $data, 2) :
            [App::shortName(get_class($this->config->getTable()), 'Model/Table', 'Table'), $data];

        $result = [];
        try {
            $config = new ModuleConfig(ConfigType::LISTS(), $module, $list, ['flatten' => $flatten, 'filter' => true]);
            $config = $config->parse();
            if (! property_exists($config, 'items')) {
                return [];
            }

            $config = json_encode($config->items);
            if (false === $config) {
                return [];
            }

            $result = json_decode($config, true);
        } catch (InvalidArgumentException $e) {
            /* Do nothing.
             *
             * ModuleConfig checks for the file to exist and to be readable and so on, but here we do load lists
             * recursively (for sub-lists, etc), which might result in files not always being there.
             *
             * In this particular case, it's not the end of the world.
             */
            return [];
        }

        if (empty($result)) {
            return [];
        }

        if (! $flatten) {
            return $result;
        }

        foreach ($result as $key => $value) {
            $result[$key] = str_repeat($spacer, substr_count($key, '.')) . $value['label'];
        }

        return $result;
    }
436319
public function insert($data, $options = [])
    {
        return $this->database->createCommand()->insert($this->name, $data, $options);
    }
772173
public function createForm($data = null, array $options = [])
    {
        return $this->formFactory->create(NodeFormType::class, $data, $options);
    }
240681
public function provide($data = null, array $options = [])
    {
        $result = (string)$data;

        if (empty($result)) {
            return $result;
        }

        // Sanitize
        $result = filter_var($result, FILTER_SANITIZE_EMAIL);
        if ($result === false) {
            // If you find a case where FILTER_SANITIZE_EMAIL fails, add
            // a unit test to EmailRendererTest and remove annotations here.
            // @codeCoverageIgnoreStart
            throw new InvalidArgumentException("Failed to sanitize email");
            // @codeCoverageIgnoreEnd
        }

        // Only link to valid emails, to avoid unpredictable behavior
        if (filter_var($result, FILTER_VALIDATE_EMAIL) === false) {
            return $result;
        }

        $view = $this->config->getView();
        $result = $view->Html->link($result, 'mailto:' . $result, ['target' => '_blank']);

        return $result;
    }
662722
public function provide($data = null, array $options = [])
    {
        $result = parent::provide($data, $options);
        $errorResponse = sprintf(parent::VALUE_NOT_FOUND_HTML, $data);

        //In case the result is empty or its the same with the errorResponse then return the result
        if (empty($result) || $errorResponse == $result) {
            return $result;
        } else {
            return sprintf(static::ICON_HTML, strtolower($data), $result);
        }
    }
522465
public function provide($data = null, array $options = [])
    {
        if (!$data instanceof CsvField) {
            throw new InvalidArgumentException("Given data is not an instance of CsvField");
        }

        $data->setType($this->dbFieldType);

        $dbField = DbField::fromCsvField($data);
        $limit = (string)$dbField->getLimit();
        if (! empty($limit) && false !== strpos($limit, '.')) {
            list($precision, $scale) = explode('.', $limit);
            $fieldOptions = $dbField->getOptions();
            $fieldOptions['precision'] = $precision;
            $fieldOptions['scale'] = $scale;
            $dbField->setOptions($fieldOptions);
        }

        $result = [
            $data->getName() => $dbField,
        ];

        return $result;
    }
243683
public function options($url, $data = array())
    {
        if (is_array($url)) {
            $data = $url;
            $url = $this->baseUrl;
        }
        $this->setUrl($url, $data);
        $this->removeHeader('Content-Length');
        $this->setOpt(CURLOPT_CUSTOMREQUEST, 'OPTIONS');
        return $this->exec();
    }
479694
public function make(array $data = null, array $options = null)
    {
        $data = $data ? $data : $this->getData();
        $this->setData($data);

        $options = $options ? $options : $this->getOptions();
        $options = array_replace_recursive($this->getDefaults(), $options);
        $this->setOptions($options);




        if ($this->isShowRowCheckbox()) {
            $this->addRowCheckbox();
        }

        if ($this->isShowRowIndex()) {
            $this->addRowIndex();
        }

        if ($this->isShowColSearch()) {
            $this->addColSearch();
        }

        $options = $this->getOptions();
        $data = $this->getData();

        $attributes = [];

        // Attributes for wrappers
        $attributes['table'] = $this->getAttributes('table', $options);
        $attributes['caption'] = $this->getAttributes('caption', $options);
        $attributes['colgroup'] = $this->getAttributes('colgroup', $options);
        $attributes['thead'] = $this->getAttributes('thead', $options);
        $attributes['tbody'] = $this->getAttributes('tbody', $options);
        $attributes['tfoot'] = $this->getAttributes('tfoot', $options);

        // caption
        $caption = isset($options['caption']['value']) ?
            $options['caption']['value'] : '';

        // colgroup data
        $cols = '';
            if (is_array($options['colgroup']) && $this->isShowColgroup()) {
            $colsData = isset($options['colgroup']['value']) ?
                $options['colgroup']['value'] : array_slice($data, 0, 1);
            $cols = $this->getColgroup($colsData, $options);
        }

        // thead data
        $thead_rows = '';
        if (is_array($options['thead']) && $this->isShowThead()) {
            $theadData = isset($options['thead']['value']) ?
                $options['thead']['value'] : array_slice($data, 0, 1);
            $theadData = is_callable($theadData) ? $theadData($data) : $theadData;
            $thead_rows = $this->getGrid($theadData, 'thead_tr', 'th',
                $options);
        }

        // tfoot data
        $tfoot_rows = '';
        if (is_array($options['tfoot']) && $this->isShowTfoot()) {
            $tfootData = isset($options['tfoot']['value']) ?
                $options['tfoot']['value'] : null;
            $tfootData = is_callable($tfootData) ? $tfootData($data) : $tfootData;
            $tfoot_rows = $this->getGrid($tfootData, 'tfoot_tr', 'tfoot_td',
                $options);
        }

        // tbody data
        $tbody_rows = $this->getGrid($data, 'tr', 'td', $options);

        // Render wrappers
        $caption = empty($caption) ?
            '' : sprintf($options['caption']['tag'], $attributes['caption'],
                $caption);

        $colgroup = empty($cols) ?
            '' : sprintf($options['colgroup']['tag'], $attributes['colgroup'],
                $cols);

        $thead = empty($thead_rows) ?
            '' : sprintf($options['thead']['tag'], $attributes['thead'],
                $thead_rows);

        $tbody = sprintf($options['tbody']['tag'], $attributes['tbody'],
            $tbody_rows);

        $tfoot = empty($tfoot_rows) ?
            '' : sprintf($options['tfoot']['tag'], $attributes['tfoot'],
                $tfoot_rows);

        $table = $caption .$colgroup . $thead . $tbody . $tfoot;

        return sprintf($options['table']['tag'], $attributes['table'], $table);
    }
249733
public function deserialize(array $data, Options $options = null)
    {
        if (empty($options)) {
            $options = $this->optionsRepo->findOneBy(['id' => $data['id']]);
        }
        if (empty($options)) {
            $options = new Options();
        }
        if (isset($data['user'])) {
            $user = isset($data['user']['id']) ? $this->userRepo->findOneBy(['uuid' => $data['user']['id']]) : null;
            $options->setUser($user);
        }
        if (isset($data['data'])) {
            $options->setOptions($data['data']);
        }

        return $options;
    }
1323036
public function update($data, $options)
    {
        $set  = [];
        $data = $this->parseData($data, $options);
        if (empty($data)) {
            return '';
        }
        foreach ($data as $key => $val) {
            $set[] = $key . '=' . $val;
        }

        $sql = str_replace(
            ['%TABLE%', '%SET%', '%JOIN%', '%WHERE%', '%ORDER%', '%LIMIT%', '%LOCK%', '%COMMENT%'],
            [
                $this->parseTable($options['table'], $options),
                implode(',', $set),
                $this->parseJoin($options['join'], $options),
                $this->parseWhere($options['where'], $options),
                $this->parseOrder($options['order'], $options),
                $this->parseLimit($options['limit']),
                $this->parseLock($options['lock']),
                $this->parseComment($options['comment']),
            ], $this->updateSql);

        return $sql;
    }
625541
public function provide($data = null, array $options = [])
    {
        $selectListItems = $this->config->getProvider('selectOptions');
        $selectListItems = new $selectListItems($this->config);
        $listName = $options['fieldDefinitions']->getLimit();

        $selectOptions = $selectListItems->provide($listName, ['symbol']);

        foreach ($selectOptions as $k => $v) {
            $selectOptions[$k] = CurrencyValueRenderer::getIcon($v, $v);
        }

        $options['selectOptions'] = $selectOptions;
        $options['element'] = 'CsvMigrations.FieldHandlers/CurrencyFieldHandler/input';

        return parent::provide($data, $options);
    }
108427
public function provide($data = null, array $options = [])
    {
        $combinedFields = $this->config->getProvider('combinedFields');
        $combinedFields = new $combinedFields($this->config);
        $combinedFields = $combinedFields->provide($data, $options);

        $result = [];
        $view = $this->config->getView();
        foreach ($combinedFields as $suffix => $fieldOptions) {
            $fieldName = $this->config->getField() . '_' . $suffix;

            if (empty($data)) {
                $data = $options['entity'];
            }
            $config = new $fieldOptions['config']($fieldName, $this->config->getTable());
            $config->setView($view);

            $handler = new FieldHandler($config);
            $result[] = $handler->renderValue($data, $options);
        }

        return implode('&nbsp;', $result);
    }
550829
public function add(array $data, array $options = array())
    {
        $result = array();
        $this->hook->attach('order.submit.before', $data, $options, $result, $this);

        if (!empty($result)) {
            return (array) $result;
        }

        $data['order_id'] = $this->order->add($data);

        if (empty($data['order_id'])) {
            return $this->getResultError();
        }

        $order = $this->order->get($data['order_id']);
        $this->setBundledProducts($order, $data);

        if (empty($options['admin'])) {
            $this->setPriceRules($order);
            $this->updateCart($order, $data['cart']);
            $this->notifyCreated($order);
            $result = $this->getResultAdded($order);
        } else {
            $this->cloneCart($order, $data['cart']);
            $result = $this->getResultAddedAdmin($order);
        }

        $this->hook->attach('order.submit.after', $data, $options, $result, $this);
        return (array) $result;
    }
39322
public function provide($data = null, array $options = [])
    {
        $field = $this->config->getField();
        $table = $this->config->getTable();

        $fieldName = $table->aliasField($field);

        $list = $options['fieldDefinitions']->getListName();
        $table = TableRegistry::get('CsvMigrations.Dblists');
        Assert::isInstanceOf($table, DblistsTable::class);

        $params = [
            'field' => $field,
            'name' => $fieldName,
            'type' => 'select',
            'label' => $options['label'],
            'required' => $options['fieldDefinitions']->getRequired(),
            'value' => $data,
            'options' => array_merge(
                ['' => Setting::EMPTY_OPTION_LABEL()],
                $table->getOptions($list)
            ),
            'extraClasses' => (!empty($options['extraClasses']) ? implode(' ', $options['extraClasses']) : ''),
            'attributes' => empty($options['attributes']) ? [] : $options['attributes'],
        ];

        $defaultElement = 'CsvMigrations.FieldHandlers/DblistFieldHandler/input';
        $element = empty($options['element']) ? $defaultElement : $options['element'];

        return $this->renderElement($element, $params);
    }
302822
public static function generateSelectOptions( $data, $selected = null, $key1, $key2 ) {

		$options	= "";

		if( isset( $data ) ) {

			if( isset($selected) ) {

				foreach ( $data as $key => $value ) {

					$val	= $value[ $key1 ];
					$option = $value[ $key2 ];

					if( $selected === $val ) {

						$options .= "<option value='$val' selected>$option</option>";
					}
					else {
						$options .= "<option value='$val'>$option</option>";
					}
				}
			}
			else {

				foreach ( $data as $key => $value ) {

					$val	= $value[ $key1 ];
					$option = $value[ $key2 ];

					$options .= "<option value='$val'>$option</option>";
				}
			}
		}

		return $options;
	}
347423
protected function prepareResult(&$data, array $options)
    {
        if (!empty($options['unserialize']) && !empty($data)) {
            foreach ((array) $options['unserialize'] as $field) {
                $data[$field] = empty($data[$field]) ? array() : unserialize($data[$field]);
            }
        }
    }
979131
public function provide($data = null, array $options = [])
    {
        if (empty($options['entity'])) {
            return null;
        }

        $table = $this->config->getTable();

        // return null in cases where no table or a dummy table was provided by the config class
        try {
            $primaryKey = $table->getPrimaryKey();
        } catch (Exception $e) {
            return null;
        }

        if (! is_string($primaryKey)) {
            throw new UnsupportedPrimaryKeyException();
        }

        if ($options['entity'] instanceof EntityInterface) {
            return $options['entity']->get($primaryKey);
        }

        if ($options['entity'] instanceof ServerRequest) {
            return $options['entity']->getData($primaryKey);
        }

        return null;
    }