1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Aist Filesystem Component (http://mateuszsitek.com/projects/filesystem) |
5
|
|
|
* |
6
|
|
|
* @copyright Copyright (c) 2017 DIGITAL WOLVES LTD (http://digitalwolves.ltd) All rights reserved. |
7
|
|
|
* @license http://opensource.org/licenses/BSD-3-Clause BSD-3-Clause |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace Aist\Filesystem\Console\Command; |
11
|
|
|
|
12
|
|
|
use Symfony\Component\Console\Command\Command; |
13
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
14
|
|
|
use Symfony\Component\Console\Input\InputOption; |
15
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
16
|
|
|
use Symfony\Component\Console\Style\SymfonyStyle; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Dump file command |
20
|
|
|
*/ |
21
|
|
|
class DumpFileCommand extends Command |
22
|
|
|
{ |
23
|
|
|
const NAME = 'filesystem:dump-file'; |
24
|
|
|
|
25
|
|
|
const DESCRIPTION = 'Filesystem dump file.'; |
26
|
|
|
|
27
|
|
|
const HELP = <<< 'EOT' |
28
|
|
|
Filesystem dump file. |
29
|
|
|
EOT; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* {@inheritdoc} |
33
|
|
|
*/ |
34
|
|
|
protected function configure() |
35
|
|
|
{ |
36
|
|
|
$this |
37
|
|
|
->setName(self::NAME) |
38
|
|
|
->setDescription(self::DESCRIPTION) |
39
|
|
|
->setHelp(self::HELP) |
40
|
|
|
->setDefinition([ |
41
|
|
|
new InputOption( |
42
|
|
|
'target', |
43
|
|
|
't', |
44
|
|
|
InputOption::VALUE_REQUIRED, |
45
|
|
|
'Target path.' |
46
|
|
|
), |
47
|
|
|
new InputOption( |
48
|
|
|
'content', |
49
|
|
|
'c', |
50
|
|
|
InputOption::VALUE_REQUIRED, |
51
|
|
|
'Content.' |
52
|
|
|
), |
53
|
|
|
]) |
54
|
|
|
; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* Executes the command |
59
|
|
|
*/ |
60
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
61
|
|
|
{ |
62
|
|
|
/** |
63
|
|
|
* Strange issue |
64
|
|
|
* Without this we can't use $this->getHelper('name') |
65
|
|
|
* but $this->getApplication()->getHelperSet()->get('name') |
66
|
|
|
*/ |
67
|
|
|
$this->setApplication($this->getApplication()); |
68
|
|
|
$filesystem = $this->getHelper('filesystem'); |
69
|
|
|
$logger = $this->getHelper('logger'); |
70
|
|
|
$io = new SymfonyStyle($input, $output); |
71
|
|
|
|
72
|
|
|
$target = $input->getOption('target'); |
73
|
|
|
$content = $input->getOption('content'); |
74
|
|
|
|
75
|
|
|
try { |
76
|
|
|
$filesystem->dumpFile($target, $content); |
|
|
|
|
77
|
|
|
if (! $output->isQuiet()) { |
78
|
|
|
$output->writeln(sprintf(' - Saved <info>%s</info>', $target)); |
79
|
|
|
} |
80
|
|
|
$logger->info( |
|
|
|
|
81
|
|
|
self::class, |
82
|
|
|
[ |
83
|
|
|
'target' => $target, |
84
|
|
|
'content' => $content, |
85
|
|
|
] |
86
|
|
|
); |
87
|
|
|
} catch (\Exception $exception) { |
88
|
|
|
if (! $output->isQuiet()) { |
89
|
|
|
$io->error($exception->getMessage()); |
90
|
|
|
} |
91
|
|
|
$logger->error( |
|
|
|
|
92
|
|
|
self::class, |
93
|
|
|
[ |
94
|
|
|
'code' => $exception->getCode(), |
95
|
|
|
'message' => $exception->getMessage(), |
96
|
|
|
'target' => $target, |
97
|
|
|
'content' => $content, |
98
|
|
|
] |
99
|
|
|
); |
100
|
|
|
|
101
|
|
|
return 1; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
return 0; |
105
|
|
|
} |
106
|
|
|
} |
107
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.