GeneratorCommand

Generator command.

abstract class Winter\Storm\Scaffold\GeneratorCommand
extends Winter\Storm\Console\Command
implements 
    Symfony\Component\Console\Command\SignalableCommandInterface

This class is used as a base for scaffolding commands, modifying stub files and copying them over to a specific location.

Traits

Trait Description
HandlesCleanup

Console Command Trait that injects cross-platform signal handling to trigger cleanup on exit through the handleCleanup() method on the implementing class.

ProvidesAutocompletion

Console Command Trait that injects cross-platform signal handling to trigger cleanup on exit through the handleCleanup() method on the implementing class.

Properties

protected $files : Winter\Storm\Filesystem\Filesystem

The filesystem instance.

protected $nameFrom : string

The argument that the generated class name comes from

protected $reservedNames : string[]

Reserved names that cannot be used for generation.

protected $stubs : array

A mapping of stub to generated file.

protected $type : string

The type of class being generated.

protected $vars : array

An array of variables to use in stubs.

protected $replaces : array

Inherited from Command

List of commands that this command replaces (aliases)

Methods

public __construct () : void

Create a new controller creator command instance.

Returns
void

public handle () : bool | null

Execute the console command.

Returns
bool | null

public makeStub (string $stubName)

Make a single stub.

Parameters
Property Description
$stubName
string

The source filename for the stub.

Returns
mixed

public makeStubs () : void

Make all stubs.

Returns
void

protected getDestinationForStub (string $stubName) : string

Get the destination path for the provided stub name

Parameters
Property Description
$stubName
string
Returns
string

protected getDestinationPath () : string

Get the base path to output generated stubs to

Returns
string

protected getNameInput () : string

Get the desired class name from the input.

Returns
string

protected getSourcePath () : string

Get the base path to source stub files from

Returns
string

protected isReservedName (string $name) : bool

Checks whether the given name is reserved.

Parameters
Property Description
$name
string
Returns
bool

protected makeDirectory (string $path) : void

Build the directory for the class if necessary.

Parameters
Property Description
$path
string
Returns
void

protected modifyString (string | array $type, string $string) : string

Internal helper that handles modify a string, with extra logic.

Parameters
Property Description
$type
string | array
$string
string
Returns
string

protected prepareVars () : array

Prepare variables for stubs.

Returns
array

protected processVars (array $vars) : array

Converts all variables to available modifier and case formats.

Syntax is CASE_MODIFIER_KEY, eg: lower_plural_xxx

Parameters
Property Description
$vars
array
Returns
array

public alert (string $string, int | string | null $verbosity = null) : void

Inherited from Command

Write a string in an alert box.

Parameters
Property Description
$string
string
$verbosity
int | string | null
Returns
void

public complete (Symfony\Component\Console\Completion\CompletionInput $input, Symfony\Component\Console\Completion\CompletionSuggestions $suggestions) : void

Provide autocompletion for this command's input

Parameters
Property Description
$input
Symfony\Component\Console\Completion\CompletionInput
$suggestions
Symfony\Component\Console\Completion\CompletionSuggestions
Returns
void

public error (string $string, int | string | null $verbosity = null) : void

Inherited from Command

Write a string as error output.

Parameters
Property Description
$string
string
$verbosity
int | string | null
Returns
void

public getSubscribedSignals () : array

Inherited from HandlesCleanup

Returns the process signals this command listens to

Returns
array

public handleSignal (integer $signal) : integer | false

Inherited from HandlesCleanup

Handle the provided Unix process signal

Parameters
Property Description
$signal
integer
Returns
integer | false

public handleWindowsSignal (integer $event) : void

Inherited from HandlesCleanup

Handle the provided Windows process singal.

Parameters
Property Description
$event
integer
Returns
void
Copyright © 2024 Winter CMS