public function build(ObjectModel\DataObject $do, array $display = null, $identifier = false) { if ($identifier === true) { $identifier = new FieldElement(ObjectUri::IDENTIFIER); $identifier->setTitle("Identifiant unique")->setConstraint(Property::CONSTRAINT_MANDATORY, true)->setConstraint(Property::CONSTRAINT_MAXLENGTH, 10); $this->addElement($identifier); } if (is_null($display)) { $display = array_keys($do->getProperties()); } foreach ($display as $element) { $property = $do->getRecursiveProperty($element); if ($property instanceof AbstractProperty) { /* convert property to form element */ $this->addElementFromProperty($property, $element, (count($this->_elements) + 1) * 100); } } }
/** * Add content from a data object and optional columns ids * * @param t41\ObjectModel\DataObject $do * @param array $columns * @return t41\View\TableComponent */ public function setContent(DataObject $do, array $columns = array()) { foreach ($columns as $column) { if (($prop = $do->getRecursiveProperty($column)) !== false) { $format = $prop instanceof CurrencyProperty ? self::FORM_CURRENCY : self::FORM_DEFAULT; $this->addColumn($column, $prop->getLabel(), $format); } } $data = $do->toArray(null, false, true); // \Zend_Debug::dump($data); die; $this->addDataRow($data['data']); return $this; }