Load sites for which the user is webmaster

@param AccountInterface $account

@return Site[]
189879
public function loadWebmasterSites(AccountInterface $account)
    {
        $roles = $this->getAccess()->getUserRoles($account);

        foreach ($roles as $grant) {
            if ($grant->getRole() !== Access::ROLE_WEBMASTER) {
                unset($roles[$grant->getSiteId()]);
            }
        }

        return $this->getStorage()->loadAll(array_keys($roles));
    }
773231
public function updateAccounts(Models\Accounts $accounts)
    {
        $resource = 'accounts';
        $response = $this->sendPutRequest($resource, $accounts->toArray());
        $accountsResponse = new Models\UpdateAccountResponse($response);
        return $accountsResponse->getAccounts();
    }
373083
public function canEditAllLabels(AccountInterface $account = null)
    {
        if ($account === null) {
            global $user;
            $account = $user;
        }

        return (
            user_access(LabelAccess::PERM_EDIT_NON_LOCKED, $account) &&
            user_access(LabelAccess::PERM_EDIT_LOCKED, $account)
        );
    }
1271813
protected function loadUserThrottles(UserInterface $user)
    {
        $queryBuilder = $this->getEntityManager()->createQueryBuilder();
        $queryBuilder
            ->select('t')
            ->from($this->entityName('user'), 't')
            ->where('t.createdAt > :interval')
            ->andWhere('t.user = :user')
            ->setParameters([
                'interval' => Carbon::now()->subSeconds($this->userInterval),
                'user'     => $user
            ]);

        return new Collection($queryBuilder->getQuery()->getResult());
    }
715758
public function userCanDereference(AccountInterface $account, NodeInterface $node, Site $site)
    {
        return $node->access(Permission::VIEW, $account) && in_array($site->getId(), $node->ucms_sites) && $this->manager->getAccess()->userIsWebmaster($account, $site);
    }
597812
private function isOwner(AccountInterface $account, Model $resource)
    {
        /** @var Model $resource */
        if ($this->isAuthenticated($account) === true) {
            $userId  = $account->getAuthIdentifier();
            $ownerId = $resource->{Model::FIELD_ID_USER};
            $isOwner = $userId === $ownerId;

            return $isOwner;
        }

        return false;
    }
991040
public function getAddressesByAccount($account)
    {
        $args = [
            (string)$account
        ];
        return $this->rpc->query(__FUNCTION__, $args);
    }
1127465
public function userIsWebmaster(AccountInterface $account, Site $site = null)
    {
        return $this->userHasRole($account, $site, Access::ROLE_WEBMASTER);
    }
312186
private function getAllRoles(TokenInterface $token)
    {
        if (null !== $this->sim) {
            $sids = $this->sim->getSecurityIdentities($token);

            return IdentityUtils::filterRolesIdentities($sids);
        }

        return RoleUtil::formatNames($token->getRoles());
    }
405670
private function getWebmasterSites()
    {
        $ret = [];

        foreach ($this->siteManager->loadWebmasterSites($this->account) as $site) {
            $ret[$site->getId()] = check_plain($site->title);
        }

        return $ret;
    }
575896
public function getRawChangeAddress($account)
    {
        $args = [
            (string)$account
        ];
        return $this->rpc->query(__FUNCTION__, $args);
    }
155311
protected function blockAccess(AccountInterface $account) {
    $route_user_id = $this->routeMatch->getParameter('user');
    if ($account->id() == $route_user_id && $account->hasPermission("create event content")) {
      return AccessResult::allowed();
    }
    // By default, the block is not visible.
    return AccessResult::forbidden();
  }
557690
protected
    function parseAccount(
        AccountInterface $account
    ) {
        if ($account) {
            $data = [];
            $data['id'] = $account->getId();
            $data['name'] = $account->getName();
            $data['phone'] = $account->getMainPhone();
            $data['email'] = $account->getMainEmail();
            $data['url'] = $account->getMainUrl();

            // get main contact
            if ($account->getMainContact()) {
                $data['contact'] = $account->getMainContact()->getFullName();
            }

            /* @var Address $accountAddress */
            $accountAddress = $account->getMainAddress();
            if ($accountAddress) {
                $data['address']['street'] = $accountAddress->getStreet();
                $data['address']['number'] = $accountAddress->getNumber();
                $data['address']['zip'] = $accountAddress->getZip();
                $data['address']['city'] = $accountAddress->getCity();
                $data['address']['country'] = $accountAddress->getCountry()->getName();
            }

            return $data;
        } else {
            return null;
        }
    }
708359
public function blockAccess(AccountInterface $account) {
    if (\Drupal::moduleHandler()->moduleExists('social_group')) {
      $group = _social_group_get_current_group();
    }
    else {
      $group = NULL;
    }

    if (is_object($group)) {
      if ($group->hasPermission('create group_node:book entity', $account)&& $account->hasPermission("create book content")) {
        if ($group->getGroupType()->id() === 'public_group') {
          $config = \Drupal::config('entity_access_by_field.settings');
          if ($config->get('disable_public_visibility') === 1 && !$account->hasPermission('override disabled public visibility')) {
            return AccessResult::forbidden();
          }
        }
        return AccessResult::allowed();
      }
    }

    // By default, the block is not visible.
    return AccessResult::forbidden();
  }
712322
public function userIsContributor(AccountInterface $account, Site $site = null)
    {
        return $this->userHasRole($account, $site, Access::ROLE_CONTRIB);
    }
834172
protected function initAccountAddressesFieldDescriptors()
    {
        $this->accountAddressesFieldDescriptors = [];

        $addressJoin = [
            self::$accountAddressEntityName => new DoctrineJoinDescriptor(
                self::$accountAddressEntityName,
                $this->getAccountEntityName() . '.accountAddresses'
            ),
            self::$addressEntityName => new DoctrineJoinDescriptor(
                self::$addressEntityName,
                self::$accountAddressEntityName . '.address'
            ),
        ];
        $countryJoin = [
            self::$countryEntityName => new DoctrineJoinDescriptor(
                self::$countryEntityName,
                self::$addressEntityName . '.country'
            ),
            self::$accountAddressEntityName => new DoctrineJoinDescriptor(
                self::$accountAddressEntityName,
                $this->getAccountEntityName() . '.accountAddresses'
            ),
            self::$addressEntityName => new DoctrineJoinDescriptor(
                self::$addressEntityName,
                self::$accountAddressEntityName . '.address'
            ),
        ];

        $this->accountAddressesFieldDescriptors['id'] = new DoctrineFieldDescriptor(
            'id',
            'id',
            self::$addressEntityName,
            'contact.contacts.address',
            $addressJoin,
            FieldDescriptorInterface::VISIBILITY_YES,
            FieldDescriptorInterface::SEARCHABILITY_NO,
            '',
            false
        );

        $this->accountAddressesFieldDescriptors['address'] = new DoctrineConcatenationFieldDescriptor(
            [
                new DoctrineConcatenationFieldDescriptor(
                    [
                        new DoctrineFieldDescriptor(
                            'street',
                            'address',
                            self::$addressEntityName,
                            '',
                            $addressJoin
                        ),
                        new DoctrineFieldDescriptor(
                            'number',
                            'address',
                            self::$addressEntityName,
                            '',
                            $addressJoin
                        ),
                        new DoctrineFieldDescriptor(
                            'addition',
                            'address',
                            self::$addressEntityName,
                            '',
                            $addressJoin
                        ),
                    ],
                    'street',
                    ' '
                ),
                new DoctrineFieldDescriptor(
                    'zip',
                    'address',
                    self::$addressEntityName,
                    '',
                    $addressJoin
                ),
                new DoctrineFieldDescriptor(
                    'city',
                    'address',
                    self::$addressEntityName,
                    '',
                    $addressJoin
                ),
                new DoctrineFieldDescriptor(
                    'state',
                    'address',
                    self::$addressEntityName,
                    '',
                    $addressJoin
                ),
                new DoctrineFieldDescriptor(
                    'name',
                    'address',
                    self::$countryEntityName,
                    '',
                    $countryJoin
                ),
                new DoctrineFieldDescriptor(
                    'postboxNumber',
                    'address',
                    self::$addressEntityName,
                    '',
                    $addressJoin
                ),
            ],
            'address',
            'public.address',
            ', ',
            FieldDescriptorInterface::VISIBILITY_ALWAYS,
            FieldDescriptorInterface::SEARCHABILITY_NO
        );
    }
951554
protected function blockAccess(AccountInterface $account) {
    // If tagging is off, deny access always.
    if (!$this->tagService->active() || !$this->tagService->groupActive()) {
      return AccessResult::forbidden();
    }

    // Routes we don't want to display the tag block on.
    $ignore_routes = [
      'entity.group.join',
      'entity.group.leave',
      'entity.group.edit_form',
      'entity.group.delete_form',
      'entity.group_content.collection',
    ];

    // Don't display on group edit.
    if (in_array($this->routeMatch->getRouteName(), $ignore_routes)) {
      return AccessResult::forbidden();
    }

    // Get group from route.
    $group = $this->routeMatch->getParameter('group');

    if ($group instanceof Group) {
      if ($group->hasField('social_tagging')) {
        if (!empty(($group->get('social_tagging')->getValue()))) {
          // We only show the block if the field contains values.
          return AccessResult::allowed();
        }
      }
    }

    return AccessResult::forbidden();
  }