class FacetedCategoryChoice extends FacetedCategory

Facet filter, with multiple items to choose from

Traits

Constants

DISPLAY_TYPE_CHECKBOX

DISPLAY_TYPE_TEXT

DISPLAY_TYPE_DATE

DISPLAY_TYPE_TOGGLE

Properties

protected FacetedFilter $faceted from  FacetedCategory
protected I18nTokenHelper $label from  FacetedCategory
protected array $defaultValues from  FacetedCategory
protected bool $hasMoreItems from  FacetedCategory
protected bool $showEmptyItems from  FacetedCategory
protected bool $showInMoreOnly from  FacetedCategory
protected bool $showItemCount from  FacetedCategory
protected Closure|string|null $callback from  FacetedCategory
protected string $modelProperty

Methods

__construct()

Constructor

string
__toString()

No description

addDefaultValue(string $defaultValue)

Adds a default value for this category.

addItem(string $itemLabel, Condition $condition, string $value = '', bool $default = false, bool $active = false, int|null $count = null)

Adds a FacetedCategoryItem to the $item array

addScopeCondition(Collection $collection, array $active)

No description

void
autoBuildItems(Collection $collection, int $limit, string $query = '')

No description

int
count()

No description

static ItemListTrait
create(ItemInterface ...$items)

No description

static FacetedCategory
createCategory(FacetedFilter $faceted, I18nTokenHelper $label)

No description

ItemInterface|null
first()

Get first element

array
getActiveItems()

Returns items of this category, which are active

array
getDefaultValues()

getter

string
getDisplayType()

No description

bool
getHasMoreItems()

No description

string
getIconClass()

No description

array
getItems()

No description

getIterator()

No description

string
getKey()

No description

getLabel()

No description

OptionList|null
getLabelOptionList()

No description

array
getOptions()

Returns the options array used mainly by the vue component

bool
getShowInMoreOnly()

Getter for showInMoreOnly

bool
getShowItemCount()

No description

bool
hasCallback()

Does category have a callback?

bool
hasItems()

Are FacetedCategoryItems defined?

void
invokeCallBack(Collection $collection, array $selectedCategoryValues = [])

No description

bool
isRequired()

No description

array
jsonSerialize()

No description

ItemInterface|null
last()

Return the last element

bool
offsetExists($offset)

No description

ItemInterface|null
offsetGet($offset)

No description

void
offsetSet($offset, $value)

No description

void
offsetUnset($offset)

No description

int
push(ItemInterface $item)

No description

pushItem(FacetedCategoryItem $item)

Adds an item to the ItemList

setActive(array $values)

Sets items to active based on the given $values

setCallback(Closure $callback)

Sets the callback to filter the $collection

setDefaultValues(array $defaultValues)

Set the default value(s) for this category

void
setDefaults()

Use setDefaultValues() to set the default values.

setFilterProperty(string $propertyName)

The property name of the model to filter

setIconClass(string $iconClass)

No description

void
setItems(array $items)

No description

setKey(string $key)

No description

setLabelList(OptionListCollectionInterface|null $labelList)

The option list to use as label map for the values of the $property

setRequired(bool $required)

No description

setShowEmptyItems(bool $show = true)

If enabled, the category will also show items with a hit count of 0

setShowInMoreOnly(bool $show = true)

If enabled, the category will only be shown in the "more filters" section

setShowItemCount(bool $showItemCount = true)

No description

void
sortItems()

Sorts the category items by hit count (descending)

array
toArray()

Transforms the option into an array.

int
unshift(ItemInterface $item)

No description

Details

in FacetedCategory at line 368
protected __construct()

Constructor

in FacetedCategory at line 372
string __toString()

No description

Return Value

string

in FacetedCategory at line 197
FacetedCategory addDefaultValue(string $defaultValue)

Adds a default value for this category.

Parameters

string $defaultValue

Return Value

FacetedCategory

at line 294
FacetedCategoryChoice addItem(string $itemLabel, Condition $condition, string $value = '', bool $default = false, bool $active = false, int|null $count = null)

Adds a FacetedCategoryItem to the $item array

Parameters

string $itemLabel
Condition $condition
string $value
bool $default
bool $active
int|null $count

Return Value

FacetedCategoryChoice

at line 217
Collection addScopeCondition(Collection $collection, array $active)

No description

Parameters

Collection $collection
array $active

The active values

Return Value

Collection

at line 52
void autoBuildItems(Collection $collection, int $limit, string $query = '')

No description

Parameters

Collection $collection

A cloned model collection scoped by all other active facets

int $limit

The max item limit to display

string $query

Search query that restricts the items

Return Value

void

in ItemListTrait at line 147
int count()

No description

Return Value

int

in ItemListTrait at line 37
static ItemListTrait create(ItemInterface ...$items)

No description

Parameters

ItemInterface ...$items

Return Value

ItemListTrait

at line 39
static FacetedCategory createCategory(FacetedFilter $faceted, I18nTokenHelper $label)

No description

Parameters

FacetedFilter $faceted
I18nTokenHelper $label

Return Value

FacetedCategory

in ItemListTrait at line 96
ItemInterface|null first()

Get first element

Return Value

ItemInterface|null

in FacetedCategory at line 308
array getActiveItems()

Returns items of this category, which are active

Return Value

array

in FacetedCategory at line 218
array getDefaultValues()

getter

Return Value

array

at line 29
string getDisplayType()

No description

Return Value

string

in FacetedCategory at line 115
bool getHasMoreItems()

No description

Return Value

bool

in FacetedCategory at line 122
string getIconClass()

No description

Return Value

string

in ItemListTrait at line 57
array getItems()

No description

Return Value

array

in ItemListTrait at line 107
ArrayIterator getIterator()

No description

Return Value

ArrayIterator

in FacetedCategory at line 361
string getKey()

No description

Return Value

string

in FacetedCategory at line 103
I18nTokenHelper getLabel()

No description

Return Value

I18nTokenHelper

at line 275
protected OptionList|null getLabelOptionList()

No description

Return Value

OptionList|null

in FacetedCategory at line 226
array getOptions()

Returns the options array used mainly by the vue component

Return Value

array $options

in FacetedCategory at line 187
bool getShowInMoreOnly()

Getter for showInMoreOnly

Return Value

bool

in FacetedCategory at line 418
bool getShowItemCount()

No description

Return Value

bool

in FacetedCategory at line 398
bool hasCallback()

Does category have a callback?

Return Value

bool

in FacetedCategory at line 111
bool hasItems()

Are FacetedCategoryItems defined?

Return Value

bool

in FacetedCategory at line 408
void invokeCallBack(Collection $collection, array $selectedCategoryValues = [])

No description

Parameters

Collection $collection
array $selectedCategoryValues

Return Value

void

in FacetedCategory at line 142
bool isRequired()

No description

Return Value

bool

in ItemListTrait at line 154
array jsonSerialize()

No description

Return Value

array

in ItemListTrait at line 88
ItemInterface|null last()

Return the last element

Return Value

ItemInterface|null

in ItemListTrait at line 116
bool offsetExists($offset)

No description

Parameters

$offset

Return Value

bool

in ItemListTrait at line 125
ItemInterface|null offsetGet($offset)

No description

Parameters

$offset

Return Value

ItemInterface|null

in ItemListTrait at line 133
void offsetSet($offset, $value)

No description

Parameters

$offset
$value

Return Value

void

in ItemListTrait at line 140
void offsetUnset($offset)

No description

Parameters

$offset

Return Value

void

in ItemListTrait at line 44
int push(ItemInterface $item)

No description

Parameters

ItemInterface $item

Return Value

int

in FacetedCategory at line 325
FacetedCategory pushItem(FacetedCategoryItem $item)

Adds an item to the ItemList

Parameters

FacetedCategoryItem $item

Return Value

FacetedCategory

in FacetedCategory at line 240
FacetedCategory setActive(array $values)

Sets items to active based on the given $values

Parameters

array $values

Return Value

FacetedCategory

in FacetedCategory at line 389
FacetedCategory setCallback(Closure $callback)

Sets the callback to filter the $collection

Parameters

Closure $callback

Return Value

FacetedCategory

in FacetedCategory at line 209
FacetedCategory setDefaultValues(array $defaultValues)

Set the default value(s) for this category

Parameters

array $defaultValues

Return Value

FacetedCategory

in FacetedCategory at line 262
void setDefaults()

Use setDefaultValues() to set the default values.

Calls the setDefault() and setActive() methods for items that are default values. (if the category has no active item)

Return Value

void

at line 255
FacetedCategoryChoice setFilterProperty(string $propertyName)

The property name of the model to filter

Parameters

string $propertyName

Return Value

FacetedCategoryChoice

in FacetedCategory at line 132
FacetedCategory setIconClass(string $iconClass)

No description

Parameters

string $iconClass

Return Value

FacetedCategory

in ItemListTrait at line 66
void setItems(array $items)

No description

Parameters

array $items

Return Value

void

in FacetedCategory at line 350
FacetedCategory setKey(string $key)

No description

Parameters

string $key

Return Value

FacetedCategory

Exceptions

Exception

at line 267
FacetedCategoryChoice setLabelList(OptionListCollectionInterface|null $labelList)

The option list to use as label map for the values of the $property

Parameters

OptionListCollectionInterface|null $labelList

Return Value

FacetedCategoryChoice

in FacetedCategory at line 152
FacetedCategory setRequired(bool $required)

No description

Parameters

bool $required

Return Value

FacetedCategory

in FacetedCategory at line 166
FacetedCategory setShowEmptyItems(bool $show = true)

If enabled, the category will also show items with a hit count of 0

Parameters

bool $show

Return Value

FacetedCategory

in FacetedCategory at line 178
FacetedCategory setShowInMoreOnly(bool $show = true)

If enabled, the category will only be shown in the "more filters" section

Parameters

bool $show

Return Value

FacetedCategory

in FacetedCategory at line 422
FacetedCategory setShowItemCount(bool $showItemCount = true)

No description

Parameters

bool $showItemCount

Return Value

FacetedCategory

in FacetedCategory at line 295
protected void sortItems()

Sorts the category items by hit count (descending)

Return Value

void

in ItemListTrait at line 74
array toArray()

Transforms the option into an array.

Return Value

array

in ItemListTrait at line 49
int unshift(ItemInterface $item)

No description

Parameters

ItemInterface $item

Return Value

int