getResource() public method

Returns the "data" part of the request if it is present in the body, or null otherwise.
public getResource ( ) : array | null
return array | null
示例#1
0
 /**
  * Hydrates the domain object from the updating request.
  *
  * The domain object's attributes and relationships are hydrated
  * according to the JSON API specification.
  *
  * @param \WoohooLabs\Yin\JsonApi\Request\RequestInterface $request
  * @param \WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface $exceptionFactory
  * @param mixed $domainObject
  * @return mixed
  * @throws \Exception
  */
 public function hydrateForUpdate(RequestInterface $request, ExceptionFactoryInterface $exceptionFactory, $domainObject)
 {
     $data = $request->getResource();
     if ($data === null) {
         throw $exceptionFactory->createDataMemberMissingException($request);
     }
     $this->validateType($data, $exceptionFactory);
     $domainObject = $this->hydrateIdForUpdate($domainObject, $data, $exceptionFactory);
     $domainObject = $this->hydrateAttributes($domainObject, $data);
     $domainObject = $this->hydrateRelationships($domainObject, $data, $exceptionFactory);
     return $domainObject;
 }
示例#2
0
 /**
  * @param string $relationship
  * @param \WoohooLabs\Yin\JsonApi\Request\RequestInterface $request
  * @param \WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface $exceptionFactory
  * @param mixed $domainObject
  * @return mixed
  * @throws \WoohooLabs\Yin\JsonApi\Exception\RelationshipNotExists
  */
 public function hydrateForRelationshipUpdate($relationship, RequestInterface $request, ExceptionFactoryInterface $exceptionFactory, $domainObject)
 {
     $relationshipHydrators = $this->getRelationshipHydrator($domainObject);
     if (isset($relationshipHydrators[$relationship]) === false) {
         throw $exceptionFactory->createRelationshipNotExists($relationship);
     }
     $relationshipHydrator = $relationshipHydrators[$relationship];
     return $this->doHydrateRelationship($domainObject, $relationship, $relationshipHydrator, $exceptionFactory, $request->getParsedBody(), $request->getResource());
 }