public function MediaFinderBase::shouldBeAdded in Group Media 8.2
Checks whether media item should be considered as group content.
Parameters
\Drupal\media\MediaInterface $media: Media item to check.
\Drupal\Core\Entity\EntityInterface $entity: Host entity.
string $field_name: The field name where the media was found.
Return value
bool TRUE if item should be processed, FALSE is other case.
Overrides MediaFinderInterface::shouldBeAdded
1 call to MediaFinderBase::shouldBeAdded()
- TextFieldEmbedBase::getTargetEntities in src/
Plugin/ MediaFinder/ TextFieldEmbedBase.php  
File
- src/
Plugin/ MediaFinder/ MediaFinderBase.php, line 77  
Class
- MediaFinderBase
 - Class MediaFinderBase.
 
Namespace
Drupal\groupmedia\Plugin\MediaFinderCode
public function shouldBeAdded(MediaInterface $media, EntityInterface $entity, $field_name) {
  $return = [];
  $context = [
    'entity' => $entity,
    'field_name' => $field_name,
  ];
  $this->moduleHandler
    ->alter('groupmedia_finder_add', $return, $media, $context);
  if (!is_array($return)) {
    return FALSE;
  }
  // If at least 1 module says "No", the media will not be attached.
  foreach ($return as $item) {
    if (!$item) {
      return FALSE;
    }
  }
  // Otherwise - process.
  return TRUE;
}