You are here

function hook_bynder_search_query_alter in Bynder 8.3

Same name and namespace in other branches
  1. 8.2 bynder.api.php \hook_bynder_search_query_alter()
  2. 4.0.x bynder.api.php \hook_bynder_search_query_alter()

Alter the search query passed to the Bynder API.

This is primarily used by \Drupal\bynder\Plugin\EntityBrowser\Widget\BynderSearch::getForm() before it passes $query into the getMediaList() method in the API to display a list of available Bynder assets to use as media entities.

Parameters

array $query: An associative array containing the query fields and values.

\Drupal\Core\Form\FormStateInterface $form_state: The form state of the entity browser form.

\Drupal\bynder\Plugin\EntityBrowser\Widget\BynderSearch $widget: The entity browser widget plugin.

See also

hook_form_entity_browser_ENTITY_BROWSER_ID_form_alter()

\Drupal\bynder\BynderApi::getMediaList()

File

./bynder.api.php, line 30
Hooks related to Bynder.

Code

function hook_bynder_search_query_alter(array &$query, \Drupal\Core\Form\FormStateInterface $form_state, \Drupal\bynder\Plugin\EntityBrowser\Widget\BynderSearch $widget) {
  if ($property_value = $form_state
    ->getValue([
    'filters',
    'my_property',
  ])) {
    $query['property_my_property'] = $property_value;
  }
}