Oihana PHP Arango

isDeclaredFilterPath.php

Table of Contents

Functions

isDeclaredFilterPath()  : bool
Whether a dotted path (`seller.id`) is declared under a level of `AQL::FILTERS`.

Functions

isDeclaredFilterPath()

Whether a dotted path (`seller.id`) is declared under a level of `AQL::FILTERS`.

isDeclaredFilterPath(array<string|int, mixed> $declared, string $path) : bool

A sub-field of an object is declared in one of two ways, and both are read :

  • flat, the whole dotted path as one key of the level : [ 'seller.id' => FilterType::STRING ] ;
  • as an object, each segment declared inside the object of the previous one : [ 'seller' => [ AQL::TYPE => Filter::DOCUMENT , AQL::FILTERS => [ 'id' => FilterType::STRING ] ] ].

🚨 One rule for both spellings of a filter on an element of a list. The direct one (offers[*].seller.id) walked the path segment by segment and read only the object form ; the match one (offers[*] with {"seller.id":…}) looked the dotted key up as is and read only the flat form. No declaration served both, and whichever a model chose, one of the two answered 400 to a key it did declare.

An object declared with no sub-filters is free below it, as a list declared with none is. A path neither form declares is not.

Parameters
$declared : array<string|int, mixed>

The AQL::FILTERS of the level the path starts at.

$path : string

The dotted path, without any [*] marker.

Tags
example
isDeclaredFilterPath( [ 'seller.id' => FilterType::STRING ] , 'seller.id' ) ; // true
isDeclaredFilterPath( [ 'seller' => [ AQL::TYPE => Filter::DOCUMENT , AQL::FILTERS => [ 'id' => FilterType::STRING ] ] ] , 'seller.id' ) ; // true
isDeclaredFilterPath( [ 'seller' => [ AQL::TYPE => Filter::DOCUMENT , AQL::FILTERS => [ 'id' => FilterType::STRING ] ] ] , 'seller.name' ) ; // false
author

Marc Alcaraz (ekameleon)

Return values
bool
On this page

Search results