Antidot PHP API  version 0.16.0
##PHP API to simplify integration of Antidot components
 All Classes Files Functions Variables Groups Pages
Public Member Functions | List of all members
AfsFacet Class Reference

Configuration class for AFS facets. More...

Public Member Functions

 __construct ($id, $type=AfsFacetType::UNKNOWN_TYPE, $layout=AfsFacetLayout::TREE, $mode=AfsFacetMode::UNSPECIFIED_MODE)
 Construct new facet with specified parameters.
 set_values_sort_order ($mode, $sort)
 set values sort order for this facet
 get_values_sort_order ()
 get current values sort order for this facet
 get_id ()
 Retrieves facet id.
 set_type ($type)
 Redefines facet type.
 get_type ()
 Retrieves facet type.
 get_layout ()
 Retrieves facet layout.
 set_mode ($mode)
 Defines new facet mode.
 get_mode ()
 Retrieve facet mode.
 has_single_mode ()
 Check whether mode is set to single.
 has_or_mode ()
 Check whether mode is set to or.
 has_and_mode ()
 Check whether mode is set to or.
 is_similar_to (AfsFacet $other)
 Checks whether provided facet is similar to current instance.
 update (AfsFacet $other)
 Updates current instance with parameters from other instance.
 __toString ()
 Printable facet.

Detailed Description

Configuration class for AFS facets.

Examples:
full_example.php.

Constructor & Destructor Documentation

__construct (   $id,
  $type = AfsFacetType::UNKNOWN_TYPE,
  $layout = AfsFacetLayout::TREE,
  $mode = AfsFacetMode::UNSPECIFIED_MODE 
)

Construct new facet with specified parameters.

Parameters
$id[in] facet id defined in feed.xml on indexation side.
$type[in] facet type defined in feed.xml on indexation side. Default value is AfsFacetType::UNKNOWN_TYPE. (see AfsFacetType for available types).
$layout[in] facet layout defined in feed.xml on indexation side. Default value is AfsFacetLayout::TREE. (see AfsFacetLayout for availanle layouts).
$mode[in] facet mode, see AfsFacetMode for more details. (default: UNSPECIFIED_MODE).
Exceptions
InvalidArgumentExceptioninvalid parameter value provided for id, type, layout or mode parameter.

Member Function Documentation

__toString ( )

Printable facet.

This method should be used for debug purpose only.

Returns
string representation of the facet.
get_id ( )

Retrieves facet id.

Returns
facet id.
get_layout ( )

Retrieves facet layout.

Returns
layout of the facet.
get_mode ( )

Retrieve facet mode.

Returns
facet mode (replace, or, add or unspecified).
get_type ( )

Retrieves facet type.

Returns
type of the facet.
get_values_sort_order ( )

get current values sort order for this facet

Returns
AfsFacetValuesSortOrder or null if sort order not specified
has_and_mode ( )

Check whether mode is set to or.

Returns
true when mode is or, false otherwise.
has_or_mode ( )

Check whether mode is set to or.

Returns
true when mode is or, false otherwise.
has_single_mode ( )

Check whether mode is set to single.

Returns
true when mode is single, false otherwise.
is_similar_to ( AfsFacet  $other)

Checks whether provided facet is similar to current instance.

Two instances are considered similar when following values are equals:

  • facet identifier,
  • facet type (or one is of unknown type),
  • facet layout (or one is of unknown layout). Other facet parameters are not taken into account.
Parameters
$other[in] instance to compare with.
Returns
True when both instances are similar, false otherwise.
set_mode (   $mode)

Defines new facet mode.

Parameters
$mode[in] New mode to set.
Exceptions
InvalidArgumentExceptioninvalid mode provided.
set_type (   $type)

Redefines facet type.

Parameters
$type[in] new type of the facet to set.
Exceptions
InvalidArgumentExceptioninvalid type provided.
set_values_sort_order (   $mode,
  $sort 
)

set values sort order for this facet

AFS search default sort for facet values is alphanumeric. This method allows to change this behaviour.

Parameters
$mode[in] the mode to use: see AfsFacetValuesSortMode
$sort[in] the sort to use: see AfsSortOrder
update ( AfsFacet  $other)

Updates current instance with parameters from other instance.

First, both instance are compared then when they are enough similar current instance is updated.
This can be usefull internally when facets are partially declared.

Parameters
$other[in] other instance to compare with and use as source to update.
Returns
true when everything goes right, false otherwise (instances are not similar).