Copied!

MapLocationDistance

MapLocationDistance.php : 21
Extends Criterion

The MapLocationDistance Criterion class.

Provides content filtering based on distance from geographical location.

Properties

public $operator

Criterion.php : 23

The operator used by the Criterion.

public string $operator

public $target

Criterion.php : 37

The target used by the criteria (field, metadata...).

public string $target

public $value

Criterion.php : 30

The value(s) matched by the criteria.

public array<string|int, scalar>|scalar $value

public $valueData

Criterion.php : 44

Additional value data, required by some criterions, MapLocationDistance for instance.

public Value $valueData

protected $boost

MapLocationDistance.php : 35
protected array<string|int, mixed> $boost

protected $customFields

MapLocationDistance.php : 28

Custom field definitions to query instead of default field.

protected array<string|int, mixed> $customFields = []

Methods

public__construct()

MapLocationDistance.php : 45

Performs operator validation based on the Criterion specifications returned by {@see getSpecifications()}.

public __construct(string $target, string $operator, float|array<string|int, float> $distance, float $latitude, float $longitude)

Parameters

Name Type Default value Description
$target string -

FieldDefinition identifier

$operator string -

One of the supported Operator constants

$distance float|array<string|int, float> -

The match value in kilometers, either as an array or as a single value, depending on the operator

$latitude float -

Latitude of the location that distance is calculated from

$longitude float -

Longitude of the location that distance is calculated from

publicgetCustomField()

MapLocationDistance.php : 88

Return custom field.

public getCustomField(string $type, string $field) : string|null

If no custom field is set, return null

Parameters

Name Type Default value Description
$type string - -
$field string - -

Return values

string|null

publicgetSpecifications()

MapLocationDistance.php : 51

Criterion description function.

public getSpecifications() : array<string|int, Specifications>

Returns the combination of the Criterion's supported operator/value, as an array of Specifications objects

  • Operator is one supported Operator, as an Operator::* constant
  • ValueType is the type of input value this operator requires, either array or single
  • SupportedTypes is an array of types the operator will accept
  • ValueCountLimitation is an integer saying how many values are expected.
// IN and EQ are supported return [ // The EQ operator expects a single value, either as an integer or a string new Specifications( Operator::EQ, Specifications::FORMAT_SINGLE, Specifications::TYPE_INTEGER | Specifications::TYPE_STRING ), // The IN operator expects an array of values, of either integers or strings new Specifications( Operator::IN, Specifications::FORMAT_ARRAY, Specifications::TYPE_INTEGER | Specifications::TYPE_STRING ) ]

Return values

array<string|int, Specifications>

publicsetCustomField()

MapLocationDistance.php : 73

Set a custom field to query.

public setCustomField(string $type, string $field, string $customField) : void

Set a custom field to query for a defined field in a defined type.

Parameters

Name Type Default value Description
$type string - -
$field string - -
$customField string - -