Пример #1
0
 public static function checkPrototyped(Prototyped $object)
 {
     $form = $object->proto()->makeForm();
     self::object2form($object, $form, false);
     return $form->getErrors();
 }
Пример #2
0
 private static function assemblyObject(Prototyped $object, $array, $prefix = null, ProtoDAO $parentDao = null)
 {
     if ($object instanceof DAOConnected) {
         $dao = $object->dao();
     } else {
         $dao = $parentDao ?: null;
     }
     $proto = $object->proto();
     foreach ($proto->getPropertyList() as $property) {
         $setter = $property->getSetter();
         if ($property instanceof InnerMetaProperty) {
             $object->{$setter}($property->toValue($dao, $array, $prefix));
         } elseif ($property->isBuildable($array, $prefix)) {
             if ($property->getRelationId() == MetaRelation::ONE_TO_ONE) {
                 if ($property->getFetchStrategyId() == FetchStrategy::LAZY) {
                     $columnName = $prefix . $property->getColumnName();
                     $object->{$setter . 'Id'}($array[$columnName]);
                     continue;
                 }
             }
             $object->{$setter}($property->toValue($dao, $array, $prefix));
         }
     }
     return $object;
 }
Пример #3
0
 public static function copy(Prototyped $from, Prototyped $to, array $properties)
 {
     foreach ($properties as $property) {
         /** @var LightMetaProperty $property */
         if ($from->proto()->isPropertyExists($property->getName()) && $to->proto()->isPropertyExists($property->getName())) {
             $value = self::getValue($from, $property->getName());
             self::setValue($to, $property->getName(), $value);
         }
     }
 }