Create JsonAPI-object

@param  $source
@param  DocumentHydrator $hydrator
@return JsonApiObject
551357
protected function createJsonApi($source, DocumentHydrator $hydrator): JsonApiObject
    {
        $jsonApi = isset($source->version)
            ? new JsonApiObject($source->version)
            : new JsonApiObject();

        $hydrator->hydrateObject($jsonApi, $source);

        return $jsonApi;
    }
83956
protected function processNoDataRelationship($source, DocumentHydrator $hydrator): NoDataRelationship
    {
        $relationship = new NoDataRelationship();

        $hydrator->hydrateObject($relationship, $source);

        return $relationship;
    }
1017085
public function createResponse(Request $request, $operationResult = null)
    {
        /** @var RequestMeta $meta */
        $meta = $request->attributes->get(RequestMeta::ATTRIBUTE);

        $statusCode = $this->okStatusResolver->resolve($operationResult, $meta->getOperation());

        $schema = $meta->getOperation()->getResponse($statusCode)->getSchema();

        if ($this->hydrator && $operationResult !== null) {
            $operationResult = $this->hydrator->dehydrate($operationResult, $schema);
        }

        $operationResult = $operationResult === null ? '' : $operationResult;

        if ($this->validator) {
            $validationResult = $this->validator->validate($schema, $operationResult);

            if (!$validationResult->isValid()) {
                throw new ValidationException(
                    $validationResult->getErrorMessages(),
                    Response::HTTP_INTERNAL_SERVER_ERROR,
                    ValidationException::MESSAGE_OUTPUT
                );
            };
        }

        return new JsonResponse($operationResult, $statusCode);
    }
844679
public function execute(array $parameters = [], $hydrationMode = self::HYDRATE_DOCUMENT)
    {
        if (null !== $this->maxResults) {
            $this->phpcrQuery->setLimit($this->maxResults);
        }

        if (null !== $this->firstResult) {
            $this->phpcrQuery->setOffset($this->firstResult);
        }

        foreach ($parameters as $key => $value) {
            $this->phpcrQuery->bindValue($key, $value);
        }

        if (self::HYDRATE_PHPCR === $hydrationMode) {
            return $this->phpcrQuery->execute();
        }

        if (self::HYDRATE_DOCUMENT !== $hydrationMode) {
            throw new DocumentManagerException(sprintf(
                'Unknown hydration mode "%s", should be either "document" or "phpcr_node"',
                $hydrationMode
            ));
        }

        $event = new QueryExecuteEvent($this, $this->options);
        $this->dispatcher->dispatch(Events::QUERY_EXECUTE, $event);

        return $event->getResult();
    }
1226217
private function rehydrateDocument($document, NodeInterface $node, $locale)
    {
        $hydrateEvent = new HydrateEvent($node, $locale, ['rehydrate' => true]);
        $hydrateEvent->setDocument($document);
        $this->eventDispatcher->dispatch(Events::HYDRATE, $hydrateEvent);
    }
995973
public static function configure(
        HttpClientConfigurator $httpClientConfigurator,
        Hydrator $hydrator = null,
        RequestBuilder $requestBuilder = null
    ): self {
        $httpClient = $httpClientConfigurator->createConfiguredClient();

        return new self($httpClient, $hydrator, $requestBuilder);
    }
325766
public function make($object)
    {
        $manager = Manager::getInstance();

        // Instantiate hydrator
        // TODO: We'll need to optimize this and allow pre-generation
        //       of these hydrators, and get it, ideally, from the entityMap or
        //       the Mapper class, so it's only instantiated once
        $config = new Configuration(get_class($object));

        $hydratorClass = $config->createFactory()->getHydratorClass();
        $hydrator = new $hydratorClass();

        if ($manager->isValueObject($object)) {
            $entityMap = $manager->getValueMap($object);
        } else {
            $entityMap = $manager->mapper($object)->getEntityMap();
        }

        // Build Wrapper
        return new ObjectWrapper($object, $entityMap, $hydrator);
    }
110510
public static function json($content = null, array $headers = [], $prettyPrint = false)
    {
        return new JsonResponse($content, $headers, $prettyPrint);
    }
806374
public function hydrateForCreate(
        JsonApiRequestInterface $request,
        ExceptionFactoryInterface $exceptionFactory,
        $domainObject
    ) {
        $data = $request->getResource();
        if ($data === null) {
            throw $exceptionFactory->createDataMemberMissingException($request);
        }

        $this->validateType($data, $exceptionFactory);
        $domainObject = $this->hydrateIdForCreate($domainObject, $data, $request, $exceptionFactory);
        $this->validateRequest($request);
        $domainObject = $this->hydrateAttributes($domainObject, $data);
        $domainObject = $this->hydrateRelationships($domainObject, $data, $exceptionFactory);

        return $domainObject;
    }
903868
public function createDocumentFromSource($source)
    {
        if ($source instanceof \DOMDocument) {
            return $source;
        }

        throw new RuntimeException(RuntimeException::INVALID_DOM_SOURCE_STR, RuntimeException::INVALID_DOM_SOURCE);
    }
1063121
public static function create($content, $jsonOption = 0, $status = 200, $reason = '', array $headers = [])
    {
        return new static($content, $jsonOption, $status, $reason, $headers);
    }
1242355
public function hydrate(HydrationEvent $event, $eventName, $eventDispatcher)
    {
        // Possibility to load serialized cache
        $eventDispatcher->dispatch(TmdbEvents::BEFORE_HYDRATION, $event);

        if ($event->isPropagationStopped()) {
            return $event->getSubject();
        }

        $subject = $this->hydrateSubject($event);
        $event->setSubject($subject);

        // Possibility to cache the data
        $eventDispatcher->dispatch(TmdbEvents::AFTER_HYDRATION, $event);

        return $event->getSubject();
    }
586453
protected static function defaultCreateQueryParser(
        ContainerInterface $container,
        string $rulesClass = DefaultQueryValidationRules::class
    ): JsonApiQueryParserInterface {
        static::assertClassImplements($rulesClass, JsonApiQueryRulesInterface::class);

        /** @var JsonApiParserFactoryInterface $factory */
        $factory = $container->get(JsonApiParserFactoryInterface::class);
        $parser  = $factory->createQueryParser($rulesClass);

        return $parser;
    }
695479
public function parse(Source $source, array $options = []): DocumentNode
    {
        $this->lexer = $this->createLexer($source, $options);

        return $this->lexDocument();
    }
532041
protected function processResourceCollectionDocument($source): ResourceCollectionDocument
    {
        $document = new ResourceCollectionDocument();

        foreach ($source->data as $resourceSrc)
        {
            $document->addResource($this->hydrateResource($resourceSrc));
        }

        $this->hydrateObject($document, $source);

        return $document;
    }
1021108
protected function processSingleIdentifierRelationship($source, DocumentHydrator $hydrator): SingleIdentifierRelationship
    {
        $identifier   = $this->createResourceIdentifier($source->data, $hydrator);
        $relationship = new SingleIdentifierRelationship($identifier);

        $hydrator->hydrateObject($relationship, $source);

        return $relationship;
    }
240952
private function hydrateMailboxWithSubEntities(
        HalResource $mailboxResource,
        MailboxRequest $mailboxRequest
    ): Mailbox {
        $mailboxLoader = new MailboxLoader($this->restClient, $mailboxResource, $mailboxRequest->getLinks());
        $mailboxLoader->load();

        return $mailboxResource->getEntity();
    }