/** * Hydrates the domain object from the request based on the request method. * * If the request method is POST then the domain object is hydrated * as a create. If it is a PATCH request then the domain object is * hydrated as an update. * * @param \WoohooLabs\Yin\JsonApi\Request\RequestInterface $request * @param \WoohooLabs\Yin\JsonApi\Exception\ExceptionFactoryInterface $exceptionFactory * @param mixed $domainObject * @return mixed * @throws \WoohooLabs\Yin\JsonApi\Exception\ResourceTypeMissing */ public function hydrate(RequestInterface $request, ExceptionFactoryInterface $exceptionFactory, $domainObject) { if ($request->getMethod() === "POST") { $domainObject = $this->hydrateForCreate($request, $exceptionFactory, $domainObject); } elseif ($request->getMethod() === "PATCH") { $domainObject = $this->hydrateForUpdate($request, $exceptionFactory, $domainObject); } return $domainObject; }