-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiris
More file actions
executable file
·76 lines (66 loc) · 2.48 KB
/
iris
File metadata and controls
executable file
·76 lines (66 loc) · 2.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env php
<?php
$coreDir = dirname(__FILE__) . '/src/Iris/';
require_once $coreDir . 'core/engine/autoload.php';
use Doctrine\DBAL\Migrations\Tools\Console\Command;
use Iris\Iris;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;
use Symfony\Component\Console\Input\InputOption;
// Get environment
$input = new ArgvInput();
$env = $input->getParameterOption(['--env', '-e'], getenv('IRIS_ENV'));
putenv('IRIS_ENV=' . $env);
require_once $coreDir . 'core/engine/includes.php';
$cli = new Application();
$cli->getDefinition()->addOption(new InputOption('--env', '-e', InputOption::VALUE_NONE, 'The Environment name'));
$cli->setName('Iris CRM Console Tool');
// Register all commands
$hierarchy = array_merge([
[
'namespace' => '\\Iris',
'directory' => $coreDir,
'postfix' => '',
]
],
Loader::getLoader()->getHierarchy()
);
foreach ($hierarchy as $item) {
$directory = $item['directory'] . 'Command/';
if (is_dir($directory)) {
foreach (new \DirectoryIterator($directory) as $fileInfo) {
if (is_file($directory . $fileInfo->getFilename()) && substr($fileInfo->getFilename(), -11) === 'Command.php') {
$command = $item['namespace'] . '\\Command\\' . substr($fileInfo->getFilename(), 0, -4);
if (class_exists($command)) {
$cli->add(new $command);
}
}
}
}
}
// Register Doctrine Migrations commands
$config = new \Doctrine\DBAL\Configuration();
$connectionParams = array(
'dbname' => Iris::$app->config('db.db_name'),
'user' => Iris::$app->config('db.username'),
'password' => Iris::$app->config('db.password'),
'host' => Iris::$app->config('db.host'),
'driver' => 'pdo_' . Iris::$app->config('db.conn_type'),
);
$db = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);
$helperSet = $cli->getHelperSet();
$helperSet->set(new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($db), 'db');
$helperSet->set(new \Symfony\Component\Console\Helper\QuestionHelper(), 'dialog');
$cli->addCommands([
//new Command\DiffCommand(),
new Command\ExecuteCommand(),
new Command\GenerateCommand(),
new Command\MigrateCommand(),
new Command\StatusCommand(),
new Command\VersionCommand(),
]);
$cli->add(new \Bernard\Command\ConsumeCommand(
Iris::$app->getContainer()->get('queue.consumer'),
Iris::$app->getContainer()->get('queue.factory')
));
$cli->run();