Exemplo n.º 1
0
 /**
  * @return Psc\UI\Component
  */
 public function createComponent($property, Type $propertyType)
 {
     try {
         if (isset($this->propertyComponents[$property])) {
             $component = $this->propertyComponents[$property];
         } else {
             $component = $this->componentMapper->inferComponent($propertyType);
         }
         $event = $this->getManager()->dispatchEvent(self::EVENT_COMPONENT_CREATED, array('component' => $component, 'creater' => $this, 'name' => $property, 'value' => $this->getEntity()->callGetter($property), 'label' => $this->labeler->getLabel($property)), $this);
         if (!$event->isProcessed()) {
             $component->setFormName($event->getData()->name);
             $component->setFormValue($event->getData()->value);
             $component->setFormLabel($event->getData()->label);
         }
         // else: wenn wir hier wollten, dass die component vom event replacebar sein soll, könnten wir hier event->getData()->component nehmen
         $component->init();
         // der eventListener kann ruhig init() aufrufen, wir stellen hier sicher, dass es aufgerufen wird
         return $component;
     } catch (NoComponentFoundException $e) {
         $e->setMessage($e->getMessage() . ' property: ' . $property);
         // what to do here?
         throw $e;
     }
 }
Exemplo n.º 2
0
 /**
  * @return Psc\CMS\EntityPropertyMeta
  */
 public function getPropertyMeta($name, Labeler $labeler = NULL)
 {
     if (!array_key_exists($name, $this->properties)) {
         if (!isset($labeler)) {
             $labeler = new \Psc\CMS\Labeler();
         }
         try {
             $type = $this->getSetMeta()->getFieldType($name);
             // schmeiss exception wenns das property nicht gibt
         } catch (\Psc\Data\FieldNotDefinedException $e) {
             throw \Psc\Doctrine\FieldNotDefinedException::entityField($this->getClass(), $name);
         }
         $this->properties[$name] = $meta = new EntityPropertyMeta($name, $type, $labeler->getLabel($name));
         if ($this->classMetadata->isIdentifier($name) && $this->getClassMetadata()->usesIdGenerator()) {
             $meta->setAutogeneratedValue(TRUE);
         }
     } elseif (isset($labeler)) {
         // update
         $this->properties[$name]->setLabel($labeler->getLabel($name));
     }
     return $this->properties[$name];
 }