\SearchWP\Attribute
\SearchWP\Attribute responsible for modeling the individual parts that make up a \SearchWP\Source. For example:
- Entry title
- Entry content
- Entry slug
- Custom Fields
- etc…
Arguments
When instantiating a new \SearchWP\Attribute an array of the following can be provided:
name(string)- A unique name. (default:
'') label(string)- Display label. (default: value of
name) default(false|integer)- If this
\SearchWP\Attributeshould be enabled by default returnint. (default:false) options(array|callable)- When provided, multiple instances of this
\SearchWP\Attributeare considered, e.g. Custom Fields each with ameta_key. (default:[]) allow_custom(boolean)- Whether user-defined
options can be added. (default:false) phrases(boolean|array)- Whether this
\SearchWP\Attributeshould support phrase based searching. (default:false) - When
arraythe following array keys apply: table(string) The database table name.column(string) The database table column to match phrases against.id(string) The database table column tracking entry IDs.data(mixed)- The data for this
\SearchWP\Attribute. (default:null) - When
callablethe following arguments are passed: id(string)\SearchWP\SourceID.chosen_option(string) The chosen\SearchWP\Attributeoptionwhen applicable.
Methods
When working with \SearchWP\Attribute there are a number of methods to consider.
get_name()- Getter for name.
get_label( $source )- Getter for label. If a
\SearchWP\Sourceis provided thesearchwp\source\attribute\labelfilter is applied. get_phrases()- Getter for phrase support argument value.
options_static()- Whether
optionsis static (as opposed tocallable). get_options()- Getter for
options. get_settings()- Getter for settings (i.e. as considered by an
\SearchWP\Engine). get_default()- Getter for
default. set_settings()(integer|array $settings)- Setter for settings (i.e. as considered by an
\SearchWP\Engine). Useintegerwhen there are nooptions, else usearraywith keys for each option and correspondingintegervalues. get_data()( $id, $option = '', $raw = false )- Getter for
data. $id(string)\SearchWP\SourceID.$option(string)optionvalue, when applicable.$raw(boolean) Whether to return the raw data, default is to tokenize.
Hooks
There are a number of hooks available to further modify the behavior of \SearchWP\Attribute:

