1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of the Cecil/Cecil package. |
4
|
|
|
* |
5
|
|
|
* Copyright (c) Arnaud Ligny <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace Cecil\Command; |
12
|
|
|
|
13
|
|
|
use Cecil\Util; |
14
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
15
|
|
|
use Symfony\Component\Console\Input\InputDefinition; |
16
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
17
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Removes assets cache files. |
21
|
|
|
*/ |
22
|
|
|
class CacheClearAssets extends AbstractCommand |
23
|
|
|
{ |
24
|
|
|
/** |
25
|
|
|
* {@inheritdoc} |
26
|
|
|
*/ |
27
|
|
|
protected function configure() |
28
|
|
|
{ |
29
|
|
|
$this |
30
|
|
|
->setName('cache:clear:assets') |
31
|
|
|
->setDescription('Removes assets cache') |
32
|
|
|
->setDefinition( |
33
|
|
|
new InputDefinition([ |
34
|
|
|
new InputArgument('path', InputArgument::OPTIONAL, 'Use the given path as working directory'), |
35
|
|
|
]) |
36
|
|
|
) |
37
|
|
|
->setHelp('Remove cacheds assets files'); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* {@inheritdoc} |
42
|
|
|
*/ |
43
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
44
|
|
|
{ |
45
|
|
|
if (!$this->fs->exists(Util::joinFile($this->getBuilder()->getConfig()->getCachePath(), 'assets'))) { |
46
|
|
|
$output->writeln('<info>No assets cache.</info>'); |
47
|
|
|
|
48
|
|
|
return 0; |
49
|
|
|
} |
50
|
|
|
$output->writeln('Removing assets cache directory...'); |
51
|
|
|
$output->writeln( |
52
|
|
|
sprintf('<comment>Path %s</comment>', Util::joinFile($this->getBuilder()->getConfig()->getCachePath(), 'assets')), |
53
|
|
|
OutputInterface::VERBOSITY_VERBOSE |
54
|
|
|
); |
55
|
|
|
$this->fs->remove(Util::joinFile($this->getBuilder()->getConfig()->getCachePath(), 'assets')); |
56
|
|
|
$output->writeln('<info>Assets cache is clear.</info>'); |
57
|
|
|
|
58
|
|
|
return 0; |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
|