| author | cavaliet |
| Tue, 15 Nov 2011 12:27:02 +0100 | |
| changeset 31 | f457dd0e7a1e |
| parent 18 | c85b9d1ddf19 |
| permissions | -rw-r--r-- |
|
18
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1 |
<?php |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
2 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
3 |
/* |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
4 |
* This file is part of Mandango. |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
5 |
* |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
6 |
* (c) Pablo Díez <pablodip@gmail.com> |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
7 |
* |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
8 |
* This source file is subject to the MIT license that is bundled |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
9 |
* with this source code in the file LICENSE. |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
10 |
*/ |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
11 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
12 |
namespace Mandango\Mondator; |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
13 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
14 |
/** |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
15 |
* Mondator. |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
16 |
* |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
17 |
* @author Pablo Díez <pablodip@gmail.com> |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
18 |
* |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
19 |
* @api |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
20 |
*/ |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
21 |
class Mondator |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
22 |
{ |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
23 |
private $configClasses; |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
24 |
private $extensions; |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
25 |
private $outputs; |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
26 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
27 |
/** |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
28 |
* Constructor. |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
29 |
* |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
30 |
* @api |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
31 |
*/ |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
32 |
public function __construct() |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
33 |
{ |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
34 |
$this->configClasses = array(); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
35 |
$this->extensions = array(); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
36 |
$this->options = array(); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
37 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
38 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
39 |
/** |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
40 |
* Set a config class. |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
41 |
* |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
42 |
* @param string $class The class. |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
43 |
* @param array $configClass The config class. |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
44 |
* |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
45 |
* @api |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
46 |
*/ |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
47 |
public function setConfigClass($class, array $configClass) |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
48 |
{ |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
49 |
$this->configClasses[$class] = $configClass; |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
50 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
51 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
52 |
/** |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
53 |
* Set the config classes. |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
54 |
* |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
55 |
* @param array $configClasses An array of config classes (class as key and config class as value). |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
56 |
* |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
57 |
* @api |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
58 |
*/ |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
59 |
public function setConfigClasses(array $configClasses) |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
60 |
{ |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
61 |
$this->configClasses = array(); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
62 |
foreach ($configClasses as $class => $configClass) { |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
63 |
$this->setConfigClass($class, $configClass); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
64 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
65 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
66 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
67 |
/** |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
68 |
* Returns if a config class exists. |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
69 |
* |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
70 |
* @param string $class The class. |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
71 |
* |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
72 |
* @return bool Returns if the config class exists. |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
73 |
* |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
74 |
* @api |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
75 |
*/ |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
76 |
public function hasConfigClass($class) |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
77 |
{ |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
78 |
return array_key_exists($class, $this->configClasses); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
79 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
80 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
81 |
/** |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
82 |
* Returns the config classes. |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
83 |
* |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
84 |
* @return array The config classes. |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
85 |
* |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
86 |
* @api |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
87 |
*/ |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
88 |
public function getConfigClasses() |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
89 |
{ |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
90 |
return $this->configClasses; |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
91 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
92 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
93 |
/** |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
94 |
* Returns a config class. |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
95 |
* |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
96 |
* @param string $class The class. |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
97 |
* |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
98 |
* @return array The config class. |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
99 |
* |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
100 |
* @throws \InvalidArgumentException If the config class does not exists. |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
101 |
* |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
102 |
* @api |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
103 |
*/ |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
104 |
public function getConfigClass($class) |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
105 |
{ |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
106 |
if (!$this->hasConfigClass($class)) { |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
107 |
throw new \InvalidArgumentException(sprintf('The config class "%s" does not exists.', $class)); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
108 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
109 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
110 |
return $this->configClasses[$class]; |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
111 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
112 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
113 |
/** |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
114 |
* Add a extension. |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
115 |
* |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
116 |
* @param Mandango\Mondator\Extension $extension The extension. |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
117 |
* |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
118 |
* @api |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
119 |
*/ |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
120 |
public function addExtension(Extension $extension) |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
121 |
{ |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
122 |
$this->extensions[] = $extension; |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
123 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
124 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
125 |
/** |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
126 |
* Set the extensions. |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
127 |
* |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
128 |
* @param array $extensions An array of extensions. |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
129 |
* |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
130 |
* @api |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
131 |
*/ |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
132 |
public function setExtensions(array $extensions) |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
133 |
{ |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
134 |
$this->extensions = array(); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
135 |
foreach ($extensions as $extension) { |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
136 |
$this->addExtension($extension); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
137 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
138 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
139 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
140 |
/** |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
141 |
* Returns the extensions. |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
142 |
* |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
143 |
* @return array The extensions. |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
144 |
* |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
145 |
* @api |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
146 |
*/ |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
147 |
public function getExtensions() |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
148 |
{ |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
149 |
return $this->extensions; |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
150 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
151 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
152 |
/** |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
153 |
* Generate the containers. |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
154 |
* |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
155 |
* @return array The containers. |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
156 |
* |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
157 |
* @api |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
158 |
*/ |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
159 |
public function generateContainers() |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
160 |
{ |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
161 |
$containers = array(); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
162 |
$containers['_global'] = new Container(); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
163 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
164 |
// global extensions |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
165 |
$globalExtensions = $this->getExtensions(); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
166 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
167 |
// configClasses |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
168 |
$configClasses = new \ArrayObject(); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
169 |
foreach ($this->getConfigClasses() as $class => $configClass) { |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
170 |
$configClasses[$class] = new \ArrayObject($configClass); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
171 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
172 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
173 |
// classes extensions |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
174 |
$classesExtensions = new \ArrayObject(); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
175 |
$this->generateContainersClassesExtensions($globalExtensions, $classesExtensions, $configClasses); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
176 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
177 |
// config class process |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
178 |
foreach ($classesExtensions as $class => $classExtensions) { |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
179 |
foreach ($classExtensions as $classExtension) { |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
180 |
$classExtension->configClassProcess($class, $configClasses); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
181 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
182 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
183 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
184 |
// pre global process |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
185 |
foreach ($globalExtensions as $globalExtension) { |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
186 |
$globalExtension->preGlobalProcess($configClasses, $containers['_global']); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
187 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
188 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
189 |
// class process |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
190 |
foreach ($classesExtensions as $class => $classExtensions) { |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
191 |
$containers[$class] = $container = new Container(); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
192 |
foreach ($classExtensions as $classExtension) { |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
193 |
$classExtension->classProcess($class, $configClasses, $container); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
194 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
195 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
196 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
197 |
// post global process |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
198 |
foreach ($globalExtensions as $globalExtension) { |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
199 |
$globalExtension->postGlobalProcess($configClasses, $containers['_global']); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
200 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
201 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
202 |
return $containers; |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
203 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
204 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
205 |
private function generateContainersClassesExtensions($globalExtensions, $classesExtensions, $configClasses) |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
206 |
{ |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
207 |
foreach ($configClasses as $class => $configClass) { |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
208 |
if (isset($classesExtensions[$class])) { |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
209 |
continue; |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
210 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
211 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
212 |
$classesExtensions[$class] = $classExtensions = new \ArrayObject($globalExtensions); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
213 |
$this->generateContainersNewClassExtensions($class, $classExtensions, $configClasses); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
214 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
215 |
foreach ($classExtensions as $classExtension) { |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
216 |
$newConfigClasses = new \ArrayObject(); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
217 |
$classExtension->newConfigClassesProcess($class, $configClasses, $newConfigClasses); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
218 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
219 |
foreach ($newConfigClasses as $newClass => $newConfigClass) { |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
220 |
if (isset($classesExtensions[$newClass])) { |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
221 |
throw new \RuntimeException(sprintf('The class "%s" has several config classes.', $class)); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
222 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
223 |
$configClasses[$newClass] = new \ArrayObject($newConfigClass); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
224 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
225 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
226 |
$this->generateContainersClassesExtensions($globalExtensions, $classesExtensions, $configClasses); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
227 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
228 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
229 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
230 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
231 |
private function generateContainersNewClassExtensions($class, $classExtensions, $configClasses, $extensions = null) |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
232 |
{ |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
233 |
if (null === $extensions) { |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
234 |
$extensions = $classExtensions; |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
235 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
236 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
237 |
foreach ($extensions as $extension) { |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
238 |
$newClassExtensions = new \ArrayObject(); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
239 |
$extension->newClassExtensionsProcess($class, $configClasses, $newClassExtensions); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
240 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
241 |
foreach ($newClassExtensions as $newClassExtension) { |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
242 |
if (!$newClassExtension instanceof ClassExtension) { |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
243 |
throw new \RuntimeException(sprintf('Some class extension of the class "%s" in the extension "%s" is not an instance of ClassExtension.', $class, get_class($extension))); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
244 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
245 |
if ($newClassExtension instanceof Extension) { |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
246 |
throw new \RuntimeException(sprintf('Some class extension of the class "%s" in the extension "%s" is a instance of Extension, and it can be only a instance of ClassExtension.', $class, get_class($extension))); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
247 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
248 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
249 |
$classExtensions[] = $newClassExtension; |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
250 |
$this->generateContainersNewClassExtensions($class, $classExtensions, $configClasses, $newClassExtension); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
251 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
252 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
253 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
254 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
255 |
/** |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
256 |
* Dump containers. |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
257 |
* |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
258 |
* @param array $containers An array of containers. |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
259 |
* |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
260 |
* @api |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
261 |
*/ |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
262 |
public function dumpContainers(array $containers) |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
263 |
{ |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
264 |
// directories |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
265 |
foreach ($containers as $container) { |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
266 |
foreach ($container->getDefinitions() as $name => $definition) { |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
267 |
$output = $definition->getOutput(); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
268 |
$dir = $output->getDir(); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
269 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
270 |
if (!file_exists($dir) && false === @mkdir($dir, 0777, true)) { |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
271 |
throw new \RuntimeException(sprintf('Unable to create the %s directory (%s).', $name, $dir)); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
272 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
273 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
274 |
if (!is_writable($dir)) { |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
275 |
throw new \RuntimeException(sprintf('Unable to write in the %s directory (%s).', $name, $dir)); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
276 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
277 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
278 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
279 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
280 |
// output |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
281 |
foreach ($containers as $container) { |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
282 |
foreach ($container->getDefinitions() as $name => $definition) { |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
283 |
$output = $definition->getOutput($name); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
284 |
$dir = $output->getDir(); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
285 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
286 |
$file = $dir.DIRECTORY_SEPARATOR.$definition->getClassName().'.php'; |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
287 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
288 |
if (!file_exists($file) || $output->getOverride()) { |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
289 |
$dumper = new Dumper($definition); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
290 |
$content = $dumper->dump(); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
291 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
292 |
$tmpFile = tempnam(dirname($file), basename($file)); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
293 |
if (false === @file_put_contents($tmpFile, $content) || !@rename($tmpFile, $file)) { |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
294 |
throw new \RuntimeException(sprintf('Failed to write the file "%s".', $file)); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
295 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
296 |
chmod($file, 0644); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
297 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
298 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
299 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
300 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
301 |
|
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
302 |
/** |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
303 |
* Generate and dump the containers. |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
304 |
* |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
305 |
* @api |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
306 |
*/ |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
307 |
public function process() |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
308 |
{ |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
309 |
$this->dumpContainers($this->generateContainers()); |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
310 |
} |
|
c85b9d1ddf19
first implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
311 |
} |