You are here

function hook_groupmedia_finder_add_alter in Group Media 8.2

Allows to conditionally process the found media items.

If media should NOT be processed add FALSE value to the $result array. If at least 1 FALSE will be in the $result array after all modules react on the hook, the media will not be processed. If no value is added to the $result array it is assumed that media is allowed to be processed, no restrictions.

Parameters

array $result: Adds reaction to whether media should be processed.

\Drupal\media\MediaInterface $media: Media item in question.

array $context: Array with context. Consists of 2 items 'entity' - entity that is processed to find the media item, 'field_name' - the name of the field connected to entity where the media was found.

1 function implements hook_groupmedia_finder_add_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

groupmedia_groupmedia_finder_add_alter in ./groupmedia.module
Implements hook_groupmedia_finder_add_alter().
1 invocation of hook_groupmedia_finder_add_alter()
MediaFinderBase::shouldBeAdded in src/Plugin/MediaFinder/MediaFinderBase.php
Checks whether media item should be considered as group content.

File

./groupmedia.api.php, line 44
Describes hooks provided by groupmedia module.

Code

function hook_groupmedia_finder_add_alter(array &$result, MediaInterface $media, array &$context) {
  if ($media
    ->id() == 10 && $context['entity']
    ->getEntityTypeId() == 'paragraph' && $context['field_name'] == 'field_to_exclude') {
    $result[] = FALSE;
  }
}