@@ -34,8 +34,7 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @var array |
36 | 36 | */ |
37 | - private static $loglevels = array |
|
38 | - ( |
|
37 | + private static $loglevels = array( |
|
39 | 38 | 'error' => Logger::ERROR, |
40 | 39 | 'warn' => Logger::WARNING, |
41 | 40 | 'warning' => Logger::WARNING, |
@@ -226,7 +225,7 @@ discard block |
||
226 | 225 | if ($midgard->config->logfilename) |
227 | 226 | { |
228 | 227 | $logdir = dirname($midgard->config->logfilename); |
229 | - if ( !is_dir($logdir) |
|
228 | + if (!is_dir($logdir) |
|
230 | 229 | && !mkdir($logdir, 0777, true)) |
231 | 230 | { |
232 | 231 | throw exception::user_data('Log directory could not be created'); |
@@ -233,8 +233,7 @@ |
||
233 | 233 | } |
234 | 234 | self::$logger = new Logger('midgard-portable'); |
235 | 235 | self::$logger->pushHandler(new StreamHandler($midgard->config->logfilename, self::$loglevels[$midgard->get_loglevel()])); |
236 | - } |
|
237 | - else |
|
236 | + } else |
|
238 | 237 | { |
239 | 238 | throw exception::user_data('log filename not set in config'); |
240 | 239 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | { |
110 | 110 | $repligard_entry = $em->getRepository('midgard:midgard_repligard')->findOneBy(array('guid' => $entity->guid)); |
111 | 111 | |
112 | - if ( $entity instanceof entity |
|
112 | + if ($entity instanceof entity |
|
113 | 113 | && $entity->metadata->deleted) |
114 | 114 | { |
115 | 115 | $repligard_entry->object_action = self::ACTION_DELETE; |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | { |
159 | 159 | if ($platform->getName() === 'sqlite') |
160 | 160 | { |
161 | - if ( !empty($config['primary']) |
|
161 | + if (!empty($config['primary']) |
|
162 | 162 | && !empty($config['autoincrement'])) |
163 | 163 | { |
164 | 164 | /* |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | $modified = true; |
169 | 169 | $config['columnDefinition'] = 'INTEGER PRIMARY KEY AUTOINCREMENT'; |
170 | 170 | } |
171 | - if ( !empty($config['comment']) |
|
171 | + if (!empty($config['comment']) |
|
172 | 172 | && $config['comment'] == 'BINARY') |
173 | 173 | { |
174 | 174 | $modified = true; |
@@ -263,8 +263,7 @@ discard block |
||
263 | 263 | { |
264 | 264 | $args->preventDefault(); |
265 | 265 | |
266 | - $options = array |
|
267 | - ( |
|
266 | + $options = array( |
|
268 | 267 | 'length' => 255, |
269 | 268 | 'default' => isset($column['default']) ? $column['default'] : null, |
270 | 269 | 'notnull' => (bool) ($column['null'] != 'YES'), |
@@ -276,8 +275,7 @@ discard block |
||
276 | 275 | else if ($type == 'datetime') |
277 | 276 | { |
278 | 277 | $args->preventDefault(); |
279 | - $options = array |
|
280 | - ( |
|
278 | + $options = array( |
|
281 | 279 | 'default' => isset($column['default']) ? $column['default'] : null, |
282 | 280 | 'notnull' => (bool) ($column['null'] != 'YES'), |
283 | 281 | ); |
@@ -296,7 +294,7 @@ discard block |
||
296 | 294 | public function postGenerateSchemaTable(GenerateSchemaTableEventArgs $args) |
297 | 295 | { |
298 | 296 | $table = $args->getClassTable(); |
299 | - if ( !$table->hasOption('engine') |
|
297 | + if (!$table->hasOption('engine') |
|
300 | 298 | || $table->getOption('engine') !== 'MyISAM') |
301 | 299 | { |
302 | 300 | return; |
@@ -309,8 +307,7 @@ discard block |
||
309 | 307 | |
310 | 308 | public function getSubscribedEvents() |
311 | 309 | { |
312 | - return array |
|
313 | - ( |
|
310 | + return array( |
|
314 | 311 | Events::onFlush, |
315 | 312 | dbal_events::onSchemaCreateTable, dbal_events::onSchemaColumnDefinition, |
316 | 313 | ToolEvents::postGenerateSchemaTable |
@@ -113,8 +113,7 @@ discard block |
||
113 | 113 | && $entity->metadata->deleted) |
114 | 114 | { |
115 | 115 | $repligard_entry->object_action = self::ACTION_DELETE; |
116 | - } |
|
117 | - else |
|
116 | + } else |
|
118 | 117 | { |
119 | 118 | $repligard_entry->object_action = self::ACTION_UPDATE; |
120 | 119 | } |
@@ -272,8 +271,7 @@ discard block |
||
272 | 271 | ); |
273 | 272 | |
274 | 273 | $args->setColumn(new Column($column['field'], Type::getType(Type::STRING), $options)); |
275 | - } |
|
276 | - else if ($type == 'datetime') |
|
274 | + } else if ($type == 'datetime') |
|
277 | 275 | { |
278 | 276 | $args->preventDefault(); |
279 | 277 | $options = array |
@@ -200,7 +200,7 @@ |
||
200 | 200 | break; |
201 | 201 | } |
202 | 202 | if ( $default !== null |
203 | - // we need to skip working links because in this case, Doctrine expects objects as values |
|
203 | + // we need to skip working links because in this case, Doctrine expects objects as values |
|
204 | 204 | && ( !$property->link |
205 | 205 | || $this->manager->resolve_targetclass($property) === false)) |
206 | 206 | { |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | $types = $this->manager->get_types(); |
70 | 70 | uasort($types, function($a, $b) |
71 | 71 | { |
72 | - if ( !empty($a->extends) |
|
72 | + if (!empty($a->extends) |
|
73 | 73 | && !empty($b->extends)) |
74 | 74 | { |
75 | 75 | return strnatcmp($a->extends, $b->extends); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | |
119 | 119 | foreach ($this->manager->get_types() as $type) |
120 | 120 | { |
121 | - if ( $prefix !== '' |
|
121 | + if ($prefix !== '' |
|
122 | 122 | && !class_exists($type->name)) |
123 | 123 | { |
124 | 124 | $this->add_line('class_alias( "' . $prefix . $type->name . '", "' . $type->name . '");'); |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | foreach ($this->manager->get_inherited_mapping() as $child => $parent) |
129 | 129 | { |
130 | 130 | $this->add_line('class_alias( "' . $prefix . $parent . '", "' . $prefix . $child . '");'); |
131 | - if ( $prefix !== '' |
|
131 | + if ($prefix !== '' |
|
132 | 132 | && !class_exists($child)) |
133 | 133 | { |
134 | 134 | $this->add_line('class_alias( "' . $prefix . $parent . '", "' . $child . '");'); |
@@ -199,9 +199,9 @@ discard block |
||
199 | 199 | $objects[$name] = 'new midgard_datetime("0001-01-01 00:00:00")'; |
200 | 200 | break; |
201 | 201 | } |
202 | - if ( $default !== null |
|
202 | + if ($default !== null |
|
203 | 203 | // we need to skip working links because in this case, Doctrine expects objects as values |
204 | - && ( !$property->link |
|
204 | + && (!$property->link |
|
205 | 205 | || $this->manager->resolve_targetclass($property) === false)) |
206 | 206 | { |
207 | 207 | $line .= ' = ' . $default; |
@@ -52,8 +52,7 @@ discard block |
||
52 | 52 | if ($this->dev_mode) |
53 | 53 | { |
54 | 54 | $this->output .= "\n"; |
55 | - } |
|
56 | - else |
|
55 | + } else |
|
57 | 56 | { |
58 | 57 | $this->output .= ' '; |
59 | 58 | } |
@@ -73,12 +72,10 @@ discard block |
||
73 | 72 | && !empty($b->extends)) |
74 | 73 | { |
75 | 74 | return strnatcmp($a->extends, $b->extends); |
76 | - } |
|
77 | - else if (!empty($a->extends)) |
|
75 | + } else if (!empty($a->extends)) |
|
78 | 76 | { |
79 | 77 | return -1; |
80 | - } |
|
81 | - else if (!empty($b->extends)) |
|
78 | + } else if (!empty($b->extends)) |
|
82 | 79 | { |
83 | 80 | return 1; |
84 | 81 | } |
@@ -20,8 +20,7 @@ discard block |
||
20 | 20 | |
21 | 21 | class driver implements driver_interface |
22 | 22 | { |
23 | - private $dbtypemap = array |
|
24 | - ( |
|
23 | + private $dbtypemap = array( |
|
25 | 24 | 'unsigned integer' => array('type' => dtype::INTEGER, 'default' => 0), // <== UNSIGNED in Doctrine\DBAL\Schema\Column |
26 | 25 | 'integer' => array('type' => dtype::INTEGER, 'default' => 0), |
27 | 26 | 'boolean' => array('type' => dtype::BOOLEAN, 'default' => false), |
@@ -145,11 +144,9 @@ discard block |
||
145 | 144 | |
146 | 145 | // TODO: extends |
147 | 146 | |
148 | - $table = array |
|
149 | - ( |
|
147 | + $table = array( |
|
150 | 148 | 'name' => $type->table, |
151 | - 'options' => array |
|
152 | - ( |
|
149 | + 'options' => array( |
|
153 | 150 | //Doctrine's default on MySQL is InnoDB, and the foreign keys don't play well with Midgard logic |
154 | 151 | //TODO: Maybe at some point we could try to figure out how to explicitly disable foreign key constraint creation instead |
155 | 152 | 'engine' => 'MyISAM' |
@@ -167,17 +164,14 @@ discard block |
||
167 | 164 | foreach ($type->get_properties() as $name => $property) |
168 | 165 | { |
169 | 166 | // doctrine can handle id links only |
170 | - if ( $property->link |
|
167 | + if ($property->link |
|
171 | 168 | && $target_class = $this->manager->resolve_targetclass($property)) |
172 | 169 | { |
173 | - $link_mapping = array |
|
174 | - ( |
|
170 | + $link_mapping = array( |
|
175 | 171 | 'fieldName' => $property->name, |
176 | 172 | 'targetEntity' => $target_class, |
177 | - 'joinColumns' => array |
|
178 | - ( |
|
179 | - array |
|
180 | - ( |
|
173 | + 'joinColumns' => array( |
|
174 | + array( |
|
181 | 175 | 'name' => $property->field, |
182 | 176 | 'referencedColumnName' => $property->link['field'] |
183 | 177 | ) |
@@ -260,8 +254,7 @@ discard block |
||
260 | 254 | { |
261 | 255 | if (strpos($property->dbtype, 'varchar') === 0) |
262 | 256 | { |
263 | - $mapping = array |
|
264 | - ( |
|
257 | + $mapping = array( |
|
265 | 258 | 'type' => dtype::STRING, |
266 | 259 | ); |
267 | 260 |
@@ -69,8 +69,7 @@ discard block |
||
69 | 69 | { |
70 | 70 | $this->manager = new manager($schemadirs, $this->namespace); |
71 | 71 | self::$processed_namespaces[$this->namespace] = array("manager" => $this->manager); |
72 | - } |
|
73 | - else |
|
72 | + } else |
|
74 | 73 | { |
75 | 74 | // reuse manager instance |
76 | 75 | $this->manager = self::$processed_namespaces[$this->namespace]["manager"]; |
@@ -198,8 +197,7 @@ discard block |
||
198 | 197 | if (empty($this->dbtypemap[$property->dbtype])) |
199 | 198 | { |
200 | 199 | $mapping = $this->parse_dbtype($property); |
201 | - } |
|
202 | - else |
|
200 | + } else |
|
203 | 201 | { |
204 | 202 | $mapping = $this->dbtypemap[$property->dbtype]; |
205 | 203 | } |
@@ -209,8 +207,7 @@ discard block |
||
209 | 207 | if ($property->name == 'guid') |
210 | 208 | { |
211 | 209 | $mapping['unique'] = true; |
212 | - } |
|
213 | - else |
|
210 | + } else |
|
214 | 211 | { |
215 | 212 | //we can't set this as a real DB constraint because of softdelete and tree hierarchies |
216 | 213 | $metadata->midgard['unique_fields'][] = $property->name; |
@@ -234,8 +231,7 @@ discard block |
||
234 | 231 | if ($mapping['type'] == dtype::INTEGER) |
235 | 232 | { |
236 | 233 | $metadata->setIdGeneratorType(CM::GENERATOR_TYPE_AUTO); |
237 | - } |
|
238 | - else |
|
234 | + } else |
|
239 | 235 | { |
240 | 236 | $metadata->setIdGeneratorType(CM::GENERATOR_TYPE_NONE); |
241 | 237 | } |
@@ -278,8 +274,7 @@ discard block |
||
278 | 274 | $mapping['comment'] = 'BINARY'; |
279 | 275 | return $mapping; |
280 | 276 | } |
281 | - } |
|
282 | - else if (strpos($property->dbtype, 'set') === 0) |
|
277 | + } else if (strpos($property->dbtype, 'set') === 0) |
|
283 | 278 | { |
284 | 279 | // see http://docs.doctrine-project.org/en/latest/cookbook/mysql-enums.html |
285 | 280 | if (!empty($this->dbtypemap[$property->type])) |
@@ -10,8 +10,7 @@ |
||
10 | 10 | |
11 | 11 | class classmetadata extends base_metadata |
12 | 12 | { |
13 | - public $midgard = array |
|
14 | - ( |
|
13 | + public $midgard = array( |
|
15 | 14 | 'parent' => null, |
16 | 15 | 'parentfield' => null, |
17 | 16 | 'upfield' => null, |