You are here

ViewOwnTrackerAccessCheck.php in Zircon Profile 8

Same filename and directory in other branches
  1. 8.0 core/modules/tracker/src/Access/ViewOwnTrackerAccessCheck.php

File

core/modules/tracker/src/Access/ViewOwnTrackerAccessCheck.php
View source
<?php

/**
 * @file
 * Contains \Drupal\tracker\Access\ViewOwnTrackerAccessCheck.
 */
namespace Drupal\tracker\Access;

use Drupal\Core\Access\AccessResult;
use Drupal\Core\Routing\Access\AccessInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\user\UserInterface;

/**
 * Access check for user tracker routes.
 */
class ViewOwnTrackerAccessCheck implements AccessInterface {

  /**
   * Checks access.
   *
   * @param \Drupal\Core\Session\AccountInterface $account
   *   The currently logged in account.
   * @param \Drupal\user\UserInterface $user
   *   The user whose tracker page is being accessed.
   *
   * @return \Drupal\Core\Access\AccessResultInterface
   *   The access result.
   */
  public function access(AccountInterface $account, UserInterface $user) {
    return AccessResult::allowedIf($user && $account
      ->isAuthenticated() && $user
      ->id() == $account
      ->id())
      ->cachePerUser();
  }

}

Classes

Namesort descending Description
ViewOwnTrackerAccessCheck Access check for user tracker routes.