protected function initWidget() { if (!isset($this->entityMeta)) { throw new \Psc\Exception('EntityMeta muss für initWidget() gesetzt sein'); } $this->widget = new ComboDropBox2($this->getComboBox(), $this->getDropBox(), $this->getFormLabel() ?: $this->entityMeta->getLabel()); }
/** * @return array */ public function getContentStreamButtons(PageRole $page, EntityMeta $contentStreamEntityMeta) { $buttons = array(); foreach ($page->getContentStream()->type('page-content')->revision($this->defaultRevision)->collection() as $contentStream) { $adapter = $contentStreamEntityMeta->getAdapter($contentStream, EntityMeta::CONTEXT_GRID); $adapter->setButtonMode(\Psc\CMS\Item\Buttonable::CLICK | \Psc\CMS\Item\Buttonable::DRAG); $adapter->setTabLabel('Seiteninhalt: ' . $page->getSlug() . ' (' . mb_strtoupper($contentStream->getLocale()) . ')'); $button = $adapter->getTabButton(); if ($lc = $contentStream->getLocale()) { $button->setLabel('Seiteninhalt für ' . mb_strtoupper($lc) . ' bearbeiten'); } else { $button->setLabel('Seiteninhalt #' . $contentStream->getIdentifier() . ' bearbeiten'); } $button->setLeftIcon('pencil'); $buttons[] = $button; } $sideBarStreams = $page->getContentStream()->type('sidebar-content')->revision($this->defaultRevision)->collection(); if (count($sideBarStreams) > 0) { $buttons[] = '<br /><br />'; foreach ($sideBarStreams as $contentStream) { $adapter = $contentStreamEntityMeta->getAdapter($contentStream, EntityMeta::CONTEXT_GRID); $adapter->setButtonMode(\Psc\CMS\Item\Buttonable::CLICK | \Psc\CMS\Item\Buttonable::DRAG); $adapter->setTabLabel('Sidebar: ' . $page->getSlug() . ' (' . mb_strtoupper($contentStream->getLocale()) . ')'); $button = $adapter->getTabButton(); if ($lc = $contentStream->getLocale()) { $button->setLabel('Sidebar ' . $contentStream->getLocale() . ' bearbeiten'); } $button->setLeftIcon('pencil'); $button->setRightIcon('grip-dotted-vertical'); $buttons[] = $button; } } return $buttons; }
/** * @return Psc|CMS\AutoCompleteMeta|Traversable(Collection) von Entities */ public function getAvaibleItems() { if (!isset($this->avaibleItems)) { if (!$this->entityMeta instanceof \Psc\CMS\EntityMeta) { throw new \Psc\Exception('Erst dpi() aufrufen oder avaibleItems setzen. (EntityMeta fehlt)'); } $this->avaibleItems = $this->entityMeta->getAutoCompleteRequestMeta(); } return $this->avaibleItems; }
/** * * Achtung! nicht bool zurückgeben, stattdessen irgendeine Exception schmeissen * * Wird EmptyDataException bei validate() geworfen und ist der Validator mit optional aufgerufen worden, wird keine ValidatorException geworfen * * @return $data */ public function validate($data) { if ($data === NULL) { throw EmptyDataException::factory(NULL); } $repository = $this->dc->getRepository($this->entityMeta->getClass()); try { return $repository->hydrate($data); } catch (\Psc\Doctrine\EntityNotFoundException $e) { throw EmptyDataException::factory(NULL, $e); } }
/** * Wandelt die assignedValues in Buttons um * * die JooseSnippets werden gesammelt, wenn sie extrahierbar sind * @return list($buttons, $snippets) */ protected function convertButtons() { $buttons = array(); $snippets = array(); if (isset($this->assignedValues)) { foreach ($this->assignedValues as $item) { if ($item instanceof \Psc\UI\ButtonInterface) { $button = $item; } elseif ($item instanceof \Psc\CMS\Entity) { $button = $this->entityMeta->getAdapter($item)->setButtonMode(Buttonable::CLICK | Buttonable::DRAG)->getDropBoxButton(); } else { throw new \InvalidArgumentException(Code::varInfo($item) . ' kann nicht in einen Button umgewandelt werden'); } if ($button instanceof \Psc\JS\JooseSnippetWidget) { $button->disableAutoLoad(); // das bevor getJooseSnippet() machen damit widgetSelector im snippet geht // aber NACH disableAutoLoad() $button->html()->addClass('assigned-item'); $snippets[] = $button->getJooseSnippet(); } else { $button->html()->addClass('assigned-item'); } $buttons[] = $button; } } return array($buttons, $snippets); }
/** * * Wird EmptyDataException bei validate() geworfen und ist der Validator mit optional aufgerufen worden, wird keine ValidatorException geworfen * @return $data */ public function validate($data = NULL) { if ($data === NULL || $data === array()) { throw EmptyDataException::factory(new \Psc\Data\ArrayCollection()); } if (!is_array($data)) { throw new \InvalidArgumentException('Parameter ist als Array erwartet. ' . Code::varInfo($data) . ' wurde übergeben'); } $identifierCaster = $this->getIdentifierCaster($this->entityMeta->getIdentifier()); $repository = $this->dc->getRepository($this->entityMeta->getClass()); $entities = new ArrayCollection(); foreach ($data as $key => $identifierString) { $identifier = $identifierCaster($identifierString, $key); $entities->add($repository->hydrate($identifier)); } return $entities; }
/** * Gibt das Label für den normalo Button zurück */ public function getButtonLabel() { if (isset($this->buttonLabel)) { return $this->buttonLabel; } elseif ($this->context === 'new') { return $this->entityMeta->getNewLabel(); } else { throw new \InvalidArgumentException(sprintf("Context '%s' ist unbekannt für getButtonLabel", $this->context)); } }
/** * Setzt das Element welches in der ComboBox ausgewählt ist * */ public function setSelected($item) { if (!isset($this->entityMeta)) { throw new \Psc\Exception('EntityMeta muss übergeben werden wenn selected gesetzt wird'); } $ec = $this->entityMeta->getClass(); if (!$item instanceof $ec) { throw new \InvalidArgumentException('Parameter Item für setSelected() muss vom Typ: ' . $ec . ' sein. ' . Code::varInfo($item) . ' wurde übergeben'); } $this->selected = $item; return $this; }
public function __construct(EntityMeta $entityMeta, $maxResults = 15) { $acRequest = $entityMeta->getAutoCompleteRequestMeta(array('term' => NULL)); $item = new stdClass(); $item->genitiv = $entityMeta->getGenitiv(); $item->fields = \Psc\FE\Helper::listStrings($entityMeta->getAutoCompleteFields(), ', ', ' oder '); $item->type = $entityMeta->getEntityName(); $item->url = $acRequest->getUrl(); $item->label = $entityMeta->getLabel(EntityMeta::CONTEXT_AUTOCOMPLETE); $item->data = array(); parent::__construct($item); $this->maxResults = $maxResults; // copy from meta // (hier die setter nehmen falls wir mal den search panel schön bauen sollten ;)) $this->setLabel($entityMeta->getAutoCompleteHeadline()); $this->setAutoCompleteDelay($entityMeta->getAutoCompleteDelay()); $this->setAutoCompleteBody($acRequest->getBody()); $this->setAutoCompleteMinLength($entityMeta->getAutoCompleteMinLength()); }
/** * @return Psc\CMS\EntityPropertyMeta */ protected function getCollectionPropertyMeta() { return $this->entityMeta->getPropertyMeta($this->collectionName); }
public function __construct($classMetadata = NULL) { parent::__construct('Psc\\Doctrine\\TestEntitites\\Article', $classMetadata ?: new \Doctrine\ORM\Mapping\ClassMetadata('Entities\\Article'), array('default' => 'Artikel')); }
protected function initValidatorRule() { $this->validatorRule = new SelectComboBoxValidatorRule($this->entityMeta->getClass(), $this->dc); }
/** * Gibt das Property für eine Objekt-Fremd-Beziehung zurück * * dies ist z.B. bei der ManyToOne Seite möglich * @return Psc\CMS\EntityPropertyMeta */ public function getForeignPropertyMeta(EntityMeta $foreignEntity) { throw new \Psc\Code\NotImplementedException(); $foreignField = \Psc\Inflector::create()->propertyName($foreignEntity->getGClass()->getClassName()); //var_dump($foreignEntity->getClassMetadata()->associationMappings); //var_dump($this->classMetadata->associationMappings); //var_dump($this->classMetadata->getFieldForColumn($foreignField)); $mapping = $this->classMetadata->getAssociationMapping(); //var_dump($mapping); return $this->getPropertyMeta($mapping); }
public function getDefaultRequestMeta(\Psc\CMS\EntityMeta $entityMeta) { return $entityMeta->getActionRequestMeta('articles', $this); // display articles list in category }
/** * @return Psc\UI\Accordion */ public function createRightAccordion(EntityMeta $entityMeta = NULL, $optionsLabel = 'Options', array $options = array()) { $entity = $this->getEntity(); $accordion = new Accordion(array('autoHeight' => true, 'active' => 0)); if (isset($entityMeta)) { if (!$entity->isNew()) { $options[] = $deleteButton = $entityMeta->getAdapter($entity, EntityMeta::CONTEXT_DELETE)->getDeleteTabButton(); } } $accordion->addSection($optionsLabel, $options); $this->addAccordion($accordion); return $accordion; }
public function initEntityMetaFor(EntityMeta $meta) { if ($meta->getEntityName() === 'user') { $meta->setGridLabel($this->trans('entities.user.grid'))->setNewLabel($this->trans('entities.user.insert'))->setLabel($this->trans('entities.user'))->setTCIColumn('email'); } }
public function validateIdentifier($id, \Psc\CMS\EntityMeta $entityMeta) { $rule = $this->typeRuleMapper->getRule($entityMeta->getIdentifier()->getType()); return $rule->validate($id); }
public function __construct($classMetadata) { parent::__construct('Psc\\Doctrine\\TestEntitites\\Tag', $classMetadata, array(TabsContentItem2::LABEL_DEFAULT => 'Tag')); }