Provide search options

@param mixed $data Data to use for provision
@param array $options Options to use for provision
@return mixed
351699
public function provide($data = null, array $options = [])
    {
        $template = $this->getBasicTemplate('number');
        $defaultOptions = $this->getDefaultOptions($data, $options);
        $defaultOptions['input'] = ['content' => $template];

        $view = $this->config->getView();
        $content = $view->Form->control('', [
            'name' => '{{name}}',
            'value' => '{{value}}',
            'type' => 'number',
            'step' => $options['step'] ?? Setting::DEFAULT_STEP_FOR_NUMBER,
            'max' => $options['max'] ?? Setting::MAX_VALUE_FOR_NUMBER,
            'min' => $options['min'] ?? Setting::MIN_VALUE_FOR_NUMBER,
            'label' => false
        ]);

        $defaultOptions['input'] = [
            'content' => $content
        ];

        $result[$this->config->getField()] = $defaultOptions;

        return $result;
    }
1312033
protected function parseSet($data, $options)
    {
        if (empty($data)) {
            return [];
        }
        unset($options);
        $result = [];
        foreach ($data as $key => $val) {
            $item = $this->parseKey($key);
            if (is_array($val) && isset($val[0]) && in_array($val[0], ['$inc', '$set', '$unset', '$push', '$pushall', '$addtoset', '$pop', '$pull', '$pullall'])) {
                $result[$val[0]][$item] = $this->parseValue($val[1], $key);
            } else {
                $result['$set'][$item] = $this->parseValue($val, $key);
            }
        }
        return $result;
    }
428171
public function optionsQueryData(& $options) {
		// column prefix
		if (empty($options['column_prefix'])) {
			$options['column_prefix'] = $this->column_prefix;
		}
		// handle pk
		if (!array_key_exists('pk', $options)) {
			$options['pk'] = $this->pk;
		}
		$pk = $options['pk'];
		// inject tenant
		if ($this->tenant && !isset($options['where'][$this->tenant_column])) {
			$options['where'][$this->tenant_column] = \Tenant::id();
		}
		// if compound key
		if (count($pk) > 1) {
			$temp = $pk;
			$last = array_pop($temp);
			foreach ($temp as $v) {
				if (empty($options['where'][$v])) {
					return [];
				}
			}
		}
		$data = $this->get($options);
		// merge acl returned from get
		if (!empty($this->acl_get_options)) {
			$options = $this->acl_get_options;
		}
		// if compound key
		if (!empty($temp)) {
			foreach ($temp as $v) {
				// if pk is array
				if (!empty($options['where'][$v]) && is_array($options['where'][$v])) {
					$result = [];
					foreach ($options['where'][$v] as $v2) {
						if (isset($data[$v2])) {
							$result = array_merge_hard($result, $data[$v2]);
						}
					}
					$data = $result;
				} else { // regular pk
					if (!isset($data[$options['where'][$v]])) {
						return [];
					}
					$data = $data[$options['where'][$v]];
				}
			}
		}
		return $data;
	}
1333845
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);
        // Set the limit to Phinx\Db\Adapter\MysqlAdapter::BLOB_LONG
        $data->setLimit(MysqlAdapter::BLOB_LONG);

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

        return $result;
    }
305966
public function insert(&$data, array $options = array())
    {
        $document = new Document($data, $this);
        $insert = $document->insert($options);
        $data = $document->data;

        return $insert;
    }
1304225
protected function _prepareDataAndOptions($data, $options)
    {
        $options += ['validate' => true];

        $endpointName = $this->_endpoint->getAlias();
        if (isset($data[$endpointName])) {
            $data = $data[$endpointName];
        }

        $data = new ArrayObject($data);
        $options = new ArrayObject($options);
        $this->_endpoint->dispatchEvent('Model.beforeMarshal', compact('data', 'options'));

        return [(array)$data, (array)$options];
    }
1009506
protected function parsePkWhere($data, &$options)
    {
        $pk = $this->getPk($options);
        // 获取当前数据表
        $table = is_array($options['table']) ? key($options['table']) : $options['table'];
        if (!empty($options['alias'][$table])) {
            $alias = $options['alias'][$table];
        }
        if (is_string($pk)) {
            $key = isset($alias) ? $alias . '.' . $pk : $pk;
            // 根据主键查询
            if (is_array($data)) {
                $where[$key] = isset($data[$pk]) ? $data[$pk] : ['in', $data];
            } else {
                $where[$key] = strpos($data, ',') ? ['IN', $data] : $data;
            }
        } elseif (is_array($pk) && is_array($data) && !empty($data)) {
            // 根据复合主键查询
            foreach ($pk as $key) {
                if (isset($data[$key])) {
                    $attr         = isset($alias) ? $alias . '.' . $key : $key;
                    $where[$attr] = $data[$key];
                } else {
                    throw new Exception('miss complex primary data');
                }
            }
        }

        if (!empty($where)) {
            if (isset($options['where']['AND'])) {
                $options['where']['AND'] = array_merge($options['where']['AND'], $where);
            } else {
                $options['where']['AND'] = $where;
            }
        }
        return;
    }
482339
protected function createFromArrayWithContext($data, $options)
    {
        $_documentClass = $this->_documentClass;

        return $_documentClass::createFromArray($data, $options);
    }
788664
protected function parseData($data, array $options, $key = null)
    {
        $architect = new Architect();

        return $architect->parseData($data, $options['modes'], $key);
    }
147337
public function prepareSearchEntity(array $options = array())
    {
        $alias = $options['alias'];

        /**
         * @var Entity $search_entity
         */
        $search_entity = $this->controller->{$alias}->newEntity();

        $search_entity->setAccess('*', true);
        $this->controller->{$alias}->patchEntity($search_entity, $this->controller->request->getData());
        $this->controller->set(compact('search_entity'));
    }
608891
protected function renderTemplate($data, array $options)
    {
        return $this->twig->render(
            $options['template'],
            array_merge($options['context'], ['column' => $options['column'], 'data' => $data])
        );
    }
1114922
public function provide($data = null, array $options = [])
    {
        $defaultOptions = $this->getDefaultOptions($data, $options);

        $view = $this->config->getView();
        if (isset($options['element'])) {
            $template = $view->element($options['element'], [
                'options' => [
                    'fieldName' => '{{name}}',
                    'value' => '{{value}}',
                    'type' => 'timepicker',
                    'label' => false
                ]
            ]);
        } else {
            $template = $view->Form->control('', [
                'name' => '{{name}}',
                'value' => '{{value}}',
                'type' => 'text',
                'data-provide' => 'timepicker',
                'autocomplete' => 'off',
                'label' => false,
                'templates' => [
                    'input' => vsprintf($this->templates['input'], [
                        'bootstrap-timepicker timepicker',
                        'clock-o'
                    ])
                ]
            ]);
        }

        $defaultOptions['input'] = [
            'content' => $template,
            'post' => [
                [
                    'type' => 'script',
                    'content' => [
                        'CsvMigrations.dom-observer',
                        'AdminLTE./plugins/timepicker/bootstrap-timepicker.min',
                        'CsvMigrations.timepicker.init'
                    ],
                    'block' => 'scriptBottom'
                ],
                [
                    'type' => 'css',
                    'content' => 'AdminLTE./plugins/timepicker/bootstrap-timepicker.min',
                    'block' => 'css'
                ]
            ]
        ];

        $result[$this->config->getField()] = $defaultOptions;

        return $result;
    }
417215
private function filterArray(array $data, array $options)
    {
        $this->sanitized = true;

        return filter_var_array($data, $options, true);
    }
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;
    }
297808
public function provide($data = null, array $options = [])
    {
        if (! is_string($data)) {
            return '';
        }

        if ('' === $data) {
            return '';
        }

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

        $fileUpload = new FileUpload($table);

        $entities = $fileUpload->getFiles($field, $data);

        if ($entities->isEmpty()) {
            return '';
        }

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

        return $this->renderElement($element, ['entities' => $entities]);
    }
1273024
private function buildItem(array $data, array $options = [])
    {
        $options = array_merge($options, [
            'label' => $data['title'],
        ]);
        if (!empty($data['attributes'])) {
            $options['attributes'] = $data['attributes'];
        }

        // Fix routing / url / path
        if (0 < strlen($data['path'])) {
            $options['uri'] = $data['path'];
        } elseif (0 < strlen($data['route'])) {
            $options['route'] = $data['route'];
            if (!empty($data['parameters'])) {
                $options['routeParameters'] = $data['parameters'];
            }
        }

        $item = $this
            ->factory
            ->createItem($data['name'], $options)
            ->setExtra('translation_domain', false);

        // Children items
        foreach ($this->menus as $menu) {
            if ($data['id'] === intval($menu['parent'])) {
                $item->addChild($this->buildItem($menu));
            }
        }

        // Custom menu event
        if (isset($data['options']['event']) && 0 < strlen($event = $data['options']['event'])) {
            $this->dispatcher->dispatch($event, new MenuEvent($this->factory, $item));
        }

        return $item;
    }
429023
private function getLanguageOptions(array $data)
    {
        $options = new LanguageBag();

        foreach ($data as $key => $value) {
            if (substr($key, -8) == '-options') {
                $language = substr($key, 0, -8); // remove "-options"

                if (is_array($value)) {
                    $value = new LanguageBag($value);
                }

                $options->set($language, $value);
            }
        }

        return $options;
    }