Beispiel #1
0
 /**
  * Fügt ein Property des Entities als Spalte dem Grid hinzu
  *
  * flags:
  *   TCI_BUTTON stellt den Inhalt des Properties in einen Button dar, der das Entity als Button repräsentiert.
  *
  * wenn mit dem Grid Tabs geöffnet werden sollen, muss mindestens ein Property ein TCI_BUTTON flag haben
  * @param bitmap $flags
  * @param Closure $htmlConverter für tci: function ($button, $entity, $property, $entityMeta), normal: function ($propertyValue, $entity, $property)
  * @return Psc\CMS\FormPanelColumn
  */
 public function addProperty($propertyName, $flags = 0x0, Closure $htmlConverter = NULL)
 {
     $property = $this->entityMeta->getPropertyMeta($propertyName, $this->labeler);
     if ($flags & self::TCI_BUTTON) {
         $entityMeta = $this->entityMeta;
         return $this->createColumn($property->getName(), $property->getType(), $property->getLabel(), array($property->getName(), 'tci'), function (Entity $entity) use($property, $entityMeta, $htmlConverter) {
             $adapter = $entityMeta->getAdapter($entity, EntityMeta::CONTEXT_GRID);
             $adapter->setButtonMode(\Psc\CMS\Item\Buttonable::CLICK | \Psc\CMS\Item\Buttonable::DRAG);
             $button = $adapter->getTabButton();
             if (isset($htmlConverter)) {
                 return $htmlConverter($button, $entity, $property, $entityMeta);
             }
             return $button;
         });
     } else {
         $column = $this->createColumn($property->getName(), $property->getType(), $property->getLabel());
         $valueConverter = $this->getDefaultConverter($column);
         $column->setConverter(function (Entity $entity) use($property, $column, $valueConverter, $htmlConverter) {
             if ($htmlConverter) {
                 return $htmlConverter($entity->callGetter($property->getName()), $entity, $property);
             } else {
                 return $valueConverter($entity->callGetter($property->getName()), $column);
             }
         });
         return $column;
     }
 }
 /**
  * Tested eine Custom Action
  *
  * @param int|NULL $id
  * @return whatever $format is set to
  */
 public function action($id, $resourceName, $format = 'html', $method = 'GET', $data = NULL)
 {
     if ($id === NULL) {
         $url = $this->urlPrefix . '/' . $this->entityMeta->getEntityNamePlural() . '/' . $resourceName;
     } else {
         $url = $this->urlPrefix . '/' . $this->entityMeta->getEntityName() . '/' . $id . '/' . $resourceName;
     }
     $dispatcher = $this->dispatcher($method, $url);
     if ($data) {
         $dispatcher->setRequestData($this->parsePost($data));
     }
     return $this->result($dispatcher, $format);
 }
 public function inserts($subResource = NULL)
 {
     $this->hasAction($this->getUrlPrefix() . '/' . $this->entityMeta->getEntityNamePlural() . ($subResource ? '/' . $subResource : NULL));
     $this->hasMethod('POST');
     return $this;
 }