2 namespace TYPO3\CMS\Backend\Console;
66 $this->
boot($commandLineName);
68 if (is_callable($commandLineScript)) {
69 call_user_func($commandLineScript);
72 include($commandLineScript);
74 }
catch (\InvalidArgumentException $e) {
75 $output->writeln(
'<error>Oops, an error occurred: ' . $e->getMessage() .
'</error>');
77 $output->writeln(
'Valid keys are:');
79 $cliKeys = array_keys(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'GLOBAL'][
'cliKeys']);
81 foreach ($cliKeys as $key => $value) {
82 $output->writeln(
' ' . $value);
84 $exitCode = $e->getCode();
85 }
catch (\RuntimeException $e) {
86 $output->writeln(
'<error>Oops, an error occurred: ' . $e->getMessage() .
'</error>');
87 $exitCode = $e->getCode();
89 $output->writeln(
'<error>Oops, an error occurred: ' . $e->getMessage() .
'</error>');
90 $exitCode = $e->getCode();
101 protected function boot($commandLineName)
104 ->loadExtensionTables(
true)
105 ->initializeBackendUser();
111 ->initializeBackendAuthentication()
112 ->initializeLanguageObject();
130 if (empty($cliKey)) {
131 throw new \InvalidArgumentException(
'This script must have a command as first argument.', 1);
132 }
elseif (!is_array(
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'GLOBAL'][
'cliKeys'][$cliKey])) {
133 throw new \InvalidArgumentException(
'This supplied command is not valid.', 1);
147 list($commandLineScript, $commandLineName) =
$GLOBALS[
'TYPO3_CONF_VARS'][
'SC_OPTIONS'][
'GLOBAL'][
'cliKeys'][$cliKey];
148 if (!is_callable($commandLineScript)) {
151 define(
'TYPO3_cliKey', $cliKey);
152 define(
'TYPO3_cliInclude', $commandLineScript);
156 $GLOBALS[
'temp_cliScriptPath'] = array_shift($_SERVER[
'argv']);
157 $GLOBALS[
'temp_cliKey'] = array_shift($_SERVER[
'argv']);
158 array_unshift($_SERVER[
'argv'],
$GLOBALS[
'temp_cliScriptPath']);
159 return array($commandLineScript, $commandLineName);
170 if (
$GLOBALS[
'BE_USER']->user[
'uid']) {
171 throw new \RuntimeException(
'Another user was already loaded which is impossible in CLI mode!', 3);
174 throw new \RuntimeException(
'Module name, "' . $commandLineName .
'", was not prefixed with "_CLI_"', 3);
176 $userName = strtolower($commandLineName);
177 $GLOBALS[
'BE_USER']->setBeUserByName($userName);
178 if (!
$GLOBALS[
'BE_USER']->user[
'uid']) {
179 throw new \RuntimeException(
'No backend user named "' . $userName .
'" was found!', 3);
181 if (
$GLOBALS[
'BE_USER']->isAdmin()) {
182 throw new \RuntimeException(
'CLI backend user "' . $userName .
'" was ADMIN which is not allowed!', 3);