WoohooLabs\Yin\JsonApi\Request\RequestInterface::getResource PHP Method

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
    public function getResource();

Usage Example

示例#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;
 }
All Usage Examples Of WoohooLabs\Yin\JsonApi\Request\RequestInterface::getResource