/** * Stores the object in the request. * * @param Request $request The request * @param ParamConverter $configuration Contains the name, class and options of the object * * @return bool True if the object has been successfully set, else false * @throws \InvalidArgumentException */ public function apply(Request $request, ParamConverter $configuration) { $originalName = parent::getRequestAttributeName($request, $configuration); $fallbackName = $this->getRequestAttributeName($request, $configuration); if (!parent::apply($request, $configuration)) { return false; } if ($originalName !== $fallbackName) { $request->attributes->set($originalName, $request->attributes->get($fallbackName)); } return true; }
/** * Stores the object in the request. * * @param Request $request The request * @param ParamConverter $configuration Contains the name, class and options of the object * * @return bool True if the object has been successfully set, else false * @throws \InvalidArgumentException */ public function apply(Request $request, ParamConverter $configuration) { $originalName = $configuration->getName(); if ($request->attributes->has('familyCode')) { $configuration->setName('familyCode'); } if (!parent::apply($request, $configuration)) { return false; } if ($originalName !== $configuration->getName()) { $request->attributes->set($originalName, $request->attributes->get($configuration->getName())); } return true; }