‪TYPO3CMS  10.4
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  ->setDescription('Lock the TYPO3 Backend')
38  ->addArgument(
39  'redirect',
40  InputArgument::OPTIONAL,
41  'If set, then the TYPO3 Backend will redirect to the locking state (only used when locking the TYPO3 Backend'
42  );
43  }
44 
52  protected function ‪execute(InputInterface $input, OutputInterface ‪$output)
53  {
54  $io = new SymfonyStyle($input, ‪$output);
55  $io->title($this->getDescription());
56  $lockFile = $this->‪getLockFileName();
57  if (@is_file($lockFile)) {
58  $io->note('A lock file already exists. Overwriting it.');
59  }
60  ‪$output = 'Wrote lock file to "' . $lockFile . '"';
61  if ($input->getArgument('redirect')) {
62  $lockFileContent = $input->getArgument('redirect');
63  $lockFileContent = is_string($lockFileContent) ? $lockFileContent : '';
64  ‪$output .= LF . 'with content "' . $lockFileContent . '".';
65  } else {
66  $lockFileContent = '';
67  ‪$output .= '.';
68  }
69  ‪GeneralUtility::writeFile($lockFile, $lockFileContent);
70  $io->success(‪$output);
71  return 0;
72  }
73 
79  protected function ‪getLockFileName()
80  {
81  return ‪Environment::getLegacyConfigPath() . '/LOCK_BACKEND';
82  }
83 }
‪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:119
‪TYPO3\CMS\Backend\Command\LockBackendCommand\getLockFileName
‪string getLockFileName()
Definition: LockBackendCommand.php:79
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:40
‪TYPO3\CMS\Backend\Command\LockBackendCommand\execute
‪int execute(InputInterface $input, OutputInterface $output)
Definition: LockBackendCommand.php:52
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Core\Utility\GeneralUtility\writeFile
‪static bool writeFile($file, $content, $changePermissions=false)
Definition: GeneralUtility.php:1836
‪TYPO3\CMS\Core\Core\Environment\getLegacyConfigPath
‪static string getLegacyConfigPath()
Definition: Environment.php:282