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; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
use ConsoleHelpers\CodeInsight\KnowledgeBase\DatabaseManager; |
15
|
|
|
use ConsoleHelpers\CodeInsight\KnowledgeBase\KnowledgeBaseFactory; |
16
|
|
|
use ConsoleHelpers\DatabaseMigration\MigrationManager; |
17
|
|
|
use ConsoleHelpers\DatabaseMigration\PhpMigrationRunner; |
18
|
|
|
use ConsoleHelpers\DatabaseMigration\SqlMigrationRunner; |
19
|
|
|
|
20
|
|
|
class Container extends \ConsoleHelpers\ConsoleKit\Container |
21
|
|
|
{ |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* {@inheritdoc} |
25
|
|
|
*/ |
26
|
|
|
public function __construct(array $values = array()) |
27
|
|
|
{ |
28
|
|
|
parent::__construct($values); |
29
|
|
|
|
30
|
|
|
$this['app_name'] = 'Code-Insight'; |
31
|
|
|
$this['app_version'] = '@git-version@'; |
32
|
|
|
|
33
|
|
|
$this['working_directory_sub_folder'] = '.code-insight'; |
34
|
|
|
|
35
|
|
|
$this['config_defaults'] = array(); |
36
|
|
|
|
37
|
|
|
$this['project_root_folder'] = function () { |
38
|
|
|
return dirname(dirname(__DIR__)); |
39
|
|
|
}; |
40
|
|
|
|
41
|
|
|
$this['migration_manager'] = function ($c) { |
42
|
|
|
$migrations_directory = $c['project_root_folder'] . '/migrations'; |
43
|
|
|
$migration_manager = new MigrationManager($migrations_directory, $c); |
44
|
|
|
$migration_manager->registerMigrationRunner(new SqlMigrationRunner()); |
45
|
|
|
$migration_manager->registerMigrationRunner(new PhpMigrationRunner()); |
46
|
|
|
|
47
|
|
|
return $migration_manager; |
48
|
|
|
}; |
49
|
|
|
|
50
|
|
|
$this['db_manager'] = function ($c) { |
51
|
|
|
return new DatabaseManager($c['migration_manager']); |
52
|
|
|
}; |
53
|
|
|
|
54
|
|
|
$this['knowledge_base_factory'] = function ($c) { |
55
|
|
|
return new KnowledgeBaseFactory($c['db_manager']); |
56
|
|
|
}; |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
} |
60
|
|
|
|