/**
  * @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;
     }
     Assert::isUnreachable();
 }
 private function spawnObject(Prototyped $object, array $options)
 {
     foreach ($object->proto()->getPropertyList() as $propName => $property) {
         /* @var $property LightMetaProperty */
         if (isset($options[$propName])) {
             $setter = $property->getSetter();
             $object->{$setter}($options[$propName]);
         }
     }
     return $object;
 }
 private static function assemblyObject(Prototyped $object, $array, $prefix = null)
 {
     if ($object instanceof DAOConnected) {
         $dao = $object->dao();
     } else {
         $dao = 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;
 }
 public static function checkPrototyped(Prototyped $object)
 {
     $form = $object->proto()->makeForm();
     self::object2form($object, $form, false);
     return $form->getErrors();
 }