[TASK] Cleanup CLI commands in EXT:backend
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Classes / Command / UnlockBackendCommand.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\InputInterface;
18 use Symfony\Component\Console\Output\OutputInterface;
19 use Symfony\Component\Console\Style\SymfonyStyle;
20
21 /**
22 * Core function for unlocking the TYPO3 Backend
23 */
24 class UnlockBackendCommand extends Command
25 {
26 /**
27 * Configure the command by defining the name, options and arguments
28 */
29 protected function configure()
30 {
31 $this->setDescription('Unlock the TYPO3 Backend');
32 }
33
34 /**
35 * Executes the command for removing the lock file
36 *
37 * @param InputInterface $input
38 * @param OutputInterface $output
39 * @return void
40 */
41 protected function execute(InputInterface $input, OutputInterface $output)
42 {
43 $io = new SymfonyStyle($input, $output);
44 $io->title($this->getDescription());
45 $lockFile = $this->getLockFileName();
46 if (@is_file($lockFile)) {
47 unlink($lockFile);
48 if (@is_file($lockFile)) {
49 $io->caution('Could not remove lock file "' . $lockFile . '"!');
50 } else {
51 $io->success('Removed lock file "' . $lockFile . '".');
52 }
53 } else {
54 $io->note('No lock file "' . $lockFile . '" was found.' . LF . 'Hence no lock can be removed.');
55 }
56 }
57
58 /**
59 * Location of the file name
60 *
61 * @return string
62 */
63 protected function getLockFileName()
64 {
65 return PATH_typo3conf . 'LOCK_BACKEND';
66 }
67 }