PHP Class lithium\console\command\Create

li3 create --template=controller Posts li3 create --template=model Posts
Inheritance: extends lithium\console\Command
Exibir arquivo Open project: unionofrad/lithium Class Usage Examples

Public Properties

Property Type Description
$library string Name of library to use
$template string The name of the template to use to generate the file. This allows you to add a custom template to be used in place of the core template for each command. Place templates in \extensions\command\create\template.

Protected Properties

Property Type Description
$_library array Holds library data from lithium\core\Libraries::get().

Public Methods

Method Description
run ( string $command = null ) : boolean Run the create command. Takes $command and delegates to $command::$method

Protected Methods

Method Description
_default ( string $name ) : boolean Run through the default set. model, controller, test model, test controller
_execute ( string $command ) : boolean Execute the given sub-command for the current request.
_init ( ) : void Class initializer. Parses template and sets up params that need to be filled.
_instance ( string $name, array $config = [] ) : object Get an instance of a sub-command
_namespace ( string $request, array $options = [] ) : string Get the namespace.
_params ( ) : array Parse a template to find available variables specified in {:name} format. Each variable corresponds to a method in the sub command. For example, a {:namespace} variable will call the namespace method in the model command when li3 create model Post is called.
_save ( array $params = [] ) : string | boolean Save a template with the current params. Writes file to Create::$path.
_template ( ) : string Returns the contents of the template.

Method Details

_default() protected method

Run through the default set. model, controller, test model, test controller
protected _default ( string $name ) : boolean
$name string class name to create
return boolean

_execute() protected method

Execute the given sub-command for the current request.
protected _execute ( string $command ) : boolean
$command string The sub-command name. example: Model, Controller, Test
return boolean

_init() protected method

Class initializer. Parses template and sets up params that need to be filled.
protected _init ( ) : void
return void

_instance() protected method

Get an instance of a sub-command
protected _instance ( string $name, array $config = [] ) : object
$name string the name of the sub-command to instantiate
$config array
return object

_namespace() protected method

Get the namespace.
protected _namespace ( string $request, array $options = [] ) : string
$request string
$options array
return string

_params() protected method

Parse a template to find available variables specified in {:name} format. Each variable corresponds to a method in the sub command. For example, a {:namespace} variable will call the namespace method in the model command when li3 create model Post is called.
protected _params ( ) : array
return array

_save() protected method

Save a template with the current params. Writes file to Create::$path.
protected _save ( array $params = [] ) : string | boolean
$params array
return string | boolean A result string on success of writing the file. If any errors occur along the way such as missing information boolean false is returned.

_template() protected method

Returns the contents of the template.
protected _template ( ) : string
return string

run() public method

Run the create command. Takes $command and delegates to $command::$method
public run ( string $command = null ) : boolean
$command string
return boolean

Property Details

$_library protected_oe property

Holds library data from lithium\core\Libraries::get().
protected array $_library
return array

$library public_oe property

Name of library to use
public string $library
return string

$template public_oe property

The name of the template to use to generate the file. This allows you to add a custom template to be used in place of the core template for each command. Place templates in \extensions\command\create\template.
public string $template
return string