/** * Add fields by properties without "Exclude" annotation */ protected function addFieldsByExcludeStrategy() { $properties = $this->getClassReflection()->getProperties(); $excludedAnnotations = $this->readPropertyAnnotations(ExcludeAnnotation::class); $columnsAnnotations = $this->readPropertyAnnotations(ColumnAnnotation::class); foreach ($properties as $property) { if ($property->isStatic()) { continue; } $name = $property->getName(); if (isset($excludedAnnotations[$name])) { continue; } $field = new Field($name); if (isset($columnsAnnotations[$name])) { $this->applyAnnotation($field, $columnsAnnotations[$name]); } $this->resolveType($field); $this->schema->addField($field); } }
/** * {@inheritdoc} */ public function getSchema() { $colsNumber = 0; foreach ($this->source as $row) { $count = count($row); if ($count > $colsNumber) { $colsNumber = $count; } } $schema = new Schema(); if ($colsNumber === 0) { return $schema; } $colSize = (int) round(100 / $colsNumber); for ($i = 0; $i < $colsNumber; ++$i) { $field = new Field($i); $field->setWidth($colSize); $schema->addField($field); } return $schema; }