Locker\Helpers\Helpers::getAgentIdentifier PHP Method

getAgentIdentifier() static public method

Determines which identifier is currently in use in the given actor.
static public getAgentIdentifier ( stdClass $actor ) : String | null
$actor stdClass
return String | null Identifier in use.
    static function getAgentIdentifier(\stdClass $actor)
    {
        if (isset($actor->mbox)) {
            return 'mbox';
        }
        if (isset($actor->account)) {
            return 'account';
        }
        if (isset($actor->openid)) {
            return 'openid';
        }
        if (isset($actor->mbox_sha1sum)) {
            return 'mbox_sha1sum';
        }
        return null;
    }

Usage Example

Beispiel #1
0
 /**
  * Removes properties other than `objectType` and identifier from objects inside a statement.
  * @param \stdClass $statement Statement to be formatted.
  * @return \stdClass Formatted statement.
  */
 public function identityStatement(\stdClass $statement)
 {
     $actor = $statement->actor;
     // Processes an anonymous group or actor.
     $is_anonymous_group = $actor->objectType === 'Group' && Helpers::getAgentIdentifier($actor) === null;
     if ($is_anonymous_group) {
         $actor->members = array_map(function (\stdClass $member) {
             return $this->identityObject($member, Helpers::getAgentIdentifier($member));
         }, $actor->members);
     } else {
         $actor = $this->identityObject($actor, Helpers::getAgentIdentifier($actor));
     }
     // Replace parts of the statements.
     $statement->actor = $actor;
     $statement->object = $this->identityObject($statement->object, Helpers::getAgentIdentifier($statement->object) ?: 'id');
     return $statement;
 }
All Usage Examples Of Locker\Helpers\Helpers::getAgentIdentifier