TYPO3  7.6
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
CliRequestHandler Class Reference
Inheritance diagram for CliRequestHandler:
RequestHandlerInterface

Public Member Functions

 __construct (Bootstrap $bootstrap)
 
 handleRequest (InputInterface $input)
 
 canHandleRequest (InputInterface $input)
 
 getPriority ()
 

Protected Member Functions

 boot ($commandLineName)
 
 validateCommandLineKeyFromInput (InputInterface $input)
 
 getIncludeScriptByCommandLineKey ($cliKey)
 
 loadCommandLineBackendUser ($commandLineName)
 

Protected Attributes

 $bootstrap
 

Detailed Description

Command Line Interface Request Handler dealing with "cliKey"-based Commands from the cli_dispatch.phpsh script. Picks up requests only when coming from the CLI mode. Resolves the "cliKey" which is registered inside $TYPO3_CONF_VARS[SC_OPTIONS][GLOBAL][cliKeys] and includes the CLI-based script or exits if no valid "cliKey" is found. Also logs into the system as a backend user which needs to be added to the database called _CLI_mymodule

Definition at line 31 of file CliRequestHandler.php.

Constructor & Destructor Documentation

__construct ( Bootstrap  $bootstrap)

Constructor handing over the bootstrap

Parameters
Bootstrap$bootstrap

Definition at line 44 of file CliRequestHandler.php.

References CliRequestHandler\$bootstrap.

Member Function Documentation

boot (   $commandLineName)
protected

Execute TYPO3 bootstrap

Exceptions
\RuntimeExceptionwhen the CLI user cannot be authenticated properly

Definition at line 101 of file CliRequestHandler.php.

References GeneralUtility\flushOutputBuffers(), and CliRequestHandler\loadCommandLineBackendUser().

Referenced by CliRequestHandler\handleRequest().

canHandleRequest ( InputInterface  $input)

This request handler can handle any CLI request.

Parameters
InputInterface$input
Returns
bool Always TRUE

Implements RequestHandlerInterface.

Definition at line 192 of file CliRequestHandler.php.

getIncludeScriptByCommandLineKey (   $cliKey)
protected

Define cli-related parameters and return the include script as well as the command line name. Used for authentication against the backend user in the "laodCommandLineBackendUser()" action.

Parameters
string$cliKeythe CLI key
Returns
string the absolute path to the include script

Definition at line 145 of file CliRequestHandler.php.

References $GLOBALS, and GeneralUtility\getFileAbsFileName().

Referenced by CliRequestHandler\handleRequest().

getPriority ( )

Returns the priority - how eager the handler is to actually handle the request.

Returns
int The priority of the request handler.

Implements RequestHandlerInterface.

Definition at line 202 of file CliRequestHandler.php.

handleRequest ( InputInterface  $input)

Handles any commandline request

Parameters
InputInterface$input
Returns
void

Implements RequestHandlerInterface.

Definition at line 55 of file CliRequestHandler.php.

References $GLOBALS, CliRequestHandler\boot(), CliRequestHandler\getIncludeScriptByCommandLineKey(), GeneralUtility\makeInstance(), and CliRequestHandler\validateCommandLineKeyFromInput().

loadCommandLineBackendUser (   $commandLineName)
protected

If the backend script is in CLI mode, it will try to load a backend user named by the CLI module name (in lowercase)

Parameters
string$commandLineNamethe name of the module registered inside $TYPO3_CONF_VARS[SC_OPTIONS][GLOBAL][cliKeys] as second parameter
Exceptions
\RuntimeExceptionif a non-admin Backend user could not be loaded

Definition at line 168 of file CliRequestHandler.php.

References $GLOBALS, and StringUtility\beginsWith().

Referenced by CliRequestHandler\boot().

validateCommandLineKeyFromInput ( InputInterface  $input)
protected

Check CLI parameters. First argument is a key that points to the script configuration. If it is not set or not valid, the script exits with an error message.

Parameters
InputInterface$inputan instance of the input given to the CLI call
Returns
string the CLI key in use
Exceptions
\InvalidArgumentException

Definition at line 127 of file CliRequestHandler.php.

References $GLOBALS, elseif, and InputInterface\getFirstArgument().

Referenced by CliRequestHandler\handleRequest().

Member Data Documentation

$bootstrap
protected

Definition at line 37 of file CliRequestHandler.php.

Referenced by CliRequestHandler\__construct().