public function getMediaWithTerm(NodeInterface $node, TermInterface $term) {
    $mids = $this->getMediaReferencingNodeAndTerm($node, $term);
    if (empty($mids)) {
      return NULL;
    }
    return $this->entityTypeManager->getStorage('media')->load(reset($mids));
  }
public function getMediaWithTerm(NodeInterface $node, TermInterface $term) {
    $mids = $this->getMediaReferencingNodeAndTerm($node, $term);
    if (empty($mids)) {
      return NULL;
    }
    return $this->entityTypeManager->getStorage('media')->load(reset($mids));
  }
public function getMediaWithTerm ( NodeInterface $ node , TermInterface $ term ) { $ mids = $ this -> getMediaReferencingNodeAndTerm ( $ node , $ term ) ; if ( empty ( $ mids ) ) { return NULL ; } return $ this -> entityTypeManager -> getStorage ( 'media' ) -> load ( reset ( $ mids ) ) ; }
Gets media that belong to a node with the specified term.

@param \Drupal\node\NodeInterface $node
The parent node.
@param \Drupal\taxonomy\TermInterface $term
Taxonomy term.

@return \Drupal\media\MediaInterface
The child Media.

@throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
Calling getStorage() throws if the entity type doesn't exist.
@throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
Calling getStorage() throws if the storage handler couldn't be loaded.
Gets media that belong to a node with the specified term .