class GeneratorService (View source)

Service for the Kickstart generator

Properties

protected ObjectManagerInterface $objectManager
protected PackageManager $packageManager
protected Inflector $inflector
protected ReflectionService $reflectionService
protected array $generatedFiles

Methods

array
generateActionController(string $packageKey, string $subpackage, string $controllerName, bool $fusionView = false, bool $overwrite = false)

Generate a controller with the given name for the given package

array
generateCrudController(string $packageKey, string $subpackage, string $controllerName, bool $fusionView = false, bool $overwrite = false)

Generate an Action Controller with pre-made CRUD methods

array
generateCommandController(string $packageKey, string $controllerName, bool $overwrite = false)

Generate a command controller with the given name for the given package

array
generateView(string $packageKey, string $subpackage, string $controllerName, string $viewName, string $templateName, bool $overwrite = false)

Generate a view with the given name for the given package and controller

array
generateLayout(string $packageKey, string $layoutName, bool $overwrite = false)

Generate a default layout

array
generateFusion(string $packageKey, string $subpackage, string $controllerName, string $viewName, string $templateName, bool $overwrite = false)

Generate a Fusion with the given name for the given package and controller

array
generatePrototype(string $packageKey, string $layoutName, bool $overwrite = false)

Generate a default page prototype

array
generateModel(string $packageKey, string $modelName, array $fieldDefinitions, bool $overwrite = false)

Generate a model for the package with the given model name and fields

array
generateTestsForModel(string $packageKey, string $modelName, bool $overwrite = false)

Generate a dummy testcase for a model for the package with the given model name

array
generateRepository(string $packageKey, string $modelName, bool $overwrite = false)

Generate a repository for a model given a model name and package key

array
generateDocumentation(string $packageKey)

Generate a documentation skeleton for the package key

array
generateTranslation(string $packageKey, string $sourceLanguageKey, array $targetLanguageKeys = [])

Generate translation for the package key

array
normalizeFieldDefinitions(array $fieldDefinitions, string $namespace = '')

Normalize types and prefix types with namespaces

void
generateFile(string $targetPathAndFilename, string $fileContent, bool $force = false)

Generate a file with the given content and add it to the generated files

string
renderTemplate(string $templatePathAndFilename, array $contextVariables)

Render the given template file with the given variables

array

Details

array generateActionController(string $packageKey, string $subpackage, string $controllerName, bool $fusionView = false, bool $overwrite = false)

Generate a controller with the given name for the given package

Parameters

string $packageKey

The package key of the controller's package

string $subpackage

An optional subpackage name

string $controllerName

The name of the new controller

bool $fusionView

If the controller should default to a FusionView

bool $overwrite

Overwrite any existing files?

Return Value

array

An array of generated filenames

array generateCrudController(string $packageKey, string $subpackage, string $controllerName, bool $fusionView = false, bool $overwrite = false)

Generate an Action Controller with pre-made CRUD methods

Parameters

string $packageKey

The package key of the controller's package

string $subpackage

An optional subpackage name

string $controllerName

The name of the new controller

bool $fusionView

If the controller should default to a FusionView

bool $overwrite

Overwrite any existing files?

Return Value

array

An array of generated filenames

array generateCommandController(string $packageKey, string $controllerName, bool $overwrite = false)

Generate a command controller with the given name for the given package

Parameters

string $packageKey

The package key of the controller's package

string $controllerName

The name of the new controller

bool $overwrite

Overwrite any existing files?

Return Value

array

An array of generated filenames

array generateView(string $packageKey, string $subpackage, string $controllerName, string $viewName, string $templateName, bool $overwrite = false)

Generate a view with the given name for the given package and controller

Parameters

string $packageKey

The package key of the controller's package

string $subpackage

An optional subpackage name

string $controllerName

The name of the new controller

string $viewName

The name of the view

string $templateName

The name of the view

bool $overwrite

Overwrite any existing files?

Return Value

array

An array of generated filenames

array generateLayout(string $packageKey, string $layoutName, bool $overwrite = false)

Generate a default layout

Parameters

string $packageKey

The package key of the controller's package

string $layoutName

The name of the layout

bool $overwrite

Overwrite any existing files?

Return Value

array

An array of generated filenames

array generateFusion(string $packageKey, string $subpackage, string $controllerName, string $viewName, string $templateName, bool $overwrite = false)

Generate a Fusion with the given name for the given package and controller

Parameters

string $packageKey

The package key of the controller's package

string $subpackage

An optional subpackage name

string $controllerName

The name of the new controller

string $viewName

The name of the view

string $templateName

The name of the view

bool $overwrite

Overwrite any existing files?

Return Value

array

An array of generated filenames

array generatePrototype(string $packageKey, string $layoutName, bool $overwrite = false)

Generate a default page prototype

Parameters

string $packageKey

The package key of the controller's package

string $layoutName

The name of the layout

bool $overwrite

Overwrite any existing files?

Return Value

array

An array of generated filenames

array generateModel(string $packageKey, string $modelName, array $fieldDefinitions, bool $overwrite = false)

Generate a model for the package with the given model name and fields

Parameters

string $packageKey

The package key of the controller's package

string $modelName

The name of the new model

array $fieldDefinitions

The field definitions

bool $overwrite

Overwrite any existing files?

Return Value

array

An array of generated filenames

array generateTestsForModel(string $packageKey, string $modelName, bool $overwrite = false)

Generate a dummy testcase for a model for the package with the given model name

Parameters

string $packageKey

The package key of the controller's package

string $modelName

The name of the new model fpr which to generate the test

bool $overwrite

Overwrite any existing files?

Return Value

array

An array of generated filenames

array generateRepository(string $packageKey, string $modelName, bool $overwrite = false)

Generate a repository for a model given a model name and package key

Parameters

string $packageKey

The package key

string $modelName

The name of the model

bool $overwrite

Overwrite any existing files?

Return Value

array

An array of generated filenames

array generateDocumentation(string $packageKey)

Generate a documentation skeleton for the package key

Parameters

string $packageKey

The package key

Return Value

array

An array of generated filenames

array generateTranslation(string $packageKey, string $sourceLanguageKey, array $targetLanguageKeys = [])

Generate translation for the package key

Parameters

string $packageKey
string $sourceLanguageKey
array $targetLanguageKeys

Return Value

array

An array of generated filenames

protected array normalizeFieldDefinitions(array $fieldDefinitions, string $namespace = '')

Normalize types and prefix types with namespaces

Parameters

array $fieldDefinitions

The field definitions

string $namespace

The namespace

Return Value

array

The normalized and type converted field definitions

protected void generateFile(string $targetPathAndFilename, string $fileContent, bool $force = false)

Generate a file with the given content and add it to the generated files

Parameters

string $targetPathAndFilename
string $fileContent
bool $force

Return Value

void

protected string renderTemplate(string $templatePathAndFilename, array $contextVariables)

Render the given template file with the given variables

Parameters

string $templatePathAndFilename
array $contextVariables

Return Value

string

Exceptions

Exception

protected array getPrimaryNamespaceAndEntryPath(PackageInterface $package)

No description

Parameters

PackageInterface $package

Return Value

array