Parses the account data.

@param AccountInterface $account

@return array
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;
        }
    }
1222349
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
    switch ($operation) {
    case 'view':
      return AccessResult::allowedIfHasPermission($account, 'access content');

    case 'edit':
      return AccessResult::allowedIfHasPermission($account, 'administer site commerce');

    case 'update':
      return AccessResult::allowedIfHasPermission($account, 'administer site commerce');

    case 'duplicate':
      return AccessResult::allowedIfHasPermission($account, 'administer site commerce');

    case 'delete':
      return AccessResult::allowedIfHasPermission($account, 'administer site commerce');
    }

    return AccessResult::forbidden();
  }
46562
public function getAllowedTransitions(AccountInterface $account, Site $site)
    {
        $ret = [];
        $states = SiteState::getList();
        $matrix = $this->getStateTransitionMatrix();
        $drupalRoles = $account->getRoles();

        foreach ($states as $state => $name) {
            if (isset($matrix[$site->state][$state])) {
                foreach ($matrix[$site->state][$state] as $target) {
                    list($type, $role) = explode(':', $target, 2);
                    if ('site' === $type) {
                        if ($this->userHasRole($account, $site, $role)) {
                            $ret[$state] = $name;
                            break;
                        }
                    } else if ('drupal' === $type) {
                        if (in_array($role, $drupalRoles)) {
                            $ret[$state] = $name;
                            break;
                        }
                    }
                }
            }
        }

        return $ret;
    }
1076317
protected function parse(ServerRequestInterface $request): array
    {
        $body = $request->getBody()->getContents();
        if ($body === '') {
            return [];
        }

        $parsedJson = \json_decode($body, true, $this->decodeDepth, $this->decodeOptions);

        if (json_last_error() !== JSON_ERROR_NONE) {
            throw new DomainException(json_last_error_msg(), json_last_error());
        }

        return $parsedJson;
    }
575896
public function getRawChangeAddress($account)
    {
        $args = [
            (string)$account
        ];
        return $this->rpc->query(__FUNCTION__, $args);
    }
1137863
public function getUserGroups(AccountInterface $account)
    {
        $userId = $account->id();

        if (!isset($this->accessCache[$userId])) {
            $this->accessCache[$userId] = [];

            $q = $this
                ->database
                ->select('ucms_group_access', 'gu')
                ->fields('gu', ['group_id', 'user_id', 'role'])
                ->condition('gu.user_id', $userId)
            ;

            // This will populate the PartialUserInterface information without
            // the need to join on the user table. Performance for the win.
            // This will always remain true as long as we have a foreign key
            // constraint on the user table, we are sure that the user actually
            // exists, and since we have the instance, it's all good!
            $q->addExpression(':name', 'name', [':name' => $account->getAccountName()]);
            $q->addExpression(':mail', 'mail', [':mail' => $account->getEmail()]);
            $q->addExpression(':status', 'status', [':status' => $account->status]);

            $r = $q->execute();
            $r->setFetchMode(\PDO::FETCH_CLASS, GroupMember::class);

            // Can't use fetchAllAssoc() because properties are private on the
            // objects built by PDO
            $this->accessCache[$userId] = [];

            foreach ($r as $record) {
                $this->accessCache[$userId][] = $record;
            }
        }

        return $this->accessCache[$userId];
    }
1306306
protected function parseTransactionAccount()
    {
        $account = parent::parseTransactionAccount();
        if ($account !== '') {
            return $account;
        }

        // IBAN
        $transactionData = str_replace('Europese Incasso, doorlopend ', '', $this->getCurrentTransactionData());
        $transactionData = preg_replace('![\r\n]+!', '', $transactionData);
        if (preg_match('#/CNTP/(.*?)/#', $transactionData, $results)) {
            $account = trim($results[1]);
            if (!empty($account)) {
                return $this->sanitizeAccount($account);
            }
        }
        if (preg_match('#:86:([A-Z]{2}[\d]{2}[A-Z]{4}[\d]+?) [A-Z]{6}[A-Z0-9]{0,4} #', $transactionData, $results)) {
            $account = trim($results[1]);
            if (!empty($account)) {
                return $this->sanitizeAccount($account);
            }
        }

        return '';
    }
27761
public function getData(UserInterface $user): array
    {
        $userData = array();
        $userData[ self::FIELD_ID ] = $user->getId()->toString();
        $userData[ self::FIELD_EMAIL ] = $user->getEmail()->getEmail();
        $userData[ self::FIELD_NAME ] = $user->getName();
        $userData[ self::FIELD_BIRTHDAY ] = is_null($user->getBirthday()) ? null : $user->getBirthday()->format('Y-m-d');
        $userData[ self::FIELD_LAST_LOGIN ] = $user->getLastLogin()->format('Y-m-d H:i:s');

        return $userData;
    }
727116
protected function blockAccess(AccountInterface $account) {
    $route_name = $this->routeMatch->getRouteName();
    $routes_to_check = [
      'view.event_enrollments.view_enrollments',
      'entity.node.canonical',
      'view.managers.view_managers',
    ];
    if (in_array($route_name, $routes_to_check)) {
      $node = $this->routeMatch->getParameter('node');
      if (!is_null($node) && !is_object($node)) {
        $node = node_load($node);
      }

      if (is_object($node) && $node->getType() === 'event') {
        // Retrieve the group and if there are groups respect group permission.
        $groups = $this->getGroups($node);
        if (!empty($groups)) {
          foreach ($groups as $group) {
            if ($group->hasPermission('enroll to events in groups', $account)) {
              return AccessResult::allowed();
            }
          }
        }
        else {
          // @TODO Always show the block when the user is already enrolled.
          return AccessResult::allowed();
        }
      }
    }
    // By default, the block is not visible.
    return AccessResult::forbidden();
  }
871791
public function get_properties($account_id) {
		$result = array();
		try {
			if ( $this->ga ) {
				$properties = $this->ga
					->management_webproperties
					->listManagementWebproperties( $account_id );
				$result     = $properties->getItems();
			}
		} catch ( \Exception $e ) {
			// Do nothing.
			error_log($e->getMessage(), $e->getCode());
		}
		return $result;
	}
740174
private function toJsonRequest($accounts) {
    $jsonUsers = array();
    foreach($accounts as $account) {
      $user = array(
        'email' => $account->getEmail(),
        'localId' => $account->getUserId(),
        'emailVerified' => $account->isEmailVerified(),
        'displayName' => $account->getDisplayName(),
        'passwordHash' => Google_Utils::urlSafeB64Encode(
            $account->getPasswordHash()),
        'salt' => Google_Utils::urlSafeB64Encode($account->getSalt())
      );
      array_push($jsonUsers, $user);
    }
    return $jsonUsers;
  }
482977
protected static function fetchAccount(BaseClientInterface $client) {
    $account = self::find()->byClient($client)->one();

    if (null === $account) {
      /** @var Account $account */
      $account = Yii::createObject([
        'class' => Account::className(),
        'provider' => $client->getId(),
        'clientId' => $client->getUserAttributes()['id'],
        'data' => Json::encode($client->getUserAttributes()),
      ]);
      $account->save(false);
    }

    return $account;
  }
765058
public function userIsMember(AccountInterface $account, Group $group)
    {
        // @todo fix this, cache that
        return (bool)$this
            ->database
            ->query(
                "SELECT 1 FROM {ucms_group_access} WHERE group_id = :group AND user_id = :user",
                [':group' => $group->getId(), ':user' => $account->id()]
            )
            ->fetchField()
        ;
    }
855731
public function getIniPrefix($accountId = null)
    {
        if ($accountId == null) {
            $arr = array();
            foreach ($this->configs as $key => $value) {
                $pos = strpos($key, '.');
                if (strstr($key, "acct")) {
                    $arr[] = substr($key, 0, $pos);
                }
            }
            return array_unique($arr);
        } else {
            $iniPrefix = array_search($accountId, $this->configs);
            $pos = strpos($iniPrefix, '.');
            $acct = substr($iniPrefix, 0, $pos);

            return $acct;
        }
    }
589368
public function parse()
    {
        $results = [];

        foreach ($this->output as $account) {
            if ($account = $this->parseAccount($account)) {
                $results[] = $account;
            }
        }

        return $results;
    }
284994
public function getBalanceByAccount($account)
    {
        $args = [
            (string)$account,
            $this->minconf
        ];
        return $this->rpc->query("getBalance", $args);
    }
315551
public function getCustomerAccount()
    {
        if ($account = $this->entity->getCustomerAccount()) {
            return array(
                'id' => $account->getId(),
                'name' => $account->getName()
            );
        }

        return null;
    }