You are here

class PhotosRouteProvider in Album Photos 8.5

Same name and namespace in other branches
  1. 6.0.x src/Entity/PhotosRouteProvider.php \Drupal\photos\Entity\PhotosRouteProvider

Provides routes for photos images.

Hierarchy

Expanded class hierarchy of PhotosRouteProvider

File

src/Entity/PhotosRouteProvider.php, line 13

Namespace

Drupal\photos\Entity
View source
class PhotosRouteProvider implements EntityRouteProviderInterface {

  /**
   * {@inheritdoc}
   */
  public function getRoutes(EntityTypeInterface $entity_type) {
    $route_collection = new RouteCollection();
    $parameters = [];
    $parameters['node'] = [
      'type' => 'entity:node',
    ];
    $route = (new Route('/photos/{node}/{photos_image}'))
      ->addDefaults([
      '_controller' => '\\Drupal\\photos\\Controller\\PhotosImageViewController::view',
      '_title_callback' => '\\Drupal\\photos\\Controller\\PhotosImageViewController::title',
    ])
      ->setRequirement('_entity_access', 'photos_image.view')
      ->setRequirement('photos_image', '\\d+')
      ->setRequirement('node', '\\d+')
      ->setOption('parameters', $parameters);
    $route_collection
      ->add('entity.photos_image.canonical', $route);
    $route = (new Route('/photos/{node}/{photos_image}/delete'))
      ->addDefaults([
      '_entity_form' => 'photos_image.delete',
      '_title' => 'Delete image',
    ])
      ->setRequirement('_entity_access', 'photos_image.delete')
      ->setRequirement('photos_image', '\\d+')
      ->setRequirement('node', '\\d+')
      ->setOption('parameters', $parameters)
      ->setOption('_photos_image_operation_route', TRUE);
    $route_collection
      ->add('entity.photos_image.delete_form', $route);
    $route = (new Route('/photos/{node}/{photos_image}/edit'))
      ->setDefault('_entity_form', 'photos_image.edit')
      ->setRequirement('_entity_access', 'photos_image.update')
      ->setRequirement('photos_image', '\\d+')
      ->setRequirement('node', '\\d+')
      ->setOption('parameters', $parameters)
      ->setOption('_photos_image_operation_route', TRUE);
    $route_collection
      ->add('entity.photos_image.edit_form', $route);
    return $route_collection;
  }

}

Members