You are here

protected static function DataProvider::isValidConjunctionForFilter in RESTful 7.2

Check if a conjunction is valid for filtering.

Parameters

string $conjunction: The operator.

Throws

\Drupal\restful\Exception\BadRequestException

1 call to DataProvider::isValidConjunctionForFilter()
DataProvider::processFilterInput in src/Plugin/resource/DataProvider/DataProvider.php
Processes the input for a filter and adds the appropriate defaults.
1 method overrides DataProvider::isValidConjunctionForFilter()
DataProviderEntity::isValidConjunctionForFilter in src/Plugin/resource/DataProvider/DataProviderEntity.php
Overrides DataProvider::isValidConjunctionForFilter().

File

src/Plugin/resource/DataProvider/DataProvider.php, line 493
Contains \Drupal\restful\Plugin\resource\DataProvider\DataProvider.

Class

DataProvider

Namespace

Drupal\restful\Plugin\resource\DataProvider

Code

protected static function isValidConjunctionForFilter($conjunction) {
  $allowed_conjunctions = array(
    'AND',
    'OR',
    'XOR',
  );
  if (!in_array(strtoupper($conjunction), $allowed_conjunctions)) {
    throw new BadRequestException(format_string('Conjunction "@conjunction" is not allowed for filtering on this resource. Allowed conjunctions are: !allowed', array(
      '@conjunction' => $conjunction,
      '!allowed' => implode(', ', $allowed_conjunctions),
    )));
  }
}