PHP 클래스 ZF\Console\Application

파일 보기 프로젝트 열기: zfcampus/zf-console 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$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.

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