public function BynderOAuthLogin::access in Bynder 8.3
Same name and namespace in other branches
- 8 src/Controller/BynderOAuthLogin.php \Drupal\bynder\Controller\BynderOAuthLogin::access()
- 8.2 src/Controller/BynderOAuthLogin.php \Drupal\bynder\Controller\BynderOAuthLogin::access()
- 4.0.x src/Controller/BynderOAuthLogin.php \Drupal\bynder\Controller\BynderOAuthLogin::access()
Checks access to oAuth login.
Parameters
\Drupal\Core\Session\AccountInterface $account: Run access checks for this account.
Return value
\Drupal\Core\Access\AccessResultInterface Access result.
1 string reference to 'BynderOAuthLogin::access'
File
- src/
Controller/ BynderOAuthLogin.php, line 97
Class
- BynderOAuthLogin
- Controller for oAuth login.
Namespace
Drupal\bynder\ControllerCode
public function access(AccountInterface $account) {
if ($this->bynder
->hasAccessToken()) {
return AccessResult::forbidden();
}
$browsers = $this
->entityTypeManager()
->getStorage('entity_browser')
->loadMultiple();
/** @var \Drupal\entity_browser\Entity\EntityBrowser $browser */
foreach ($browsers as $browser) {
if ($account
->hasPermission('access ' . $browser
->id() . ' entity browser pages')) {
foreach ($browser
->getWidgets() as $widget) {
if ($widget instanceof BynderSearch || $widget instanceof BynderUpload) {
return AccessResult::allowed();
}
}
}
}
return AccessResult::forbidden();
}