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
<?php
/**
* @see https://github.com/zendframework/zend-component-installer for the canonical source repository
* @copyright Copyright (c) 2016-2017 Zend Technologies USA Inc. (http://www.zend.com)
* @license https://github.com/zendframework/zend-component-installer/blob/master/LICENSE.md New BSD License
*/
namespace Zend\ComponentInstaller\Injector;
class ApplicationConfigInjector extends AbstractInjector
{
/**
* Configuration file to update.
*
* @var string
*/
protected $configFile = 'config/application.config.php';
/**
* Patterns and replacements to use when registering a code item.
*
* @var string[]
*/
protected $injectionPatterns = [
self::TYPE_COMPONENT => [
'pattern' => '/^(\s+)(\'modules\'\s*\=\>\s*(?:array\s*\(|\[))\s*$/m',
'replacement' => "\$1\$2\n\$1 '%s',",
],
self::TYPE_MODULE => [
'pattern' => "/('modules'\s*\=\>\s*(?:array\s*\(|\[).*?)\n(\s+)(\)|\])/s",
'replacement' => "\$1\n\$2 '%s',\n\$2\$3",
],
self::TYPE_DEPENDENCY => [
'pattern' => '/^(\s+)(\'modules\'\s*\=\>\s*(?:array\s*\(|\[)[^)\]]*\'%s\')/m',
'replacement' => "\$1\$2,\n\$1 '%s'",
],
self::TYPE_BEFORE_APPLICATION => [
'pattern' => '/^(\s+)(\'modules\'\s*\=\>\s*(?:array\s*\(|\[)[^)\]]*)(\'%s\')/m',
'replacement' => "\$1\$2'%s',\n$1 \$3",
],
];
/**
* Pattern to use to determine if the code item is registered.
*
* @var string
*/
protected $isRegisteredPattern = '/\'modules\'\s*\=\>\s*(?:array\(|\[)[^)\]]*\'%s\'/s';
/**
* Patterns and replacements to use when removing a code item.
*
* @var string[]
*/
protected $removalPatterns = [
'pattern' => '/^\s+\'%s\',\s*$/m',
'replacement' => '',
];
}