PHP Класс ZF\Console\Application

Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$banner null | string | callable
$bannerDisabledForUserCommands boolean
$console Zend\Console\Adapter\AdapterInterface
$debug boolean Flag to specify if the application is in debug mode
$dispatcher ZF\Console\DispatcherInterface
$exceptionHandler callable
$footer null | string | callable
$name string
$routeCollection ZF\Console\RouteCollection
$version string

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

Метод Описание
__construct ( string $name, string $version, array | Traversabl\Traversable $routes, Zend\Console\Adapter\AdapterInterface $console = null, ZF\Console\DispatcherInterface $dispatcher = null ) Initialize the application
getDispatcher ( ) : ZF\Console\DispatcherInterface
getExceptionHandler ( ) : callable Gets the registered exception handler
isBannerDisabledForUserCommands ( ) : boolean Whether or not to disable the banner in user commands. False by default.
removeRoute ( String $name ) : self Remove a route by name
run ( array $args = null ) : integer Run the application
setBanner ( null | string | callable $bannerOrCallable ) : self Set the banner to display.
setBannerDisabledForUserCommands ( boolean $flag = true ) : self Disables the banner for user commands. Still shows it before usage messages.
setDebug ( boolean $flag ) Sets the debug flag of the application
setExceptionHandler ( callable $handler ) : self Sets exception handler to use the expection Message
setFooter ( null | string | callable $footerOrCallable ) : self Set the footer to display.
showMessage ( string | callable $messageOrCallable ) Display a message (banner or footer)
showUsageMessage ( null | string $name = null ) Displays a usage message for the router
showVersion ( Zend\Console\Adapter\AdapterInterface $console ) : integer Display the application version

Защищенные методы

Метод Описание
calcMaxString ( array $data = [] ) : integer Calculate the maximum string length for an array
initializeExceptionHandler ( ) Initialize the exception handler (if not in debug mode)
mapRouteHandler ( array $route ) Map a route handler
processRun ( array $args ) : integer Process run If the argument list is empty, displays a usage message.
setProcessTitle ( ) Set CLI process title (PHP versions >= 5.5)
setRoutes ( array | Traversabl\Traversable $routes ) : self Set routes to use
setupAutocompleteCommand ( ZF\Console\RouteCollection $routeCollection, ZF\Console\DispatcherInterface $dispatcher ) Sets up the default autocomplete command
setupHelpCommand ( ZF\Console\RouteCollection $routeCollection, ZF\Console\DispatcherInterface $dispatcher ) Sets up the default help command
setupVersionCommand ( ZF\Console\RouteCollection $routeCollection, ZF\Console\DispatcherInterface $dispatcher ) Sets up the default version command
showUnmatchedRouteMessage ( array $args ) Show message indicating inability to match a route.
showUnrecognizedRouteMessage ( string $name ) Display an error message indicating a route name was not recognized
showUsageMessageForRoute ( Route $route, $log = false ) Display the usage message for an individual route
validateMessage ( mixed $stringOrCallable )

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

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

Creates a RouteCollection and populates it with the $routes provided. Sets the banner to call showVersion(). If no help command is defined, defines one. If no version command is defined, defines one.
public __construct ( string $name, string $version, array | Traversabl\Traversable $routes, Zend\Console\Adapter\AdapterInterface $console = null, ZF\Console\DispatcherInterface $dispatcher = null )
$name string Application name
$version string Application version
$routes array | Traversabl\Traversable Routes/route specifications to use for the application
$console Zend\Console\Adapter\AdapterInterface Console adapter to use within the application
$dispatcher ZF\Console\DispatcherInterface Configured dispatcher mapping routes to callables

calcMaxString() защищенный Метод

Calculate the maximum string length for an array
protected calcMaxString ( array $data = [] ) : integer
$data array
Результат integer

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

public getDispatcher ( ) : ZF\Console\DispatcherInterface
Результат ZF\Console\DispatcherInterface

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

Lazy-instantiates an ExceptionHandler instance with the current console instance if no handler has been specified.
public getExceptionHandler ( ) : callable
Результат callable

initializeExceptionHandler() защищенный Метод

Initialize the exception handler (if not in debug mode)

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

Whether or not to disable the banner in user commands. False by default.
public isBannerDisabledForUserCommands ( ) : boolean
Результат boolean

mapRouteHandler() защищенный Метод

If a given route specification has a "handler" entry, and the dispatcher does not currently have a handler for that command, map it.
protected mapRouteHandler ( array $route )
$route array

processRun() защищенный Метод

If arguments are provided, but no routes match, displays a usage message and returns a status of 1. Otherwise, attempts to dispatch the matched command, returning the execution status.
protected processRun ( array $args ) : integer
$args array
Результат integer

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

Remove a route by name
public removeRoute ( String $name ) : self
$name String
Результат self

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

If no arguments are provided, pulls them from $argv, stripping the script argument first. If the argument list is empty, displays a usage message. If arguments are provided, but no routes match, displays a usage message and returns a status of 1. Otherwise, attempts to dispatch the matched command, returning the execution status.
public run ( array $args = null ) : integer
$args array
Результат integer

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

Used whenever the application is called without arguments. If the default help implementation is used, also displayed with help messages.
public setBanner ( null | string | callable $bannerOrCallable ) : self
$bannerOrCallable null | string | callable
Результат self

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

Disables the banner for user commands. Still shows it before usage messages.
public setBannerDisabledForUserCommands ( boolean $flag = true ) : self
$flag boolean
Результат self

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

Sets the debug flag of the application
public setDebug ( boolean $flag )
$flag boolean

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

Sets exception handler to use the expection Message
public setExceptionHandler ( callable $handler ) : self
$handler callable
Результат self

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

Used whenever the application is called without arguments. If the default help implementation is used, also displayed with help messages.
public setFooter ( null | string | callable $footerOrCallable ) : self
$footerOrCallable null | string | callable
Результат self

setProcessTitle() защищенный Метод

Set CLI process title (PHP versions >= 5.5)
protected setProcessTitle ( )

setRoutes() защищенный Метод

Allows specifying an array of routes, which may be mixed Route instances or array specifications for creating routes.
protected setRoutes ( array | Traversabl\Traversable $routes ) : self
$routes array | Traversabl\Traversable
Результат self

setupAutocompleteCommand() защищенный Метод

Creates the route, and maps the command.
protected setupAutocompleteCommand ( ZF\Console\RouteCollection $routeCollection, ZF\Console\DispatcherInterface $dispatcher )
$routeCollection ZF\Console\RouteCollection
$dispatcher ZF\Console\DispatcherInterface

setupHelpCommand() защищенный Метод

Creates the route, and maps the command.
protected setupHelpCommand ( ZF\Console\RouteCollection $routeCollection, ZF\Console\DispatcherInterface $dispatcher )
$routeCollection ZF\Console\RouteCollection
$dispatcher ZF\Console\DispatcherInterface

setupVersionCommand() защищенный Метод

Creates the route, and maps the command.
protected setupVersionCommand ( ZF\Console\RouteCollection $routeCollection, ZF\Console\DispatcherInterface $dispatcher )
$routeCollection ZF\Console\RouteCollection
$dispatcher ZF\Console\DispatcherInterface

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

If the message is a string and not callable, uses the composed console instance to render it. If the message is a callable, calls it with the composed console instance as an argument.
public showMessage ( string | callable $messageOrCallable )
$messageOrCallable string | callable

showUnmatchedRouteMessage() защищенный Метод

Show message indicating inability to match a route.
protected showUnmatchedRouteMessage ( array $args )
$args array

showUnrecognizedRouteMessage() защищенный Метод

Display an error message indicating a route name was not recognized
protected showUnrecognizedRouteMessage ( string $name )
$name string

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

If a route name is provided, usage for that route only will be displayed; otherwise, the name/short description for each will be present.
public showUsageMessage ( null | string $name = null )
$name null | string

showUsageMessageForRoute() защищенный Метод

Display the usage message for an individual route
protected showUsageMessageForRoute ( Route $route, $log = false )
$route Route

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

Display the application version
public showVersion ( Zend\Console\Adapter\AdapterInterface $console ) : integer
$console Zend\Console\Adapter\AdapterInterface
Результат integer

validateMessage() защищенный Метод

protected validateMessage ( mixed $stringOrCallable )
$stringOrCallable mixed

Описание свойств

$banner защищенное свойство

protected null|string|callable $banner
Результат null | string | callable

$bannerDisabledForUserCommands защищенное свойство

protected bool $bannerDisabledForUserCommands
Результат boolean

$console защищенное свойство

protected AdapterInterface,Zend\Console\Adapter $console
Результат Zend\Console\Adapter\AdapterInterface

$debug защищенное свойство

Flag to specify if the application is in debug mode
protected bool $debug
Результат boolean

$dispatcher защищенное свойство

protected DispatcherInterface,ZF\Console $dispatcher
Результат ZF\Console\DispatcherInterface

$exceptionHandler защищенное свойство

protected callable $exceptionHandler
Результат callable

$name защищенное свойство

protected string $name
Результат string

$routeCollection защищенное свойство

protected RouteCollection,ZF\Console $routeCollection
Результат ZF\Console\RouteCollection

$version защищенное свойство

protected string $version
Результат string