Пример #1
0
 /**
  * @throws BaseException
  * @return ModelAndView
  **/
 public function run(Prototyped $subject, Form $form, HttpRequest $request)
 {
     Assert::isFalse($this->running, 'command already running');
     Assert::isTrue($subject instanceof DAOConnected);
     $this->transaction = InnerTransaction::begin($subject->dao());
     try {
         $mav = $this->command->run($subject, $form, $request);
         $this->running = true;
         return $mav;
     } catch (BaseException $e) {
         $this->transaction->rollback();
         throw $e;
     }
 }
Пример #2
0
 public static function checkPrototyped(Prototyped $object)
 {
     $form = $object->proto()->makeForm();
     self::object2form($object, $form, false);
     return $form->getErrors();
 }
Пример #3
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;
 }
Пример #4
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);
         }
     }
 }