Example #1
0
 /**
  * @param \Model\Generator\Part\Model $part
  */
 public function generateEnumConstantList($part)
 {
     $file = $part->getFile();
     $table = $part->getTable();
     foreach ($table->getColumn() as $column) {
         if ($column->getColumnType() == 'enum') {
             $enumList = $column->getEnumValuesAsArray();
             // пропускаем флаги и enum поля с числом параметров >10
             if (substr($column->getName(), 0, 3) == 'is_' || $enumList == array('y', 'n') || count($enumList) > 10) {
                 continue;
             }
             foreach ($enumList as $enumValue) {
                 $columnName = $column->getName();
                 $name = strtoupper($columnName . '_' . $enumValue);
                 $property = new PropertyGenerator($name, $enumValue, PropertyGenerator::FLAG_CONSTANT);
                 $tags = array(array('name' => 'const'), array('name' => 'var', 'description' => 'string'));
                 $docblock = new DocBlockGenerator("Значение {$enumValue} поля {$columnName}");
                 $docblock->setTags($tags);
                 $property->setDocBlock($docblock);
                 $file->getClass()->addPropertyFromGenerator($property);
             }
         }
     }
 }