You are here

class LogintobogganValidateAccess in LoginToboggan 8

Determines access to routes based on login status of current user.

Hierarchy

Expanded class hierarchy of LogintobogganValidateAccess

1 string reference to 'LogintobogganValidateAccess'
logintoboggan.services.yml in ./logintoboggan.services.yml
logintoboggan.services.yml
1 service uses LogintobogganValidateAccess
access_check.logintoboggan.validate_access in ./logintoboggan.services.yml
Drupal\logintoboggan\Access\LogintobogganValidateAccess

File

src/Access/LogintobogganValidateAccess.php, line 16

Namespace

Drupal\logintoboggan\Access
View source
class LogintobogganValidateAccess implements RoutingAccessInterface {

  /**
   * The time service.
   *
   * @var \Drupal\Component\Datetime\TimeInterface
   */
  protected $time;

  /**
   * Class constructor.
   */
  public function __construct(Time $datetime) {
    $this->time = $datetime;
  }

  /**
   * {@inheritdoc}
   */
  public function appliesTo() {
    return [
      '_logintoboggan_validate_email_access',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function access(Route $route, Request $request, AccountInterface $account) {
    $path = Url::fromRoute('<current>')
      ->toString();
    $arg = explode('/', $path);
    $request_time = $this->time
      ->getRequestTime();
    return $arg[4] < $request_time ? AccessResult::allowed() : AccessResult::forbidden();
  }

}

Members