smsplatform-1.0.x-dev/src/Access/SupportsPushedReportsAccessCheck.php

src/Access/SupportsPushedReportsAccessCheck.php
<?php

declare(strict_types=1);

namespace Drupal\smsplatform\Access;

use Drupal\Core\Access\AccessResult;
use Drupal\Core\Routing\Access\AccessInterface;
use Symfony\Component\HttpFoundation\Request;

/**
 * Checks if gateway supports pushed reports.
 */
class SupportsPushedReportsAccessCheck implements AccessInterface {

  /**
   * Checks if the gateway supports pushed reports.
   */
  public function access(Request $request) {
    if ($request->attributes->has('gateway')) {
      /** @var \Drupal\smsplatform\Entity\SmsGatewayInterface $sms_gateway */
      $sms_gateway = $request->attributes->get('gateway');
      return AccessResult::allowedIf($sms_gateway->supportsReportsPush())
        ->addCacheContexts(['route'])
        ->addCacheContexts($sms_gateway->getCacheContexts());
    }
    return AccessResult::neutral();
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc