Beispiel #1
0
 /**
  * Maps entity property to forms or child containers.
  *
  * @param \Zend\Form\FormInterface $form
  * @param \Core\Entity\EntityInterface $entity
  * @param string $property
  * @return void
  */
 protected function mapEntity($form, $entity, $property)
 {
     if (false === $property) {
         return;
     }
     if (true === $property) {
         $mapEntity = $entity;
     } else {
         if ($entity->hasProperty($property) || is_callable([$entity, "get{$property}"])) {
             $getter = "get{$property}";
             $mapEntity = $entity->{$getter}();
         } else {
             return;
         }
     }
     if ($form instanceof Container) {
         $form->setEntity($mapEntity);
     } else {
         $form->bind($mapEntity);
     }
 }
Beispiel #2
0
 /**
  * Maps entity property to forms or child containers.
  *
  * @param \Zend\Form\FormInterface $form
  * @param string $key
  * @param \Core\Entity\EntityInterface $entity
  * @return void
  */
 protected function mapEntity($form, $key, $entity)
 {
     if (true === $key) {
         $mapEntity = $entity;
     } elseif (isset($entity->{$key})) {
         $mapEntity = $entity->{$key};
     } else {
         return;
     }
     if ($form instanceof Container) {
         $form->setEntity($mapEntity);
     } else {
         $form->bind($mapEntity);
     }
 }