public function getMedia(NodeInterface $node) {
    if (!$this->entityTypeManager->getStorage('field_storage_config')->load('media.' . self::MEDIA_OF_FIELD)) {
      return [];
    }
    $mids = $this->entityQuery->get('media')->condition(self::MEDIA_OF_FIELD, $node->id())->execute();
    if (empty($mids)) {
      return [];
    }
    return $this->entityTypeManager->getStorage('media')->loadMultiple($mids);
  }
public function getMedia(NodeInterface $node) {
    if (!$this->entityTypeManager->getStorage('field_storage_config')->load('media.' . self::MEDIA_OF_FIELD)) {
      return [];
    }
    $mids = $this->entityQuery->get('media')->condition(self::MEDIA_OF_FIELD, $node->id())->execute();
    if (empty($mids)) {
      return [];
    }
    return $this->entityTypeManager->getStorage('media')->loadMultiple($mids);
  }
public function getMedia ( NodeInterface $ node ) { if ( ! $ this -> entityTypeManager -> getStorage ( 'field_storage_config' ) -> load ( 'media.' . self :: MEDIA_OF_FIELD ) ) { return [ ] ; } $ mids = $ this -> entityQuery -> get ( 'media' ) -> condition ( self :: MEDIA_OF_FIELD , $ node -> id ( ) ) -> execute ( ) ; if ( empty ( $ mids ) ) { return [ ] ; } return $ this -> entityTypeManager -> getStorage ( 'media' ) -> loadMultiple ( $ mids ) ; }
Gets media that belong to a node.

@param \Drupal\node\NodeInterface $node
The parent node.

@return \Drupal\media\MediaInterface[]
The children 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 .