AnnotatedCommandFactory
class AnnotatedCommandFactory implements AutomaticOptionsProviderInterface (View source)
The AnnotatedCommandFactory creates commands for your application.
Use with a Dependency Injection Container and the CommandFactory. Alternately, use the CommandFileDiscovery to find commandfiles, and then use AnnotatedCommandFactory::createCommandsFromClass() to create commands. See the README for more information.
Properties
static protected | $ignoreCommandsInTraits | var bool |
|
static protected | $ignoreCommandsInParentClasses | var bool |
|
protected | $commandProcessor | var CommandProcessor |
|
protected | $listeners | var CommandCreationListenerInterface[] |
|
protected | $automaticOptionsProviderList | var AutomaticOptionsProvider[] |
|
protected | $includeAllPublicMethods | var boolean |
|
protected | $commandInfoAlterers | var CommandInfoAltererInterface |
|
protected | $dataStore | var SimpleCacheInterface |
|
protected | $ignoredCommandsRegexps | var string[] |
Methods
Typically, traits should not contain commands; however, some applications make use of this feature to package commands in libraries, so we must allow command files in traits to maintain backwards compatibility. Call this method to skip the parsing of trait files for a performance boost.
Typically, commands should not be inherited from parent classes; however, some applications make use of this feature to package commands in libraries, so we must allow command files in traits to maintain backwards compatibility. Call this method to skip the parsing of trait files for a performance boost.
No description
No description
Set the 'include all public methods flag'. If true (the default), then every public method of each commandFile will be used to create commands.
No description
No description
Add a listener that is notified immediately before the command factory creates commands from a commandFile instance. This listener can use this opportunity to do more setup for the commandFile, and so on.
Add a listener that's just a simple 'callable'.
Add a regular expresion used to match methods names that will not be part of the final set of commands.
Call all command creation listeners
n.b. This registers all hooks from the commandfile instance as a side-effect.
No description
No description
Get the command info list from the cache
Check to see if this factory has a cache datastore.
Set a cache datastore for this factory. Any object with 'set' and 'get' methods is acceptable. The key is the classname being cached, and the value is a nested associative array of strings.
Get the data store attached to this factory.
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
No description
Register a command hook given the CommandInfo for a method.
No description
Give plugins an opportunity to update the commandInfo
Get the options that are implied by annotations, e.g.
Details
static
setIgnoreCommandsInTraits(bool $skipTraitFiles)
Typically, traits should not contain commands; however, some applications make use of this feature to package commands in libraries, so we must allow command files in traits to maintain backwards compatibility. Call this method to skip the parsing of trait files for a performance boost.
In future versions, this property be removed, and commands will not be parsed from traits. Use Robo plugins as the preferred method of distributing shared commands.
static
setIgnoreCommandsInParentClasses(bool $ignoreCommandsInParentClasses)
Typically, commands should not be inherited from parent classes; however, some applications make use of this feature to package commands in libraries, so we must allow command files in traits to maintain backwards compatibility. Call this method to skip the parsing of trait files for a performance boost.
In future versions, this property be removed, and commands will not be parsed from traits. Use Robo plugins as the preferred method of distributing shared commands.
__construct()
No description
setCommandProcessor(CommandProcessor $commandProcessor)
No description
CommandProcessor
commandProcessor()
No description
setIncludeAllPublicMethods($includeAllPublicMethods)
Set the 'include all public methods flag'. If true (the default), then every public method of each commandFile will be used to create commands.
If it is false, then only those public methods annotated with @command or @name (deprecated) will be used to create commands.
getIncludeAllPublicMethods()
No description
HookManager
hookManager()
No description
addListener(CommandCreationListenerInterface $listener)
Add a listener that is notified immediately before the command factory creates commands from a commandFile instance. This listener can use this opportunity to do more setup for the commandFile, and so on.
addListernerCallback(callable $listener)
Add a listener that's just a simple 'callable'.
addIgnoredCommandsRegexp(string $regex)
Add a regular expresion used to match methods names that will not be part of the final set of commands.
protected
notify(object $commandFileInstance)
Call all command creation listeners
addAutomaticOptionProvider(AutomaticOptionsProviderInterface $optionsProvider)
No description
addCommandInfoAlterer(CommandInfoAltererInterface $alterer)
No description
createCommandsFromClass($commandFileInstance, $includeAllPublicMethods = null)
n.b. This registers all hooks from the commandfile instance as a side-effect.
getCommandInfoListFromClass($commandFileInstance)
No description
protected
storeCommandInfoListInCache($commandFileInstance, $commandInfoList)
No description
protected array
getCommandInfoListFromCache(mixed $commandFileInstance)
Get the command info list from the cache
bool
hasDataStore()
Check to see if this factory has a cache datastore.
type
setDataStore(mixed $dataStore)
Set a cache datastore for this factory. Any object with 'set' and 'get' methods is acceptable. The key is the classname being cached, and the value is a nested associative array of strings.
TODO: Typehint this to SimpleCacheInterface
This is not done currently to allow clients to use a generic cache store that does not itself depend on the annotated-command library.
getDataStore()
Get the data store attached to this factory.
protected
createCommandInfoListFromClass($commandFileInstance, $cachedCommandInfoList)
No description
createCommandInfo($commandFileInstance, $commandMethodName)
No description
createCommandsFromClassInfo($commandInfoList, $commandFileInstance, $includeAllPublicMethods = null)
No description
createSelectedCommandsFromClassInfo($commandInfoList, $commandFileInstance, callable $commandSelector)
No description
protected
isMethodRecognizedAsCommand($commandInfo, $includeAllPublicMethods)
No description
protected
isMethodRecognizedAsHook($commandInfo)
No description
protected
filterCommandInfoList($commandInfoList, callable $commandSelector)
No description
static
isCommandOrHookMethod($commandInfo, $includeAllPublicMethods)
No description
static
isHookMethod($commandInfo)
No description
static
isCommandMethod($commandInfo, $includeAllPublicMethods)
No description
registerCommandHooksFromClassInfo($commandInfoList, $commandFileInstance)
No description
registerCommandHook(CommandInfo $commandInfo, object $commandFileInstance)
Register a command hook given the CommandInfo for a method.
The hook format is:
protected
getNthWord($string, $n, $default = '', $delimiter = ' ')
No description
createCommand(CommandInfo $commandInfo, $commandFileInstance)
No description
alterCommandInfo(CommandInfo $commandInfo, $commandFileInstance)
Give plugins an opportunity to update the commandInfo
InputOption[]
callAutomaticOptionsProviders(CommandInfo $commandInfo)
Get the options that are implied by annotations, e.g.
@fields implies that there should be a --fields and a --format option.
InputOption[]
automaticOptions(CommandInfo $commandInfo)
Get the options that are implied by annotations, e.g.
@fields implies that there should be a --fields and a --format option.