‪TYPO3CMS  9.5
LockBackendCommand.php
Go to the documentation of this file.
1 <?php
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;
23 
27 class ‪LockBackendCommand extends Command
28 {
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 
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 
74  protected function ‪getLockFileName()
75  {
76  return ‪Environment::getLegacyConfigPath() . '/LOCK_BACKEND';
77  }
78 }
‪TYPO3\CMS\Backend\Command\LockBackendCommand\configure
‪configure()
Definition: LockBackendCommand.php:32
‪TYPO3\CMS\Backend\Command\LockBackendCommand
Definition: LockBackendCommand.php:28
‪TYPO3\CMS\Backend\Command
Definition: LockBackendCommand.php:2
‪TYPO3\CMS\Backend\Command\LockBackendCommand\execute
‪execute(InputInterface $input, OutputInterface $output)
Definition: LockBackendCommand.php:49
‪$output
‪$output
Definition: annotationChecker.php:113
‪TYPO3\CMS\Backend\Command\LockBackendCommand\getLockFileName
‪string getLockFileName()
Definition: LockBackendCommand.php:74
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:39
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Core\Core\Environment\getLegacyConfigPath
‪static string getLegacyConfigPath()
Definition: Environment.php:256