PluginAssetsRemoveCommand
extends Command
in package
uses
PluginAssetsTrait
Command for removing plugin assets from app's webroot.
Tags
Table of Contents
Properties
- $_modelFactories : array<string|int, callable|LocatorInterface>
- A list of overridden model factory functions.
- $_modelType : string
- The model type to use.
- $_tableLocator : LocatorInterface|null
- Table locator instance
- $defaultTable : string|null
- This object's default table alias.
- $modelClass : string|null
- This object's primary model class name. Should be a plural form.
- $name : string
- The name of this command.
Methods
- __construct() : mixed
- Constructor
- abort() : void
- Halt the the current process with a StopException.
- buildOptionParser() : ConsoleOptionParser
- Get the option parser.
- defaultName() : string
- Get the command name.
- execute() : int|null
- Execute the command
- executeCommand() : int|null
- Execute another command with the provided set of arguments.
- fetchTable() : Table
- Convenience method to get a table instance.
- getDescription() : string
- Get the command description.
- getModelType() : string
- Get the model type to be used by this class
- getName() : string
- Get the command name.
- getOptionParser() : ConsoleOptionParser
- Get the option parser.
- getRootName() : string
- Get the root command name.
- getTableLocator() : LocatorInterface
- Gets the table locator.
- initialize() : void
- Hook method invoked by CakePHP when a command is about to be executed.
- loadModel() : RepositoryInterface
- Loads and constructs repository objects required by this object
- log() : bool
- Convenience method to write a message to Log. See Log::write() for more information on writing to logs.
- modelFactory() : void
- Override a existing callable to generate repositories of a given type.
- run() : int|null
- Run the command.
- setModelType() : $this
- Set the model type to be used by this class
- setName() : $this
- Set the name this command uses in the collection.
- setTableLocator() : $this
- Sets the table locator.
- _setModelClass() : void
- Set the modelClass property based on conventions.
- displayHelp() : void
- Output help content
- setOutputLevel() : void
- Set the output level based on the Arguments.
Properties
$_modelFactories
A list of overridden model factory functions.
protected
array<string|int, callable|LocatorInterface>
$_modelFactories
= []
$_modelType
The model type to use.
protected
string
$_modelType
= 'Table'
$_tableLocator
Table locator instance
protected
LocatorInterface|null
$_tableLocator
$defaultTable
This object's default table alias.
protected
string|null
$defaultTable
= null
$modelClass
This object's primary model class name. Should be a plural form.
Use Cake\ORM\Locator\LocatorAwareTrait::$defaultTable
instead.
protected
string|null
$modelClass
CakePHP will not inflect the name.
Example: For an object named 'Comments', the modelClass would be 'Comments'.
Plugin classes should use Plugin.Comments
style names to correctly load
models from the correct plugin.
Use empty string to not use auto-loading on this object. Null auto-detects based on controller name.
$name
The name of this command.
protected
string
$name
= 'cake unknown'
Methods
__construct()
Constructor
public
__construct() : mixed
By default CakePHP will construct command objects when building the CommandCollection for your application.
abort()
Halt the the current process with a StopException.
public
abort([int $code = self::CODE_ERROR ]) : void
Parameters
- $code : int = self::CODE_ERROR
-
The exit code to use.
Tags
buildOptionParser()
Get the option parser.
public
buildOptionParser(ConsoleOptionParser $parser) : ConsoleOptionParser
Parameters
- $parser : ConsoleOptionParser
-
The option parser to update
Return values
ConsoleOptionParserdefaultName()
Get the command name.
public
static defaultName() : string
Tags
Return values
stringexecute()
Execute the command
public
execute(Arguments $args, ConsoleIo $io) : int|null
Remove plugin assets from app's webroot.
Parameters
Return values
int|null —The exit code or null for success
executeCommand()
Execute another command with the provided set of arguments.
public
executeCommand(CommandInterface|string $command[, array<string|int, mixed> $args = [] ][, ConsoleIo|null $io = null ]) : int|null
If you are using a string command name, that command's dependencies will not be resolved with the application container. Instead you will need to pass the command as an object with all of its dependencies.
Parameters
- $command : CommandInterface|string
-
The command class name or command instance.
- $args : array<string|int, mixed> = []
-
The arguments to invoke the command with.
- $io : ConsoleIo|null = null
-
The ConsoleIo instance to use for the executed command.
Return values
int|null —The exit code or null for success of the command.
fetchTable()
Convenience method to get a table instance.
public
fetchTable([string|null $alias = null ][, array<string, mixed> $options = [] ]) : Table
Parameters
- $alias : string|null = null
-
The alias name you want to get. Should be in CamelCase format. If
null
then the value of $defaultTable property is used. - $options : array<string, mixed> = []
-
The options you want to build the table with. If a table has already been loaded the registry options will be ignored.
Tags
Return values
TablegetDescription()
Get the command description.
public
static getDescription() : string
Return values
stringgetModelType()
Get the model type to be used by this class
public
getModelType() : string
Return values
stringgetName()
Get the command name.
public
getName() : string
Return values
stringgetOptionParser()
Get the option parser.
public
getOptionParser() : ConsoleOptionParser
You can override buildOptionParser() to define your options & arguments.
Tags
Return values
ConsoleOptionParsergetRootName()
Get the root command name.
public
getRootName() : string
Return values
stringgetTableLocator()
Gets the table locator.
public
getTableLocator() : LocatorInterface
Return values
LocatorInterfaceinitialize()
Hook method invoked by CakePHP when a command is about to be executed.
public
initialize() : void
Override this method and implement expensive/important setup steps that should not run on every command run. This method will be called before the options and arguments are validated and processed.
loadModel()
Loads and constructs repository objects required by this object
public
loadModel([string|null $modelClass = null ][, string|null $modelType = null ]) : RepositoryInterface
Use LocatorAwareTrait::fetchTable()
instead.
Typically used to load ORM Table objects as required. Can also be used to load other types of repository objects your application uses.
If a repository provider does not return an object a MissingModelException will be thrown.
Parameters
- $modelClass : string|null = null
-
Name of model class to load. Defaults to $this->modelClass. The name can be an alias like
'Post'
or FQCN likeApp\Model\Table\PostsTable::class
. - $modelType : string|null = null
-
The type of repository to load. Defaults to the getModelType() value.
Tags
Return values
RepositoryInterface —The model instance created.
log()
Convenience method to write a message to Log. See Log::write() for more information on writing to logs.
public
log(string $message[, string|int $level = LogLevel::ERROR ][, array<string|int, mixed>|string $context = [] ]) : bool
Parameters
- $message : string
-
Log message.
- $level : string|int = LogLevel::ERROR
-
Error level.
- $context : array<string|int, mixed>|string = []
-
Additional log data relevant to this message.
Return values
bool —Success of log write.
modelFactory()
Override a existing callable to generate repositories of a given type.
public
modelFactory(string $type, LocatorInterface|callable $factory) : void
Parameters
- $type : string
-
The name of the repository type the factory function is for.
- $factory : LocatorInterface|callable
-
The factory function used to create instances.
run()
Run the command.
public
run(array<string|int, mixed> $argv, ConsoleIo $io) : int|null
Parameters
- $argv : array<string|int, mixed>
-
Arguments from the CLI environment.
- $io : ConsoleIo
-
The console io
Tags
Return values
int|null —Exit code or null for success.
setModelType()
Set the model type to be used by this class
public
setModelType(string $modelType) : $this
Parameters
- $modelType : string
-
The model type
Return values
$thissetName()
Set the name this command uses in the collection.
public
setName(string $name) : $this
Parameters
- $name : string
-
The name the command uses in the collection.
Tags
Return values
$thissetTableLocator()
Sets the table locator.
public
setTableLocator(LocatorInterface $tableLocator) : $this
Parameters
- $tableLocator : LocatorInterface
-
LocatorInterface instance.
Return values
$this_setModelClass()
Set the modelClass property based on conventions.
protected
_setModelClass(string $name) : void
If the property is already set it will not be overwritten
Parameters
- $name : string
-
Class name.
displayHelp()
Output help content
protected
displayHelp(ConsoleOptionParser $parser, Arguments $args, ConsoleIo $io) : void
Parameters
- $parser : ConsoleOptionParser
-
The option parser.
- $args : Arguments
-
The command arguments.
- $io : ConsoleIo
-
The console io
setOutputLevel()
Set the output level based on the Arguments.
protected
setOutputLevel(Arguments $args, ConsoleIo $io) : void