You are here

public function PhotosImage::getAlbumUrl in Album Photos 8.5

Same name and namespace in other branches
  1. 6.0.x src/Entity/PhotosImage.php \Drupal\photos\Entity\PhotosImage::getAlbumUrl()

Gets the album url.

Return value

\Drupal\Core\Url The album url.

Overrides PhotosImageInterface::getAlbumUrl

File

src/Entity/PhotosImage.php, line 250

Class

PhotosImage
Defines the photos image entity class.

Namespace

Drupal\photos\Entity

Code

public function getAlbumUrl() {
  $album_link_override = \Drupal::config('photos.settings')
    ->get('album_link_override');
  if ($album_link_override) {
    $album_link_override = str_replace(':', '.', $album_link_override);

    // @todo add support for other arguments?
    $url = Url::fromRoute('view.' . $album_link_override, [
      'node' => $this
        ->getAlbumId(),
    ]);
  }
  else {

    // Default to the photo album node page.
    $url = Url::fromRoute('entity.node.canonical', [
      'node' => $this
        ->getAlbumId(),
    ]);
  }
  return $url;
}