本文整理汇总了PHP中QueryExecutor::getFilters方法的典型用法代码示例。如果您正苦于以下问题:PHP QueryExecutor::getFilters方法的具体用法?PHP QueryExecutor::getFilters怎么用?PHP QueryExecutor::getFilters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueryExecutor
的用法示例。
在下文中一共展示了QueryExecutor::getFilters方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: registerFilters
private function registerFilters()
{
$command = $this->register('filters');
// set description
$command->setDescription('Returns possible filters for query');
// set arguments
$command->setDefinition(array(new InputOption('filters', null, InputOption::VALUE_REQUIRED, 'Formatted filters: filter1=value1,value2;filter2=value3,value4'), new InputArgument('query', InputArgument::REQUIRED, 'Query')));
// set action
$command->setCode(function (InputInterface $input, OutputInterface $output) {
// get argument id
$query = $input->getArgument('query');
$setting = SettingsStorage::getInstance();
$code = $setting->getById('code');
$key = $setting->getById('key');
if (empty($code)) {
$code = 1;
} else {
$code = (int) $code['value'];
}
if (empty($key)) {
$output->writeln("Allegro web api key not set, use 'config key XXXXXX' to configure");
return;
} else {
$key = $key['value'];
}
$filters = $input->getOption('filters');
$api = new AllegroApi($key, $code);
// returns filters
foreach (QueryExecutor::getFilters($api, $query, $filters) as $filter) {
$output->writeln(sprintf("<info>%-30s</info>\t%-30s\n%s\n", "<info>{$filter['name']} " . ($filter['range'] ? '=[min,max]' : '') . "</info>", $filter['description'], implode(', ', array_map(function ($item) {
return "{$item['value']} - '{$item['name']}'";
}, $filter['values']))));
}
});
}