TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
CommandController Class Reference
Inheritance diagram for CommandController:
CommandControllerInterface ControllerInterface MockBCommandController Tx_Extbase_Command_MockCCommandController HelpCommandController MockACommandController ExtensionCommandController LanguageCommandController

Public Member Functions

 injectObjectManager (ObjectManagerInterface $objectManager)
 
 injectReflectionService (ReflectionService $reflectionService)
 
 canProcessRequest (\TYPO3\CMS\Extbase\Mvc\RequestInterface $request)
 
 processRequest (RequestInterface $request, ResponseInterface $response)
 
- Public Member Functions inherited from ControllerInterface
 processRequest (\TYPO3\CMS\Extbase\Mvc\RequestInterface $request,\TYPO3\CMS\Extbase\Mvc\ResponseInterface $response)
 

Protected Member Functions

 resolveCommandMethodName ()
 
 initializeCommandMethodArguments ()
 
 forward ($commandName, $controllerObjectName=null, array $arguments=[])
 
 ensureAdminRoleIfRequested ()
 
 restoreUserRole ($originalRole)
 
 output ($text, array $arguments=[])
 
 outputLine ($text= '', array $arguments=[])
 
 outputFormatted ($text= '', array $arguments=[], $leftPadding=0)
 
 quit ($exitCode=0)
 
 sendAndExit ($exitCode=0)
 
 getBackendUserAuthentication ()
 

Protected Attributes

 $request
 
 $response
 
 $arguments
 
 $commandMethodName = ''
 
 $requestAdminPermissions = false
 
 $reflectionService
 
 $objectManager
 
 $output
 

Detailed Description

A controller which processes requests from the command line

http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later

Definition at line 36 of file CommandController.php.

Member Function Documentation

canProcessRequest ( \TYPO3\CMS\Extbase\Mvc\RequestInterface  $request)

Checks if the current request type is supported by the controller.

Parameters
\TYPO3\CMS\Extbase\Mvc\RequestInterface$requestThe current request
Returns
bool TRUE if this request type is supported, otherwise FALSE

Implements ControllerInterface.

Definition at line 106 of file CommandController.php.

Referenced by CommandController\processRequest().

ensureAdminRoleIfRequested ( )
protected

Set admin permissions for currently authenticated user if requested and returns the original state or NULL

Returns
NULL|int

Definition at line 267 of file CommandController.php.

References CommandController\getBackendUserAuthentication().

forward (   $commandName,
  $controllerObjectName = null,
array  $arguments = [] 
)
protected

Forwards the request to another command and / or CommandController.

Request is directly transferred to the other command / controller without the need for a new request.

Parameters
string$commandName
string$controllerObjectName
array$arguments
Returns
void
Exceptions
StopActionException

Definition at line 222 of file CommandController.php.

References CommandController\$arguments.

getBackendUserAuthentication ( )
protected

Returns the global BackendUserAuthentication object.

Returns
BackendUserAuthentication|null

Definition at line 368 of file CommandController.php.

References $GLOBALS.

Referenced by CommandController\ensureAdminRoleIfRequested(), and CommandController\restoreUserRole().

initializeCommandMethodArguments ( )
protected

Initializes the arguments array of this controller by creating an empty argument object for each of the method arguments found in the designated command method.

Exceptions
TYPO3
Returns
void
Exceptions
InvalidArgumentTypeException

Definition at line 165 of file CommandController.php.

Referenced by CommandController\processRequest().

injectObjectManager ( ObjectManagerInterface  $objectManager)
Parameters
\TYPO3\CMS\Extbase\Object\ObjectManagerInterface$objectManager
Returns
void

Definition at line 87 of file CommandController.php.

References CommandController\$objectManager.

injectReflectionService ( ReflectionService  $reflectionService)
Parameters
\TYPO3\CMS\Extbase\Reflection\ReflectionService$reflectionService

Definition at line 95 of file CommandController.php.

References CommandController\$reflectionService.

output (   $text,
array  $arguments = [] 
)
protected

Outputs specified text to the console window You can specify arguments that will be passed to the text via sprintf

See also
http://www.php.net/sprintf
Parameters
string$textText to output
array$argumentsOptional arguments to use for sprintf
Returns
void

Definition at line 303 of file CommandController.php.

References CommandController\$arguments.

Referenced by HelpCommandController\displayHelpForCommand(), HelpCommandController\displayHelpIndex(), ExtensionCommandController\dumpClassLoadingInformationCommand(), CommandController\outputFormatted(), CommandController\outputLine(), and CommandController\processRequest().

outputFormatted (   $text = '',
array  $arguments = [],
  $leftPadding = 0 
)
protected

Formats the given text to fit into MAXIMUM_LINE_LENGTH and outputs it to the console window

Parameters
string$textText to output
array$argumentsOptional arguments to use for sprintf
int$leftPaddingThe number of spaces to use for indentation
Returns
void
See also
outputLine()

Definition at line 331 of file CommandController.php.

References CommandController\$arguments, and CommandController\output().

outputLine (   $text = '',
array  $arguments = [] 
)
protected

Outputs specified text to the console window and appends a line break

Parameters
string$textText to output
array$argumentsOptional arguments to use for sprintf
Returns
void
See also
output()

Definition at line 316 of file CommandController.php.

References CommandController\$arguments, and CommandController\output().

Referenced by HelpCommandController\displayHelpForCommand(), HelpCommandController\displayHelpIndex(), HelpCommandController\errorCommand(), HelpCommandController\helpCommand(), and HelpCommandController\helpStubCommand().

processRequest ( RequestInterface  $request,
ResponseInterface  $response 
)

Processes a command line request.

Parameters
RequestInterface$requestThe request object
ResponseInterface$responseThe response, modified by this handler
Returns
void
Exceptions
UnsupportedRequestTypeExceptionif the controller doesn't support the current request type

Definition at line 120 of file CommandController.php.

References CommandController\$request, CommandController\$response, CommandController\canProcessRequest(), CommandController\initializeCommandMethodArguments(), CommandController\output(), and CommandController\resolveCommandMethodName().

quit (   $exitCode = 0)
protected

Exits the CLI through the dispatcher An exit status code can be specified

See also
http://www.php.net/exit
Parameters
int$exitCodeExit code to return on exit
Exceptions
StopActionException
Returns
void

Definition at line 344 of file CommandController.php.

Referenced by ExtensionCommandController\dumpClassLoadingInformationCommand().

resolveCommandMethodName ( )
protected

Resolves and checks the current command method name

Note: The resulting command method name might not have the correct case, which isn't a problem because PHP is case insensitive regarding method names.

Exceptions
TYPO3
Returns
string Method name of the current command
Exceptions
NoSuchCommandException

Definition at line 148 of file CommandController.php.

References CommandController\$commandMethodName.

Referenced by CommandController\processRequest().

restoreUserRole (   $originalRole)
protected

Restores the original user role

Parameters
NULL | int$originalRole

Definition at line 285 of file CommandController.php.

References CommandController\getBackendUserAuthentication().

sendAndExit (   $exitCode = 0)
protected

Sends the response and exits the CLI without any further code execution Should be used for commands that flush code caches.

Parameters
int$exitCodeExit code to return on exit
Returns
void

Definition at line 357 of file CommandController.php.

Member Data Documentation

$commandMethodName = ''
protected

Definition at line 58 of file CommandController.php.

Referenced by CommandController\resolveCommandMethodName().

$objectManager
protected

Definition at line 76 of file CommandController.php.

Referenced by CommandController\injectObjectManager().

$output
protected

Definition at line 81 of file CommandController.php.

$reflectionService
protected

Definition at line 71 of file CommandController.php.

Referenced by CommandController\injectReflectionService().

$request
protected

Definition at line 41 of file CommandController.php.

Referenced by CommandController\processRequest().

$requestAdminPermissions = false
protected

Definition at line 66 of file CommandController.php.

$response
protected

Definition at line 46 of file CommandController.php.

Referenced by CommandController\processRequest().