‪TYPO3CMS  ‪main
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 
47  protected function ‪execute(InputInterface $input, OutputInterface ‪$output): int
48  {
49  $io = new SymfonyStyle($input, ‪$output);
50  $io->title($this->getDescription());
51  $lockFile = $this->‪getLockFileName();
52  if (@is_file($lockFile)) {
53  $io->note('A lock file already exists. Overwriting it.');
54  }
55  ‪$output = 'Wrote lock file to "' . $lockFile . '"';
56  if ($input->getArgument('redirect')) {
57  $lockFileContent = $input->getArgument('redirect');
58  $lockFileContent = is_string($lockFileContent) ? $lockFileContent : '';
59  ‪$output .= LF . 'with content "' . $lockFileContent . '".';
60  } else {
61  $lockFileContent = '';
62  ‪$output .= '.';
63  }
64  ‪GeneralUtility::writeFile($lockFile, $lockFileContent);
65  $io->success(‪$output);
66  return Command::SUCCESS;
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:34
‪TYPO3\CMS\Backend\Command\LockBackendCommand
Definition: LockBackendCommand.php:30
‪TYPO3\CMS\Core\Core\Environment\getLegacyConfigPath
‪static getLegacyConfigPath()
Definition: Environment.php:268
‪TYPO3\CMS\Backend\Command
Definition: CreateBackendUserCommand.php:18
‪TYPO3\CMS\Backend\Command\LockBackendCommand\execute
‪execute(InputInterface $input, OutputInterface $output)
Definition: LockBackendCommand.php:47
‪$output
‪$output
Definition: annotationChecker.php:119
‪TYPO3\CMS\Backend\Command\LockBackendCommand\getLockFileName
‪string getLockFileName()
Definition: LockBackendCommand.php:74
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:41
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:51
‪TYPO3\CMS\Core\Utility\GeneralUtility\writeFile
‪static bool writeFile($file, $content, $changePermissions=false)
Definition: GeneralUtility.php:1452