/** * {@inherit}. * * @throws \Exception */ public function map($from, $to) { foreach ($this->strategies as $class => $strategy) { if ($from instanceof $class) { return $strategy->map($from, $to); } } if ($this->fallaback) { return $this->fallaback->map($from, $to); } throw new MapperNotFoundException($from); }
/** * @param mixed $request * @param mixed $object * * @return BindResult * * @throws \Exception */ public function bind($request, $object) { if (!is_object($object)) { $object = new $object(); } $newObject = $this->mapper->map($request, $object); $groups = $this->defaultGroups; if (is_callable(array($request, 'getMethod'), true)) { $groups[] = $request->getMethod(); } $issues = $this->validator->validate($object, null, $groups); return $this->createBindResultFromFilledObject($issues, $newObject); }
/** * @param mixed $request * @param mixed $object * @param string[] $validationGroups Groups to apply validation to * * @return BindResult * * @throws \Exception */ public function bind($request, $object, array $validationGroups = []) { if (!is_object($object)) { $object = new $object(); } $newObject = $this->mapper->map($request, $object); $groups = $this->defaultGroups; if (method_exists($request, 'getMethod')) { $groups[] = $request->getMethod(); } $groups = array_merge($groups, $validationGroups); $issues = $this->validator->validate($object, null, $groups); return $this->createBindResultFromFilledObject($issues, $newObject); }