Exemplo n.º 1
0
 /**
  * Return a member's account meta data.
  *
  * @param string|null $guid
  *
  * @return Storage\Entity\AccountMeta[]|null
  */
 public function getMemberMeta($guid = null)
 {
     if ($guid === null) {
         if (!$this->session->hasAuthorisation()) {
             return null;
         }
         $auth = $this->session->getAuthorisation();
         $guid = $auth->getGuid();
     }
     $meta = $this->records->getAccountMetaAll($guid);
     return $meta ?: null;
 }
Exemplo n.º 2
0
 /**
  * @param string $guid Member GUID.
  *
  * @return Profile
  */
 private function getEntityProfile($guid = null)
 {
     if ($guid !== null && !Uuid::isValid($guid)) {
         throw new \RuntimeException(sprintf('Invalid GUID value "%s" given.', $guid));
     }
     $account = $this->records->getAccountByGuid($guid);
     $profile = $account ? new Profile($account->toArray()) : new Profile([]);
     $accountMeta = $this->records->getAccountMetaAll($guid);
     if ($accountMeta === false) {
         return $profile;
     }
     /** @var Storage\Entity\AccountMeta $metaEntity */
     foreach ((array) $accountMeta as $metaEntity) {
         if ($profile->has($metaEntity->getMeta())) {
             // Meta shouldn't override
             continue;
         }
         $profile[$metaEntity->getMeta()] = $metaEntity->getValue();
     }
     return $profile;
 }