コード例 #1
0
ファイル: MapperStrategy.php プロジェクト: pugx/bindto
 /**
  * {@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);
 }
コード例 #2
0
ファイル: Binder.php プロジェクト: eux/Bindto
 /**
  * @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);
 }
コード例 #3
0
ファイル: Binder.php プロジェクト: pugx/bindto
 /**
  * @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);
 }