public function getColumnsDefinition() { $annotation = $this->getCustomAnnotation(); $definition = $this->getContentTypeDefinition(); $list = $annotation->getList(1); $columns = []; foreach ($list as $key => $title) { if ($definition->hasProperty($key)) { $formelementDefinition = null; $column = new PropertyColumn(); try { $formelementDefinition = $definition->getViewDefinition('default')->getFormElementDefinition($key); } catch (CMDLParserException $e) { // If view does not have a form element definition, but still knows the property } if ($key == 'status' && $definition->hasStatusList()) { $column = new StatusColumn(); } elseif ($key == 'subtype' && $definition->hasSubtypes()) { $column = new SubtypeColumn(); } else { if ($formelementDefinition) { switch ($formelementDefinition->getFormElementType()) { case 'selection': $column = new SelectionColumn(); break; default: $column = new PropertyColumn(); break; } } } $column->setProperty($key); $column->setFormElementDefinition($formelementDefinition); if ($key == 'name') { $column->setLinkToRecord(true); } } else { $column = new AttributeColumn(); $column->setAttribute($key); if (trim($key, '.') == 'id') { $column->setLinkToRecord(true); } } $column->setTitle($title); $column->setRenderer($this->getCellRenderer()); $columns[] = $column; } // Add Edit/Delete-Buttons $buttonColumn = new ButtonColumn(); $buttonColumn->setEditButton(true); if ($this->canDo('delete', $this->getRepository(), $this->getContentTypeDefinition())) { $buttonColumn->setDeleteButton(true); } $buttonColumn->setRenderer($this->getCellRenderer()); $columns[] = $buttonColumn; return $columns; }
public function getColumnsDefinition() { $contentTypeDefinition = $this->getContentTypeDefinition(); $columns = []; $column = new AttributeColumn(); $column->setTitle('ID'); $column->setAttribute('id'); $column->setLinkToRecord(true); $columns[] = $column; if ($contentTypeDefinition->hasSubtypes()) { $column = new SubtypeColumn(); $column->setTitle('Subtype'); $columns[] = $column; } $column = new PropertyColumn(); $column->setTitle('Name'); $column->setProperty('name'); $column->setLinkToRecord(true); try { $column->setFormElementDefinition($contentTypeDefinition->getViewDefinition('default')->getFormElementDefinition('name')); } catch (CMDLParserException $e) { // If default view does not have a name form element } $columns[] = $column; $column = new AttributeColumn(); $column->setTitle('Last Change'); $column->setAttribute('lastchange'); $columns[] = $column; if ($contentTypeDefinition->hasStatusList()) { $column = new StatusColumn(); $column->setTitle('Status'); $columns[] = $column; } if ($contentTypeDefinition->isSortable()) { $column = new AttributeColumn(); $column->setTitle('Pos'); $column->setAttribute('position'); $columns[] = $column; } // Add Edit/Delete-Buttons $buttonColumn = new ButtonColumn(); $buttonColumn->setEditButton(true); if ($this->canDo('delete', $this->getRepository(), $this->getContentTypeDefinition())) { $buttonColumn->setDeleteButton(true); } $buttonColumn->setRenderer($this->getCellRenderer()); $columns[] = $buttonColumn; foreach ($columns as $column) { $column->setRenderer($this->getCellRenderer()); } return $columns; }