public static function getLong(Form $form)
 {
     $long = array();
     foreach ($form->getPrimitiveList() as $primitive) {
         if (strlen($primitive->getName()) > 1) {
             $long[] = $primitive->getName() . self::getValueType($primitive);
         }
     }
     return $long;
 }
Exemplo n.º 2
0
 /**
  * @return Form
  */
 public static function removePrefix(Form $form, $prefix)
 {
     $newForm = Form::create();
     foreach ($form->getPrimitiveList() as $primitive) {
         $primitive->setName(strtr($primitive->getName(), [$prefix => '']));
         $newForm->add($primitive);
     }
     return $newForm;
 }
Exemplo n.º 3
0
 /**
  * @static
  * @param Prototyped $object
  * @param Form $form
  * @return array modified objects to save
  * @throws WrongArgumentException
  */
 public static function fillObject(Prototyped $object, Form $form)
 {
     $modifications = array();
     foreach ($form->getPrimitiveList() as $primitive) {
         try {
             $value = $primitive->getValue();
             $field = $primitive->getName();
             if (!self::hasProperty($object, $field)) {
                 continue;
             }
             if (self::getValue($object, $field) != $value) {
                 self::setValue($object, $field, $value);
                 $owner = self::getOwner($object, $field);
                 $modifications[get_class($owner) . '#' . $owner->getId()] = $owner;
             }
         } catch (WrongArgumentException $e) {
             throw $e;
         }
     }
     return $modifications;
 }