public function initDynamicVariables() { $this->dynamicVars = self::getConfigDynamicVariables(); $this->dynamicVars = array_merge($this->dynamicVars, ['$MODEL_NAME$' => $this->modelName, '$MODEL_NAME_CAMEL$' => $this->modelNameCamel, '$MODEL_NAME_PLURAL$' => $this->modelNamePlural, '$MODEL_NAME_PLURAL_CAMEL$' => $this->modelNamePluralCamel, '$DISPLAY_ATTRIBUTE$' => DataBaseHelper::getColumnFromTable($this->tableName)]); if ($this->tableName) { $this->dynamicVars['$TABLE_NAME$'] = $this->tableName; } else { $this->dynamicVars['$TABLE_NAME$'] = $this->modelNamePluralCamel; } }
private function getDisplayAttr() { return DataBaseHelper::getColumnFromTable($this->commandData->tableName); }
public function generateFieldsFromTable() { $this->schema->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string'); $columns = $this->schema->listTableColumns($this->tableName); $fields = []; foreach ($columns as $column) { switch ($column->getType()->getName()) { case 'integer': $fieldInput = $this->generateIntFieldInput($column->getName(), 'integer', $column); if (strpos($column->getName(), '_id') > 0) { $type = 'select'; $tableSourceName = $this->checkForForeignKeySourceTable($column->getName()); $columnName = DataBaseHelper::getColumnFromTable($tableSourceName); if ($tableSourceName != '') { $type .= ':' . $tableSourceName . ':' . $columnName; } } else { $type = 'number'; } break; case 'tinyint': $fieldInput = $this->generateIntFieldInput($column->getName(), 'tinyInteger', $column); $type = 'checkbox'; break; case 'smallint': $fieldInput = $this->generateIntFieldInput($column->getName(), 'smallInteger', $column); $type = 'number'; break; case 'bigint': $fieldInput = $this->generateIntFieldInput($column->getName(), 'bigInteger', $column); $type = 'number'; break; case 'boolean': $fieldInput = $this->generateSingleFieldInput($column->getName(), 'boolean'); $type = 'checkbox'; break; case 'datetime': $fieldInput = $this->generateSingleFieldInput($column->getName(), 'dateTime'); $type = 'date'; break; case 'datetimetz': $fieldInput = $this->generateSingleFieldInput($column->getName(), 'dateTimeTz'); $type = 'date'; break; case 'date': $fieldInput = $this->generateSingleFieldInput($column->getName(), 'date'); $type = 'date'; break; case 'time': $fieldInput = $this->generateSingleFieldInput($column->getName(), 'time'); $type = 'text'; break; case 'decimal': $fieldInput = $this->generateDecimalInput($column, 'decimal'); $type = 'number'; break; case 'float': $fieldInput = $this->generateFloatInput($column); $type = 'number'; break; case 'string': $fieldInput = $this->generateStringInput($column); $type = 'text'; break; case 'text': $fieldInput = $this->generateTextInput($column); $type = 'textarea'; break; default: $fieldInput = $this->generateTextInput($column); $type = 'text'; } if (strtolower($column->getName()) == 'password') { $type = 'password'; } elseif (strtolower($column->getName()) == 'email') { $type = 'email'; } if (!empty($fieldInput)) { // $fieldInput .= $this->checkForDefault($column); // $fieldInput .= $this->checkForNullable($column); // $fieldInput .= $this->checkForUnique($column); $fields[] = GeneratorUtils::processFieldInput($fieldInput, $type, $this->getValidations($column)); } } return $fields; }