本文整理汇总了PHP中Anomaly\Streams\Platform\Ui\Table\TableBuilder::getFilters方法的典型用法代码示例。如果您正苦于以下问题:PHP TableBuilder::getFilters方法的具体用法?PHP TableBuilder::getFilters怎么用?PHP TableBuilder::getFilters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Anomaly\Streams\Platform\Ui\Table\TableBuilder
的用法示例。
在下文中一共展示了TableBuilder::getFilters方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: normalize
/**
* Normalize filter input.
*
* @param TableBuilder $builder
*/
public function normalize(TableBuilder $builder)
{
$filters = $builder->getFilters();
$stream = $builder->getTableStream();
foreach ($filters as $slug => &$filter) {
/**
* If the filter is a string then use
* it for everything.
*/
if (is_string($filter) && !str_contains($filter, '/')) {
$filter = ['slug' => $filter, 'field' => $filter, 'filter' => 'field'];
}
/**
* If the filter is a class string then use
* it for the filter.
*/
if (is_string($filter) && str_contains($filter, '/')) {
$filter = ['slug' => $slug, 'filter' => $filter];
}
/**
* Move the slug into the filter.
*/
if (!isset($filter['slug'])) {
$filter['slug'] = $slug;
}
/**
* Move the slug to the filter.
*/
if (!isset($filter['filter'])) {
$filter['filter'] = $filter['slug'];
}
/**
* Fallback the field.
*/
if (!isset($filter['field']) && $stream && $stream->hasAssignment($filter['slug'])) {
$filter['field'] = $filter['slug'];
}
/**
* If there is no filter type
* then assume it's the slug.
*/
if (!isset($filter['filter'])) {
$filter['filter'] = $filter['slug'];
}
/**
* Set the table's stream.
*/
if ($stream) {
$filter['stream'] = $stream;
}
}
$builder->setFilters($filters);
}
示例2: guess
/**
* Guess some table table filter placeholders.
*
* @param TableBuilder $builder
*/
public function guess(TableBuilder $builder)
{
$filters = $builder->getFilters();
$stream = $builder->getTableStream();
foreach ($filters as &$filter) {
// Skip if we already have a placeholder.
if (isset($filter['placeholder'])) {
continue;
}
// Get the placeholder off the assignment.
if ($stream && ($assignment = $stream->getAssignment(array_get($filter, 'field')))) {
/*
* Always use the field name
* as the placeholder. Placeholders
* that are assigned otherwise usually
* feel out of context:
*
* "Choose an option..." in the filter
* would just be weird.
*/
$placeholder = $assignment->getFieldName();
if ($this->translator->has($placeholder)) {
$filter['placeholder'] = $placeholder;
}
}
if (!($module = $this->modules->active())) {
continue;
}
$placeholder = $module->getNamespace('field.' . $filter['slug'] . '.placeholder');
if (!isset($filter['placeholder']) && $this->translator->has($placeholder)) {
$filter['placeholder'] = $placeholder;
}
$placeholder = $module->getNamespace('field.' . $filter['slug'] . '.name');
if (!isset($filter['placeholder']) && $this->translator->has($placeholder)) {
$filter['placeholder'] = $placeholder;
}
if (!array_get($filter, 'placeholder')) {
$filter['placeholder'] = $filter['slug'];
}
if (!$this->translator->has($filter['placeholder']) && $this->config->get('streams::system.lazy_translations')) {
$filter['placeholder'] = ucwords($this->string->humanize($filter['placeholder']));
}
}
$builder->setFilters($filters);
}
示例3: resolve
/**
* Resolve table views.
*
* @param TableBuilder $builder
*/
public function resolve(TableBuilder $builder)
{
$this->resolver->resolve($builder->getFilters(), compact('builder'));
}