bynder-4.0.0-beta1/bynder.api.php

bynder.api.php
<?php

/**
 * @file
 * Hooks related to Bynder.
 */

use Drupal\media\MediaInterface;

/**
 * @addtogroup hooks
 * @{
 */

/**
 * 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.
 *
 * @param array $query
 *   An associative array containing the query fields and values.
 * @param \Drupal\Core\Form\FormStateInterface $form_state
 *   The form state of the entity browser form.
 * @param \Drupal\bynder\Plugin\EntityBrowser\Widget\BynderSearch $widget
 *   The entity browser widget plugin.
 *
 * @see hook_form_entity_browser_ENTITY_BROWSER_ID_form_alter()
 * @see \Drupal\bynder\BynderApi::getMediaList()
 */
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;
  }
}

/**
 * Allows modules to alter the media entity based on updated bynder metadata.
 *
 * @param \Drupal\media\MediaInterface $media
 *   The media entity.
 * @param array $item
 *   The raw bynder metadata about the media asset.
 * @param bool $has_changed
 *   Must be set to TRUE when making changes to the media entity.
 */
function hook_bynder_media_update_alter(\Drupal\media\MediaInterface $media, array $item, &$has_changed) {

}

/**
 * @} End of "addtogroup hooks".
 */

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc