コード例 #1
0
 /**
  * Also try using plain limitedPropertiesList instead of limited
  * hierarchy recursing.
  **/
 public function make($object, $recursive = true)
 {
     // FIXME: make entityProto() non-static, problem with forms here
     if ($object instanceof PrototypedEntity || $object instanceof Form) {
         $proto = $this->proto;
         if ($object instanceof Form) {
             $objectProto = $object->getProto();
         } else {
             $objectProto = $object->entityProto();
         }
         if ($objectProto && !ClassUtils::isInstanceOf($proto, $objectProto)) {
             if (!$objectProto->isInstanceOf($proto)) {
                 throw new WrongArgumentException('target proto ' . get_class($objectProto) . ' is not a child of ' . get_class($proto));
             }
             $proto = $objectProto;
             return $this->cloneBuilder($proto)->make($object);
         }
     }
     if ($this->proto->isAbstract()) {
         throw new WrongArgumentException('cannot make from abstract proto ' . get_class($this->proto));
     }
     return $this->compile($object, $recursive);
 }