protected function generateMediaLinks(MediaInterface $media) {
    $media_type = $this->entityTypeManager->getStorage('media_type')->load($media->bundle());

    $type_configuration = $media_type->get('source_configuration');

    $links = [];

    $update_route_name = 'islandora.media_source_update';
    $update_route_params = ['media' => $media->id()];
    if ($this->accessManager->checkNamedRoute($update_route_name, $update_route_params, $this->account)) {
      $edit_media_url = Url::fromRoute($update_route_name, $update_route_params)
        ->setAbsolute()
        ->toString();
      $links[] = "<$edit_media_url>; rel=\"edit-media\"";
    }

    if (!isset($type_configuration['source_field'])) {
      return $links;
    }
    $source_field = $type_configuration['source_field'];

    if (empty($source_field) ||
        !$media->hasField($source_field)
    ) {
      return $links;
    }

    // Collect file links for the media.
    foreach ($media->get($source_field)->referencedEntities() as $referencedEntity) {
      if ($referencedEntity->access('view')) {
        $file_url = $referencedEntity->url('canonical', ['absolute' => TRUE]);
        $links[] = "<$file_url>; rel=\"describes\"; type=\"{$referencedEntity->getMimeType()}\"";
      }
    }

    return $links;
  }
protected function generateMediaLinks(MediaInterface $media) {
    $media_type = $this->entityTypeManager->getStorage('media_type')->load($media->bundle());

    $type_configuration = $media_type->get('source_configuration');

    $links = [];

    $update_route_name = 'islandora.media_source_update';
    $update_route_params = ['media' => $media->id()];
    if ($this->accessManager->checkNamedRoute($update_route_name, $update_route_params, $this->account)) {
      $edit_media_url = Url::fromRoute($update_route_name, $update_route_params)
        ->setAbsolute()
        ->toString();
      $links[] = "<$edit_media_url>; rel=\"edit-media\"";
    }

    if (!isset($type_configuration['source_field'])) {
      return $links;
    }
    $source_field = $type_configuration['source_field'];

    if (empty($source_field) ||
        !$media->hasField($source_field)
    ) {
      return $links;
    }

    // Collect file links for the media.
    foreach ($media->get($source_field)->referencedEntities() as $referencedEntity) {
      if ($referencedEntity->access('view')) {
        $file_url = $referencedEntity->url('canonical', ['absolute' => TRUE]);
        $links[] = "<$file_url>; rel=\"describes\"; type=\"{$referencedEntity->getMimeType()}\"";
      }
    }

    return $links;
  }
protected function generateMediaLinks ( MediaInterface $ media ) { $ media_type = $ this -> entityTypeManager -> getStorage ( 'media_type' ) -> load ( $ media -> bundle ( ) ) ; $ type_configuration = $ media_type -> get ( 'source_configuration' ) ; $ links = [ ] ; $ update_route_name = 'islandora.media_source_update' ; $ update_route_params = [ 'media' => $ media -> id ( ) ] ; if ( $ this -> accessManager -> checkNamedRoute ( $ update_route_name , $ update_route_params , $ this -> account ) ) { $ edit_media_url = Url :: fromRoute ( $ update_route_name , $ update_route_params ) -> setAbsolute ( ) -> toString ( ) ; $ links [ ] = "<$edit_media_url>; rel=\"edit-media\"" ; } if ( ! isset ( $ type_configuration [ 'source_field' ] ) ) { return $ links ; } $ source_field = $ type_configuration [ 'source_field' ] ; if ( empty ( $ source_field ) || ! $ media -> hasField ( $ source_field ) ) { return $ links ; } // Collect file links for the media. foreach ( $ media -> get ( $ source_field ) -> referencedEntities ( ) as $ referencedEntity ) { if ( $ referencedEntity -> access ( 'view' ) ) { $ file_url = $ referencedEntity -> url ( 'canonical' , [ 'absolute' => TRUE ] ) ; $ links [ ] = "<$file_url>; rel=\"describes\"; type=\"{$referencedEntity->getMimeType()}\"" ; } } return $ links ; }
Generates link headers for the described file and source update routes.

@param \Drupal\media\MediaInterface $media
Media to generate link headers.

@return string[]
Array of link headers
Generates link headers for the described file and source update routes .