-
Notifications
You must be signed in to change notification settings - Fork 0
/
Config.php
105 lines (93 loc) · 2.33 KB
/
Config.php
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
<?php
/**
* Aura\Cli Provider for Aura\Di
*
* PHP version 5
*
* Copyright (C) 2016 Jake Johns
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*
* @category Config
* @package Fusible\CliProvider
* @author Jake Johns <jake@jakejohns.net>
* @copyright 2016 Jake Johns
* @license http://jnj.mit-license.org/2016 MIT License
* @link https://github.com/fusible/fusible.cli-provider
*/
namespace Fusible\CliProvider;
use Aura\Di\Container;
use Aura\Di\ContainerConfig;
use Aura\Cli\CliFactory as Factory;
use Aura\Cli\Context\OptionFactory;
use Aura\Cli\Help;
/**
* Config
*
* @category Config
* @package Fusible\CliProvider
* @author Jake Johns <jake@jakejohns.net>
* @license http://jnj.mit-license.org/2016 MIT License
* @link https://github.com/fusible/fusible.cli-provider
*
* @see ContainerConfig
*/
class Config extends ContainerConfig
{
const GLOBALS = 'GLOBALS';
const FACTORY = 'aura/cli:factory';
const CONTEXT = 'aura/cli:context';
const STDIO = 'aura/cli:stdio';
/**
* Globals
*
* @var array
*
* @access protected
*/
protected $globals;
/**
* __construct
*
* @param array $globals GLOBALS array
*
* @access public
*/
public function __construct(array $globals = null)
{
$this->globals = (null === $globals) ? $GLOBALS : $globals;
}
/**
* Define Aura\Cli factories, services, and params
*
* @param Container $di DI Container
*
* @return void
*
* @access public
*
* @SuppressWarnings(PHPMD.ShortVariable)
*/
public function define(Container $di)
{
if (! isset($di->values[static::GLOBALS])) {
$di->values[static::GLOBALS] = $this->globals;
}
$di->set(static::FACTORY, $di->lazyNew(Factory::class));
$di->set(
static::CONTEXT,
$di->lazyGetCall(
static::FACTORY,
'newContext',
$di->lazyValue(static::GLOBALS)
)
);
$di->set(
static::STDIO,
$di->lazyGetCall(static::FACTORY, 'newStdio')
);
$di->params[Help::class]
['option_factory'] = $di->lazyNew(OptionFactory::class);
}
}