TYPO3 CMS  TYPO3_8-7
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  */
22 
26 class LockBackendCommand extends Command
27 {
31  protected function configure()
32  {
33  $this
34  ->setDescription('Lock the TYPO3 Backend')
35  ->addArgument(
36  'redirect',
37  InputArgument::OPTIONAL,
38  'If set, then the TYPO3 Backend will redirect to the locking state (only used when locking the TYPO3 Backend'
39  );
40  }
41 
48  protected function execute(InputInterface $input, OutputInterface $output)
49  {
50  $io = new SymfonyStyle($input, $output);
51  $io->title($this->getDescription());
52  $lockFile = $this->getLockFileName();
53  if (@is_file($lockFile)) {
54  $io->note('A lock file already exists. Overwriting it.');
55  }
56  $output = 'Wrote lock file to "' . $lockFile . '"';
57  if ($input->getArgument('redirect')) {
58  $lockFileContent = $input->getArgument('redirect');
59  $output .= LF . 'with content "' . $lockFileContent . '".';
60  } else {
61  $lockFileContent = '';
62  $output .= '.';
63  }
64  GeneralUtility::writeFile($lockFile, $lockFileContent);
65  $io->success($output);
66  }
67 
73  protected function getLockFileName()
74  {
75  return PATH_typo3conf . 'LOCK_BACKEND';
76  }
77 }
static writeFile($file, $content, $changePermissions=false)
execute(InputInterface $input, OutputInterface $output)