public function resolve(string $variable)
    {
        $matches = [];

        if (!$this->isMatch($variable, $matches)) {
            throw new UnresolvedException('Variable pattern "'.$variable.'" is not valid.');
        }

        $token = $this->tokenStorage->getToken();
        $user = $token->getUser();
        $identity = $user->getIdentity();

        switch ($identity->getType()) {
            case Identity::ANONYMOUS:
                $model = $this->api->get('identities.anonymous')->get($identity->getUuid());
                break;

            case Identity::INDIVIDUAL:
                $model = $this->api->get('identities.individual')->get($identity->getUuid());
                break;

            case Identity::ORGANIZATION:
                $model = $this->api->get('identities.organization')->get($identity->getUuid());
                break;

            case Identity::STAFF:
                $model = $this->api->get('identities.staff')->get($identity->getyUuid());
                break;

            case Identity::SYSTEM:
                $model = $this->api->get('identities.system')->get($identity->getUuid());
                break;

            default:
                throw new DomainException('User identity "'.$identity->getType().'" is not valid.');
        }

        if (!$model) {
            throw new UnresolvedException('Variable pattern "'.$variable.'" did not resolve to data.');
        }

        $property = $matches[1];
        $accessor = PropertyAccess::createPropertyAccessor();

        try {
            $value = $accessor->getValue($model, $property);
        } catch (Exception $exception) {
            throw new UnresolvedException('Variable pattern "'.$variable.'" did not resolve to data.', 0, $exception);
        }

        return $value;
    }
public function resolve(string $variable)
    {
        $matches = [];

        if (!$this->isMatch($variable, $matches)) {
            throw new UnresolvedException('Variable pattern "'.$variable.'" is not valid.');
        }

        $token = $this->tokenStorage->getToken();
        $user = $token->getUser();
        $identity = $user->getIdentity();

        switch ($identity->getType()) {
            case Identity::ANONYMOUS:
                $model = $this->api->get('identities.anonymous')->get($identity->getUuid());
                break;

            case Identity::INDIVIDUAL:
                $model = $this->api->get('identities.individual')->get($identity->getUuid());
                break;

            case Identity::ORGANIZATION:
                $model = $this->api->get('identities.organization')->get($identity->getUuid());
                break;

            case Identity::STAFF:
                $model = $this->api->get('identities.staff')->get($identity->getyUuid());
                break;

            case Identity::SYSTEM:
                $model = $this->api->get('identities.system')->get($identity->getUuid());
                break;

            default:
                throw new DomainException('User identity "'.$identity->getType().'" is not valid.');
        }

        if (!$model) {
            throw new UnresolvedException('Variable pattern "'.$variable.'" did not resolve to data.');
        }

        $property = $matches[1];
        $accessor = PropertyAccess::createPropertyAccessor();

        try {
            $value = $accessor->getValue($model, $property);
        } catch (Exception $exception) {
            throw new UnresolvedException('Variable pattern "'.$variable.'" did not resolve to data.', 0, $exception);
        }

        return $value;
    }
{@inheritdoc}