Passed
Push — master ( daf0b2...38121e )
by
unknown
17:34
created

UnlockBackendCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
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
16
namespace TYPO3\CMS\Backend\Command;
17
18
use Symfony\Component\Console\Command\Command;
19
use Symfony\Component\Console\Input\InputInterface;
20
use Symfony\Component\Console\Output\OutputInterface;
21
use Symfony\Component\Console\Style\SymfonyStyle;
22
use TYPO3\CMS\Core\Core\Environment;
23
24
/**
25
 * Core function for unlocking the TYPO3 Backend
26
 */
27
class UnlockBackendCommand extends Command
28
{
29
    /**
30
     * Executes the command for removing the lock file
31
     *
32
     * @param InputInterface $input
33
     * @param OutputInterface $output
34
     * @return int
35
     */
36
    protected function execute(InputInterface $input, OutputInterface $output)
37
    {
38
        $io = new SymfonyStyle($input, $output);
39
        $io->title($this->getDescription());
40
        $lockFile = $this->getLockFileName();
41
        if (@is_file($lockFile)) {
42
            unlink($lockFile);
43
            if (@is_file($lockFile)) {
44
                $io->caution('Could not remove lock file "' . $lockFile . '"!');
45
                return 1;
46
            }
47
            $io->success('Removed lock file "' . $lockFile . '".');
48
        } else {
49
            $io->note('No lock file "' . $lockFile . '" was found.' . LF . 'Hence no lock can be removed.');
50
        }
51
        return 0;
52
    }
53
54
    /**
55
     * Location of the file name
56
     *
57
     * @return string
58
     */
59
    protected function getLockFileName()
60
    {
61
        return Environment::getLegacyConfigPath() . '/LOCK_BACKEND';
62
    }
63
}
64