ScaffoldTask
- Full name:
\Zemit\Modules\Cli\Tasks\ScaffoldTask
- Parent class:
\Zemit\Modules\Cli\Task
Properties
cliDoc
public string $cliDoc
Methods
getDefinitionsAction
public getDefinitionsAction(string $name): array
Parameters:
Parameter | Type | Description |
---|---|---|
$name | string |
runAction
public runAction(): array
createControllerOutput
public createControllerOutput(array $definitions, array $columns, array $relationships): string
Parameters:
Parameter | Type | Description |
---|---|---|
$definitions | array | |
$columns | array | |
$relationships | array |
createModelInterfaceOutput
Generates the output for a model interface.
public createModelInterfaceOutput(array $definitions): string
Parameters:
Parameter | Type | Description |
---|---|---|
$definitions | array | The definitions for generating the model interface. |
Return Value:
The generated model interface output as a string.
createAbstractInterfaceOutput
Generates the abstract interface output based on the given definitions and columns.
public createAbstractInterfaceOutput(array $definitions, array $columns, array $relationships): string
Parameters:
Parameter | Type | Description |
---|---|---|
$definitions | array | The definitions for the abstract interface. |
$columns | array | The columns for which to generate getter and setter methods. |
$relationships | array | The columns for which to generate getter and setter methods. |
Return Value:
The generated abstract interface output as a string.
createAbstractOutput
Generates an abstract class output for the given definitions, table, columns, and tables.
public createAbstractOutput(array $definitions, array $columns, array $relationships): string
Parameters:
Parameter | Type | Description |
---|---|---|
$definitions | array | The definitions for the abstract output. |
$columns | array | The columns. |
$relationships | array | The relationship items. |
Return Value:
The abstract output as a string.
createModelOutput
Generates a comment for the createModelOutput method.
public createModelOutput(array $definitions): string
Parameters:
Parameter | Type | Description |
---|---|---|
$definitions | array | The array of model definitions. |
Return Value:
The generated comment.
createModelTestOutput
public createModelTestOutput(array $definitions, array $columns): string
Parameters:
Parameter | Type | Description |
---|---|---|
$definitions | array | |
$columns | array |
getModelClassComments
public getModelClassComments(array $definitions): string
Parameters:
Parameter | Type | Description |
---|---|---|
$definitions | array |
getValidationItems
Generates a string containing validation items for each column in the provided array.
public getValidationItems(array $columns): string
Parameters:
Parameter | Type | Description |
---|---|---|
$columns | array | An array of ColumnInterface objects. |
Return Value:
The generated validation items string.
getRelationshipItems
Generates relationship items for a given table.
public getRelationshipItems(string $table, array $columns, array $tables): array
Parameters:
Parameter | Type | Description |
---|---|---|
$table | string | The name of the table. |
$columns | array | The array of column objects. |
$tables | array | The array of table names. |
Return Value:
An array containing the generated relationship items.
getColumnMapMethod
public getColumnMapMethod(array $columns): string
Parameters:
Parameter | Type | Description |
---|---|---|
$columns | array |
getColumnMapComment
Returns the documentation comment for the getColumnMap
method.
public getColumnMapComment(): string
Return Value:
The documentation comment for the getColumnMap
method.
getColumnMapItems
Generates a string representation of column map items for a given array of columns.
public getColumnMapItems(array $columns): string
Parameters:
Parameter | Type | Description |
---|---|---|
$columns | array | An array of columns. |
Return Value:
The string representation of the column map items.
getPropertyItems
Generates property items for each column in the given array.
public getPropertyItems(array $columns): string
Parameters:
Parameter | Type | Description |
---|---|---|
$columns | array | An array of ColumnInterface objects. |
Return Value:
The generated property items.
getPropertyComment
Generates the comment for a property with the given column name and property type.
public getPropertyComment(\Phalcon\Db\ColumnInterface $column, array $definitions): string
Parameters:
Parameter | Type | Description |
---|---|---|
$column | \Phalcon\Db\ColumnInterface | The column object. |
$definitions | array | The property definitions. |
Return Value:
The generated property comment.
getGetSetMethods
Generates a string representation of getters and setters for a given array of columns.
public getGetSetMethods(array $columns, string $type = 'default', string $property = 'model'): string
Parameters:
Parameter | Type | Description |
---|---|---|
$columns | array | An array of columns. |
$type | string | (optional) The type of code to generate. Can be 'default', 'interface', or 'test'. Default is 'default'. |
$property | string | (optional) The name of the property to use in setter methods. Default is 'model'. |
Return Value:
The string representation of the getters and setters.
getSetMethodComment
Generates a comment for a getter or setter method for a specific column.
public getSetMethodComment(\Phalcon\Db\ColumnInterface $column, array $definitions, bool $get): string
Parameters:
Parameter | Type | Description |
---|---|---|
$column | \Phalcon\Db\ColumnInterface | The column object. |
$definitions | array | The property definitions. |
$get | bool | Determines whether the comment is for a getter or setter method. |
Return Value:
The generated comment.
getColumnAttributes
public getColumnAttributes(\Phalcon\Db\ColumnInterface $column): string
Parameters:
Parameter | Type | Description |
---|---|---|
$column | \Phalcon\Db\ColumnInterface |
getPropertyDefinitions
public getPropertyDefinitions(\Phalcon\Db\ColumnInterface $column): array
Parameters:
Parameter | Type | Description |
---|---|---|
$column | \Phalcon\Db\ColumnInterface |
saveFile
Saves a file with the given text content.
public saveFile(string $file, string $text, bool $force = false): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$file | string | The path of the file to be saved. |
$text | string | The content to be written to the file. |
$force | bool | Determines whether to overwrite an existing file. Default is false. |
Return Value:
Returns true if the file was saved successfully, false otherwise.
Inherited methods
getLicenseStamp
Retrieves the license stamp.
public getLicenseStamp(): string|null
Return Value:
The license stamp, or null if there is no license.
getStrictTypes
Retrieves the value of the 'strictTypes' property.
public getStrictTypes(): string|null
Return Value:
The value of the 'strictTypes' property, or null if the 'no-strict-types' parameter is set.
isWhitelistedTable
Checks if the given table is whitelisted.
public isWhitelistedTable(string $table): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$table | string | The table name to check. |
Return Value:
Returns true if the table is whitelisted, false otherwise.
isExcludedTable
Determines if a table is excluded.
public isExcludedTable(string $table): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$table | string | The name of the table to check. |
Return Value:
Returns true if the table is excluded, false otherwise.
isNoControllers
public isNoControllers(): bool
isNoInterfaces
public isNoInterfaces(): bool
isNoAbstracts
public isNoAbstracts(): bool
isNoModels
public isNoModels(): bool
isNoEnums
public isNoEnums(): bool
isNoStrictTypes
public isNoStrictTypes(): bool
isNoLicense
public isNoLicense(): bool
isNoComments
public isNoComments(): bool
isNoGetSetMethods
public isNoGetSetMethods(): bool
isNoValidations
public isNoValidations(): bool
isNoRelationships
public isNoRelationships(): bool
isNoColumnMap
public isNoColumnMap(): bool
isNoSetSource
public isNoSetSource(): bool
isNoTypings
public isNoTypings(): bool
isGranularTypings
public isGranularTypings(): bool
isAddRawValueType
public isAddRawValueType(): bool
isProtectedProperties
public isProtectedProperties(): bool
isAbsolutePath
Determines if a given path is an absolute path.
public isAbsolutePath(string $path = ''): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$path | string | The path to be checked. (default: null) |
Return Value:
Returns true if the path is an absolute path, false otherwise.
absolutePathOr
Retrieves the absolute file or directory path.
public absolutePathOr(string $path = '', string $fullPath = ''): string
Parameters:
Parameter | Type | Description |
---|---|---|
$path | string | The relative or absolute path to the file or directory. |
$fullPath | string | The full path including directory for the file or directory. |
Return Value:
The absolute file or directory path. If the given path is absolute, it will be returned as is. Otherwise, the full path including directory will be returned.
getDirectory
Retrieves the directory path for a given file or directory path.
public getDirectory(string $path = ''): string
Parameters:
Parameter | Type | Description |
---|---|---|
$path | string | The relative or absolute path to the file or directory. |
Return Value:
The absolute directory path for the given file or directory path.
getSrcDirectory
public getSrcDirectory(string $path = ''): string
Parameters:
Parameter | Type | Description |
---|---|---|
$path | string |
getTestsDirectory
public getTestsDirectory(string $path = ''): string
Parameters:
Parameter | Type | Description |
---|---|---|
$path | string |
getControllersDirectory
public getControllersDirectory(string $path = ''): string
Parameters:
Parameter | Type | Description |
---|---|---|
$path | string |
getModelsDirectory
public getModelsDirectory(string $path = ''): string
Parameters:
Parameter | Type | Description |
---|---|---|
$path | string |
getModelsInterfacesDirectory
public getModelsInterfacesDirectory(string $path = ''): string
Parameters:
Parameter | Type | Description |
---|---|---|
$path | string |
getAbstractsDirectory
public getAbstractsDirectory(string $path = ''): string
Parameters:
Parameter | Type | Description |
---|---|---|
$path | string |
getAbstractsInterfacesDirectory
public getAbstractsInterfacesDirectory(string $path = ''): string
Parameters:
Parameter | Type | Description |
---|---|---|
$path | string |
getModelsTestsDirectory
public getModelsTestsDirectory(string $path = ''): string
Parameters:
Parameter | Type | Description |
---|---|---|
$path | string |
getNamespaceFromPath
Converts a file system path to a PHP namespace.
public getNamespaceFromPath(string $path): string
Parameters:
Parameter | Type | Description |
---|---|---|
$path | string | The file system path to be converted. |
Return Value:
The converted PHP namespace.
getNamespace
public getNamespace(): string
getControllersNamespace
public getControllersNamespace(): string
getModelsNamespace
public getModelsNamespace(): string
getAbstractsNamespace
public getAbstractsNamespace(): string
getModelsInterfacesNamespace
public getModelsInterfacesNamespace(): string
getAbstractsInterfacesNamespace
public getAbstractsInterfacesNamespace(): string
getModelsTestsNamespace
public getModelsTestsNamespace(): string
describeColumns
Retrieves the columns of a given table.
public describeColumns(string $table): array
Parameters:
Parameter | Type | Description |
---|---|---|
$table | string | The name of the table to describe the columns. |
Return Value:
An array of columns for the specified table.
describeReferences
Retrieves the references of a given table.
public describeReferences(string $table): array
Parameters:
Parameter | Type | Description |
---|---|---|
$table | string | The name of the table to describe the references. |
Return Value:
An array of references for the specified table.
describeIndexes
Retrieves the indexes of a given table.
public describeIndexes(string $table): array
Parameters:
Parameter | Type | Description |
---|---|---|
$table | string | The name of the table to describe the indexes. |
Return Value:
An array of indexes for the specified table.
isRawValue
Determines if a value is a Phalcon DB RawValue.
public isRawValue(string|null $defaultValue = null): bool
Parameters:
Parameter | Type | Description |
---|---|---|
$defaultValue | **string | null** |
Return Value:
Returns true if the value is a raw value, false otherwise.
getColumnType
Determines the PHP data type of column.
public getColumnType(\Phalcon\Db\ColumnInterface $column): string
Parameters:
Parameter | Type | Description |
---|---|---|
$column | \Phalcon\Db\ColumnInterface | The column to check. |
Return Value:
The data type of the column. Possible values are: - 'bool' for boolean columns. - 'int' for integer columns. - 'float' for decimal or float columns. - 'double' for double columns. - 'string' for all other column types.
getDefaultValue
Retrieves the default value for a column.
public getDefaultValue(\Phalcon\Db\ColumnInterface $column): mixed
Parameters:
Parameter | Type | Description |
---|---|---|
$column | \Phalcon\Db\ColumnInterface | The column object to retrieve the default value from. |
Return Value:
Returns the default value of the column as a string, integer, boolean, float, or null based on the column type.
getPropertyName
Retrieves the property name based on the given name.
public getPropertyName(string $name): string
Parameters:
Parameter | Type | Description |
---|---|---|
$name | string | The name from which to retrieve the property name. |
Return Value:
Returns the property name as a string.
getTableName
Retrieves the table name based on the given name.
public getTableName(string $name): string
Parameters:
Parameter | Type | Description |
---|---|---|
$name | string | The original name of the table. |
Return Value:
Returns the table name with the first letter capitalized and all other letters unchanged.
beforeExecuteRoute
public beforeExecuteRoute(): void
helpAction
public helpAction(): void
mainAction
public mainAction(): ?array
normalizeResponse
public normalizeResponse(bool $response = true, ?int $code = null, ?string $status = null): array
Parameters:
Parameter | Type | Description |
---|---|---|
$response | bool | |
$code | ?int | |
$status | ?string |
afterExecuteRoute
Handle rest response automagically
public afterExecuteRoute(\Phalcon\Cli\Dispatcher $dispatcher): void
Parameters:
Parameter | Type | Description |
---|---|---|
$dispatcher | \Phalcon\Cli\Dispatcher |
Throws: