You are here

public function SupportsPushedReportsAccessCheck::access in SMS Framework 2.x

Same name and namespace in other branches
  1. 8 src/Access/SupportsPushedReportsAccessCheck.php \Drupal\sms\Access\SupportsPushedReportsAccessCheck::access()
  2. 2.1.x src/Access/SupportsPushedReportsAccessCheck.php \Drupal\sms\Access\SupportsPushedReportsAccessCheck::access()

Checks if the gateway supports pushed reports.

File

src/Access/SupportsPushedReportsAccessCheck.php, line 19

Class

SupportsPushedReportsAccessCheck
Checks if gateway supports pushed reports.

Namespace

Drupal\sms\Access

Code

public function access(Request $request) {
  if ($request->attributes
    ->has('sms_gateway')) {

    /** @var \Drupal\sms\Entity\SmsGatewayInterface $sms_gateway */
    $sms_gateway = $request->attributes
      ->get('sms_gateway');
    return AccessResult::allowedIf($sms_gateway
      ->supportsReportsPush())
      ->addCacheContexts([
      'route',
    ])
      ->addCacheContexts($sms_gateway
      ->getCacheContexts());
  }
  return AccessResult::neutral();
}