|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the Code-Insight library. |
|
4
|
|
|
* For the full copyright and license information, please view |
|
5
|
|
|
* the LICENSE file that was distributed with this source code. |
|
6
|
|
|
* |
|
7
|
|
|
* @copyright Alexander Obuhovich <[email protected]> |
|
8
|
|
|
* @link https://github.com/console-helpers/code-insight |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace ConsoleHelpers\CodeInsight\Command; |
|
12
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
use ConsoleHelpers\CodeInsight\KnowledgeBase\KnowledgeBaseFactory; |
|
15
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
16
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
17
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
18
|
|
|
|
|
19
|
|
|
class SyncCommand extends AbstractCommand |
|
20
|
|
|
{ |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* Knowledge base factory. |
|
24
|
|
|
* |
|
25
|
|
|
* @var KnowledgeBaseFactory |
|
26
|
|
|
*/ |
|
27
|
|
|
private $_knowledgeBaseFactory; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* {@inheritdoc} |
|
31
|
|
|
*/ |
|
32
|
|
|
protected function configure() |
|
33
|
|
|
{ |
|
34
|
|
|
$this |
|
35
|
|
|
->setName('sync') |
|
36
|
|
|
->setDescription('Synchronizes collected information about code with actual code') |
|
37
|
|
|
->addArgument( |
|
38
|
|
|
'project-path', |
|
39
|
|
|
InputArgument::OPTIONAL, |
|
40
|
|
|
'Path to project root folder (where <comment>.code-insight.json</comment> is located)', |
|
41
|
|
|
'.' |
|
42
|
|
|
); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Prepare dependencies. |
|
47
|
|
|
* |
|
48
|
|
|
* @return void |
|
49
|
|
|
*/ |
|
50
|
|
|
protected function prepareDependencies() |
|
51
|
|
|
{ |
|
52
|
|
|
parent::prepareDependencies(); |
|
53
|
|
|
|
|
54
|
|
|
$container = $this->getContainer(); |
|
55
|
|
|
|
|
56
|
|
|
$this->_knowledgeBaseFactory = $container['knowledge_base_factory']; |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* {@inheritdoc} |
|
61
|
|
|
*/ |
|
62
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
63
|
|
|
{ |
|
64
|
|
|
$knowledge_base = $this->_knowledgeBaseFactory->getKnowledgeBase( |
|
65
|
|
|
$this->getPath('project-path'), |
|
66
|
|
|
$this->io |
|
67
|
|
|
); |
|
68
|
|
|
|
|
69
|
|
|
$knowledge_base->refresh(); |
|
70
|
|
|
|
|
71
|
|
|
$this->io->writeln('Done.'); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
} |
|
75
|
|
|
|