Overview

Namespaces

  • Apptus
    • ESales
      • Connector
        • Report
        • Time
    • Util
      • Cache
  • PHP

Classes

  • Ad
  • Ads
  • ArgMap
  • Attribute
  • AttributeValidation
  • Authorization
  • Category
  • CategoryData
  • CategoryList
  • CategoryNode
  • CloudConnector
  • ClusterUriIterator
  • Completion
  • Completions
  • CompressionMode
  • Connector
  • ConnectorSettingsBuilder
  • Correction
  • Corrections
  • Count
  • CssClass
  • CustomerKeyAuthentication
  • DynamicPage
  • EventDataJobResult
  • FacetList
  • FacetRange
  • Facets
  • Filter
  • FilterBuilder
  • ImportData
  • JavaScriptNotifier
  • MessageAuthentication
  • OnPremConnector
  • Order
  • OrderLine
  • Panel
  • PanelContent
  • Path
  • Phrase
  • Phrases
  • Product
  • Products
  • Reporter
  • ResultType
  • Session
  • Status
  • Subpanel
  • Value
  • Values
  • Variant

Interfaces

  • Facet
  • Result

Exceptions

  • BusyClusterException
  • ClusterUnavailableException
  • DuplicateSubpanelException
  • FetchClusterException
  • IOException
  • MalformedJsonException
  • MalformedURLException
  • MissingSubpanelException
  • PanelException
  • ParseException
  • ReportException
  • RequestFailedException
  • ResultTypeException
  • Overview
  • Namespace
  • Class
  • Tree

Class Facets

Class for creating a facets argument, used for check-box navigation. It also has support for parsing and toggling facet values, so it can be used to keep track of selection changes.

Example:

$f = (new Facets('color', 'yellow', 'blue'))->add('brand', 'nike');
// ((string) $f) is: brand:nike,color:blue|yellow
$panelArguments = new ArgMap();
$panelArguments['facets'] = $f;
// ... other arguments...

If it is convenient for your scenario you can serialize the current selected values by converting it to string and store them in the browser. When a check-box is clicked, deserialize it afterwards like this:

$f = Facets::parse($facetsString);

Then update it with the last click and send a new request:

$f = $f->toggle($clickedAttribute, $clickedValue);
$panelArguments['facets'] = $f;
// ... add other arguments and send request...

Note that Facets are immutable and all methods return new Facets objects.

Namespace: Apptus\ESales\Connector
Located at Connector/Facets.php
Methods summary
public
# __construct( attribute $attribute = null, values $values = null )

Create a new empty Facets, or if provided, with the given attribute and values.

Create a new empty Facets, or if provided, with the given attribute and values.

Parameters

$attribute
the attribute name
$values
an indexed array of values, or one or more strings.

Throws

InvalidArgumentException
if attribute or values are null or the empty string.
public Apptus\ESales\Connector\Facets
# add( attribute $attribute, values $values )

Return a new Facets with the given attribute and values added.

Return a new Facets with the given attribute and values added.

Parameters

$attribute
the attribute name
$values
an indexed array of values, or one or more strings.

Returns

Apptus\ESales\Connector\Facets
a new Facets object

Throws

InvalidArgumentException
if attribute is null or the empty string.
public Apptus\ESales\Connector\Facets
# toggle( attribute $attribute, value $value )

Toggle the given attribute and value.

Toggle the given attribute and value.

Parameters

$attribute
the attribute to toggle
$value
the value for the given attribute to toggle

Returns

Apptus\ESales\Connector\Facets
a new Facets object

Throws

InvalidArgumentException
if attribute is null or the empty string.
public Apptus\ESales\Connector\Facets
# addRange( attribute $attribute, min $min, min $max )

Return a new Facets with the given attribute range added. If a range of the current attribute already existed, it will replace the existing one. Note that facet ranges are inclusive.

Return a new Facets with the given attribute range added. If a range of the current attribute already existed, it will replace the existing one. Note that facet ranges are inclusive.

Parameters

$attribute
the attribute
$min
the min value of the range
$max
the max value of the range

Returns

Apptus\ESales\Connector\Facets
a new Facets object

Throws

InvalidArgumentException
if attribute is null or the empty string.
public Apptus\ESales\Connector\Facets
# remove( attribute $attribute )

Return a new Facets with the given attribute removed.

Return a new Facets with the given attribute removed.

Parameters

$attribute
the attribute

Returns

Apptus\ESales\Connector\Facets
a new Facets object

Throws

InvalidArgumentException
if attribute is null or the empty string.
public static Apptus\ESales\Connector\Facets
# parse( source $source )

Create a Facets object from the source string.

Create a Facets object from the source string.

Parameters

$source
the string to parse

Returns

Apptus\ESales\Connector\Facets
Facets object from the source string
public string
# __toString( )

Builds and returns a string on the facet argument format.

Builds and returns a string on the facet argument format.

Returns

string
a string on the facet argument format
Apptus ESales Connector PHP API documentation generated by ApiGen