You are here

public function PhotosEditController::access in Album Photos 6.0.x

Same name and namespace in other branches
  1. 8.5 src/Controller/PhotosEditController.php \Drupal\photos\Controller\PhotosEditController::access()
  2. 8.4 src/Controller/PhotosEditController.php \Drupal\photos\Controller\PhotosEditController::access()

A custom access check.

Parameters

\Drupal\node\NodeInterface $node: The album node entity.

\Drupal\photos\PhotosImageInterface $photos_image: The photos_image entity.

Return value

\Drupal\Core\Access\AccessResult The access result.

1 string reference to 'PhotosEditController::access'
photos.routing.yml in ./photos.routing.yml
photos.routing.yml

File

src/Controller/PhotosEditController.php, line 130

Class

PhotosEditController
Edit images and image details.

Namespace

Drupal\photos\Controller

Code

public function access(NodeInterface $node, PhotosImageInterface $photos_image) {
  if ($node && $photos_image) {

    // Update cover.
    if ($node
      ->getType() == 'photos' && $node
      ->access('update')) {

      // Allowed to update album cover image.
      return AccessResult::allowed();
    }
    else {

      // Deny access.
      return AccessResult::forbidden();
    }
  }
  else {
    return AccessResult::neutral();
  }
}