‪TYPO3CMS  11.5
LockBackendCommand.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
18 use Symfony\Component\Console\Command\Command;
19 use Symfony\Component\Console\Input\InputArgument;
20 use Symfony\Component\Console\Input\InputInterface;
21 use Symfony\Component\Console\Output\OutputInterface;
22 use Symfony\Component\Console\Style\SymfonyStyle;
25 
29 class ‪LockBackendCommand extends Command
30 {
34  protected function ‪configure()
35  {
36  $this
37  ->addArgument(
38  'redirect',
39  InputArgument::OPTIONAL,
40  'If set, then the TYPO3 Backend will redirect to the locking state (only used when locking the TYPO3 Backend'
41  );
42  }
43 
51  protected function ‪execute(InputInterface $input, OutputInterface ‪$output)
52  {
53  $io = new SymfonyStyle($input, ‪$output);
54  $io->title($this->getDescription());
55  $lockFile = $this->‪getLockFileName();
56  if (@is_file($lockFile)) {
57  $io->note('A lock file already exists. Overwriting it.');
58  }
59  ‪$output = 'Wrote lock file to "' . $lockFile . '"';
60  if ($input->getArgument('redirect')) {
61  $lockFileContent = $input->getArgument('redirect');
62  $lockFileContent = is_string($lockFileContent) ? $lockFileContent : '';
63  ‪$output .= LF . 'with content "' . $lockFileContent . '".';
64  } else {
65  $lockFileContent = '';
66  ‪$output .= '.';
67  }
68  ‪GeneralUtility::writeFile($lockFile, $lockFileContent);
69  $io->success(‪$output);
70  return 0;
71  }
72 
78  protected function ‪getLockFileName()
79  {
80  return ‪Environment::getLegacyConfigPath() . '/LOCK_BACKEND';
81  }
82 }
‪TYPO3\CMS\Backend\Command\LockBackendCommand\configure
‪configure()
Definition: LockBackendCommand.php:34
‪TYPO3\CMS\Backend\Command\LockBackendCommand
Definition: LockBackendCommand.php:30
‪TYPO3\CMS\Backend\Command
Definition: LockBackendCommand.php:16
‪$output
‪$output
Definition: annotationChecker.php:121
‪TYPO3\CMS\Backend\Command\LockBackendCommand\getLockFileName
‪string getLockFileName()
Definition: LockBackendCommand.php:78
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:43
‪TYPO3\CMS\Backend\Command\LockBackendCommand\execute
‪int execute(InputInterface $input, OutputInterface $output)
Definition: LockBackendCommand.php:51
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Core\Utility\GeneralUtility\writeFile
‪static bool writeFile($file, $content, $changePermissions=false)
Definition: GeneralUtility.php:1722
‪TYPO3\CMS\Core\Core\Environment\getLegacyConfigPath
‪static string getLegacyConfigPath()
Definition: Environment.php:308