PHP Класс Silly\Application

Автор: Matthieu Napoli ([email protected])
Наследование: extends Symfony\Component\Console\Application
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__construct ( $name = 'UNKNOWN', $version = 'UNKNOWN' )
command ( string $expression, callable | string | array $callable, array $aliases = [] ) : Command Define a CLI command using a string expression and a callable.
getContainer ( ) : Interop\Container\ContainerInterface | null Returns the container that has been configured, or null.
getInvoker ( ) : Invoker\InvokerInterface
runCommand ( string $command, Symfony\Component\Console\Output\OutputInterface $output = null ) : integer Helper to run a sub-command from a command.
setInvoker ( Invoker\InvokerInterface $invoker )
useContainer ( Interop\Container\ContainerInterface $container, boolean $injectByTypeHint = false, boolean $injectByParameterName = false ) Set up the application to use a container to resolve callables.

Приватные методы

Метод Описание
assertCallableIsValid ( $callable )
createCommand ( $expression, callable $callable )
createParameterResolver ( ) : ParameterResolver Create the default parameter resolver.
defaultsViaReflection ( $command, $callable )
isStaticCallToNonStaticMethod ( mixed $callable ) : boolean Check if the callable represents a static call to a non-static method.

Описание методов

__construct() публичный Метод

public __construct ( $name = 'UNKNOWN', $version = 'UNKNOWN' )

command() публичный Метод

Define a CLI command using a string expression and a callable.
public command ( string $expression, callable | string | array $callable, array $aliases = [] ) : Command
$expression string Defines the arguments and options of the command.
$callable callable | string | array Called when the command is called. When using a container, this can be a "pseudo-callable" i.e. the name of the container entry to invoke.
$aliases array An array of aliases for the command.
Результат Silly\Command\Command

getContainer() публичный Метод

Returns the container that has been configured, or null.
public getContainer ( ) : Interop\Container\ContainerInterface | null
Результат Interop\Container\ContainerInterface | null

getInvoker() публичный Метод

public getInvoker ( ) : Invoker\InvokerInterface
Результат Invoker\InvokerInterface

runCommand() публичный Метод

Helper to run a sub-command from a command.
public runCommand ( string $command, Symfony\Component\Console\Output\OutputInterface $output = null ) : integer
$command string Command that should be run.
$output Symfony\Component\Console\Output\OutputInterface The output to use. If not provided, the output will be silenced.
Результат integer 0 if everything went fine, or an error code

setInvoker() публичный Метод

public setInvoker ( Invoker\InvokerInterface $invoker )
$invoker Invoker\InvokerInterface

useContainer() публичный Метод

Only commands that are *not* PHP callables will be fetched from the container. Commands that are PHP callables are not affected (which is what we want). *Optionally*, you can also enable dependency injection in the callable parameters: $application->command('greet', function (Psr\Log\LoggerInterface $logger) { $logger->info('I am greeting'); }); Set $injectByTypeHint to true to make Silly fetch container entries by their type-hint, i.e. call $container->get('Psr\Log\LoggerInterface'). Set $injectByParameterName to true to make Silly fetch container entries by the parameter name, i.e. call $container->get('logger'). If you set both to true, it will first look using the type-hint, then using the parameter name. In case of conflict with a command parameters, the command parameter is injected in priority over dependency injection.
public useContainer ( Interop\Container\ContainerInterface $container, boolean $injectByTypeHint = false, boolean $injectByParameterName = false )
$container Interop\Container\ContainerInterface Container implementing container-interop
$injectByTypeHint boolean
$injectByParameterName boolean