[!!!][TASK] Remove POST option from typolink.addQueryString.method
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Command / LockBackendCommand.php
1 <?php
2 namespace TYPO3\CMS\Backend\Command;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16 use Symfony\Component\Console\Command\Command;
17 use Symfony\Component\Console\Input\InputArgument;
18 use Symfony\Component\Console\Input\InputInterface;
19 use Symfony\Component\Console\Output\OutputInterface;
20 use Symfony\Component\Console\Style\SymfonyStyle;
21 use TYPO3\CMS\Core\Core\Environment;
22 use TYPO3\CMS\Core\Utility\GeneralUtility;
23
24 /**
25 * Core function for locking the TYPO3 Backend
26 */
27 class LockBackendCommand extends Command
28 {
29 /**
30 * Configure the command by defining the name, options and arguments
31 */
32 protected function configure()
33 {
34 $this
35 ->setDescription('Lock the TYPO3 Backend')
36 ->addArgument(
37 'redirect',
38 InputArgument::OPTIONAL,
39 'If set, then the TYPO3 Backend will redirect to the locking state (only used when locking the TYPO3 Backend'
40 );
41 }
42
43 /**
44 * Executes the command for adding the lock file
45 *
46 * @param InputInterface $input
47 * @param OutputInterface $output
48 */
49 protected function execute(InputInterface $input, OutputInterface $output)
50 {
51 $io = new SymfonyStyle($input, $output);
52 $io->title($this->getDescription());
53 $lockFile = $this->getLockFileName();
54 if (@is_file($lockFile)) {
55 $io->note('A lock file already exists. Overwriting it.');
56 }
57 $output = 'Wrote lock file to "' . $lockFile . '"';
58 if ($input->getArgument('redirect')) {
59 $lockFileContent = $input->getArgument('redirect');
60 $output .= LF . 'with content "' . $lockFileContent . '".';
61 } else {
62 $lockFileContent = '';
63 $output .= '.';
64 }
65 GeneralUtility::writeFile($lockFile, $lockFileContent);
66 $io->success($output);
67 }
68
69 /**
70 * Location of the file name
71 *
72 * @return string
73 */
74 protected function getLockFileName()
75 {
76 return Environment::getLegacyConfigPath() . '/LOCK_BACKEND';
77 }
78 }