1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Drush Cerbere command line tools. |
5
|
|
|
* Copyright (C) 2015 - Sebastien Malot <[email protected]> |
6
|
|
|
* |
7
|
|
|
* This program is free software; you can redistribute it and/or modify |
8
|
|
|
* it under the terms of the GNU General Public License as published by |
9
|
|
|
* the Free Software Foundation; either version 2 of the License, or |
10
|
|
|
* (at your option) any later version. |
11
|
|
|
* |
12
|
|
|
* This program is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
* GNU General Public License for more details. |
16
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU General Public License along |
18
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc., |
19
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
20
|
|
|
*/ |
21
|
|
|
|
22
|
|
|
namespace Cerbere\Parser; |
23
|
|
|
|
24
|
|
|
use Cerbere\Model\Project; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Class Make |
28
|
|
|
* @package Cerbere\Parser |
29
|
|
|
*/ |
30
|
|
|
class Make extends Ini |
31
|
|
|
{ |
32
|
|
|
/** |
33
|
|
|
* @var string |
34
|
|
|
*/ |
35
|
|
|
protected $core; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var string |
39
|
|
|
*/ |
40
|
|
|
protected $api; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @var Project[] |
44
|
|
|
*/ |
45
|
|
|
protected $projects; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @var array |
49
|
|
|
*/ |
50
|
|
|
protected $libraries; |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* |
54
|
|
|
*/ |
55
|
|
|
public function __construct() |
56
|
|
|
{ |
57
|
|
|
|
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @return string |
62
|
|
|
*/ |
63
|
|
|
public function getApi() |
64
|
|
|
{ |
65
|
|
|
return $this->api; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @return string |
70
|
|
|
*/ |
71
|
|
|
public function getCode() |
72
|
|
|
{ |
73
|
|
|
return 'make'; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @return Project[] |
78
|
|
|
*/ |
79
|
|
|
public function getProjects() |
80
|
|
|
{ |
81
|
|
|
return $this->projects; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @param string $content |
86
|
|
|
* |
87
|
|
|
* @return void |
88
|
|
|
*/ |
89
|
|
|
public function processContent($content) |
90
|
|
|
{ |
91
|
|
|
$data = $this->parseContent($content); |
92
|
|
|
|
93
|
|
|
// Core attribute is mandatory since Drupal 7.x. |
94
|
|
|
$data += array('core' => '6.x', 'api' => '', 'projects' => array(), 'libraries' => array()); |
95
|
|
|
|
96
|
|
|
$this->core = $data['core']; |
97
|
|
|
$this->api = $data['api']; |
98
|
|
|
$this->projects = array(); |
99
|
|
|
$this->libraries = $data['libraries']; |
100
|
|
|
|
101
|
|
|
// Wrap project into objects. |
102
|
|
|
foreach ($data['projects'] as $project_name => $project_details) { |
103
|
|
|
$project_details['version'] = $this->getCore() . '-' . $project_details['version']; |
104
|
|
|
|
105
|
|
|
$project = new Project($project_name, $this->getCore(), $project_details['version']); |
106
|
|
|
$project->setDetails($project_details); |
107
|
|
|
|
108
|
|
|
$this->projects[$project_name] = $project; |
109
|
|
|
} |
110
|
|
|
|
111
|
|
|
// Todo: wrap libraries into objects. |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
/** |
115
|
|
|
* @return string |
116
|
|
|
*/ |
117
|
|
|
public function getCore() |
118
|
|
|
{ |
119
|
|
|
return $this->core; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
/** |
123
|
|
|
* @parser string $filename |
124
|
|
|
* @return bool |
125
|
|
|
*/ |
126
|
|
|
public function supportedFile($filename) |
127
|
|
|
{ |
128
|
|
|
return preg_match('/\.make$/i', $filename) > 0; |
129
|
|
|
} |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* @return array |
133
|
|
|
*/ |
134
|
|
|
public function getLibraries() |
135
|
|
|
{ |
136
|
|
|
return $this->libraries; |
137
|
|
|
} |
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* @param string $project |
141
|
|
|
* |
142
|
|
|
* @return Project |
143
|
|
|
*/ |
144
|
|
|
public function getProject($project) |
145
|
|
|
{ |
146
|
|
|
return $this->projects[$project]; |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
/** |
150
|
|
|
* @param string $project |
151
|
|
|
* |
152
|
|
|
* @return bool |
153
|
|
|
*/ |
154
|
|
|
public function hasProject($project) |
155
|
|
|
{ |
156
|
|
|
return isset($this->projects[$project]); |
157
|
|
|
} |
158
|
|
|
} |
159
|
|
|
|