You are here

public function SimpleAccessProfile::buildGrant in Simple Access 8.3

Build list of grants to be as part of the content selection.

Parameters

\Drupal\user\UserInterface|null $account: Account of the user to generate access for.

string $op: Operation which is being queried.

Return value

array A list of all the grants to be used.

Overrides SimpleAccessProfileInterface::buildGrant

File

src/Entity/SimpleAccessProfile.php, line 81

Class

SimpleAccessProfile
Defines SimpleAccessProfile config entity.

Namespace

Drupal\simple_access\Entity

Code

public function buildGrant(AccountInterface $account, $op) {
  if (!$account) {
    $account = \Drupal::currentUser();
  }
  foreach (array_filter($this->access) as $gid => $access) {
    $group = SimpleAccessGroup::load($gid);
    if (isset($access[$op]) && $access[$op] && $group
      ->buildGrant($account, $op)) {
      return [
        'simple_access_profile:' . $this
          ->id() => [
          '0',
        ],
      ];
    }
  }
}