@@ -31,6 +31,9 @@ |
||
31 | 31 | return null; |
32 | 32 | } |
33 | 33 | |
34 | + /** |
|
35 | + * @param string $content |
|
36 | + */ |
|
34 | 37 | public function write_content($content) |
35 | 38 | { |
36 | 39 | return file_put_contents($this->get_path(), $content) !== false; |
@@ -201,19 +201,19 @@ |
||
201 | 201 | break; |
202 | 202 | } |
203 | 203 | |
204 | - if ( $dbobject->id > 0 |
|
204 | + if ($dbobject->id > 0 |
|
205 | 205 | && $dbobject->metadata->revised >= $object->metadata->revised) { |
206 | 206 | midgard_connection::get_instance()->set_error(exception::OBJECT_IMPORTED); |
207 | 207 | return false; |
208 | 208 | } |
209 | 209 | |
210 | - if ( $dbobject->metadata->deleted |
|
210 | + if ($dbobject->metadata->deleted |
|
211 | 211 | && !$object->metadata->deleted) { |
212 | 212 | if (!midgard_object_class::undelete($dbobject->guid)) { |
213 | 213 | return false; |
214 | 214 | } |
215 | 215 | $dbobject->metadata_deleted = false; |
216 | - } elseif ( !$dbobject->metadata->deleted |
|
216 | + } elseif (!$dbobject->metadata->deleted |
|
217 | 217 | && $object->metadata->deleted) { |
218 | 218 | return $dbobject->delete(); |
219 | 219 | } |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | } |
241 | 241 | |
242 | 242 | /** |
243 | - * @return boolean Indicating success |
|
243 | + * @return boolean|null Indicating success |
|
244 | 244 | */ |
245 | 245 | public static function import_from_xml($xml, $force = false) |
246 | 246 | { |
@@ -264,6 +264,9 @@ discard block |
||
264 | 264 | $blob->write_content($blob->content); |
265 | 265 | } |
266 | 266 | |
267 | + /** |
|
268 | + * @return string|null |
|
269 | + */ |
|
267 | 270 | private static function resolve_link_id(ClassMetadata $cm, dbobject $object, $name) |
268 | 271 | { |
269 | 272 | if ($object->$name == 0) { |
@@ -339,7 +342,7 @@ discard block |
||
339 | 342 | * |
340 | 343 | * @param SimpleXMLElement $node |
341 | 344 | * @param boolean $force |
342 | - * @return dbobject |
|
345 | + * @return blob |
|
343 | 346 | */ |
344 | 347 | private static function blob_from_xml(SimpleXMLElement $node, $force) |
345 | 348 | { |
@@ -350,6 +353,9 @@ discard block |
||
350 | 353 | return $blob; |
351 | 354 | } |
352 | 355 | |
356 | + /** |
|
357 | + * @param string $guid |
|
358 | + */ |
|
353 | 359 | private static function get_object_action($guid) |
354 | 360 | { |
355 | 361 | $result = connection::get_em() |
@@ -376,6 +382,9 @@ discard block |
||
376 | 382 | } |
377 | 383 | } |
378 | 384 | |
385 | + /** |
|
386 | + * @return string|null |
|
387 | + */ |
|
379 | 388 | private static function convert_value($value) |
380 | 389 | { |
381 | 390 | if ($value instanceof midgard_datetime) { |
@@ -213,7 +213,7 @@ |
||
213 | 213 | $midgard = midgard_connection::get_instance(); |
214 | 214 | if ($midgard->config->logfilename) { |
215 | 215 | $logdir = dirname($midgard->config->logfilename); |
216 | - if ( !is_dir($logdir) |
|
216 | + if (!is_dir($logdir) |
|
217 | 217 | && !mkdir($logdir, 0777, true)) { |
218 | 218 | throw exception::user_data('Log directory could not be created'); |
219 | 219 | } |
@@ -123,6 +123,7 @@ discard block |
||
123 | 123 | |
124 | 124 | /** |
125 | 125 | * Toggle autostart |
126 | + * @param boolean $autostart |
|
126 | 127 | */ |
127 | 128 | public static function set_autostart($autostart) |
128 | 129 | { |
@@ -156,6 +157,9 @@ discard block |
||
156 | 157 | } |
157 | 158 | } |
158 | 159 | |
160 | + /** |
|
161 | + * @param string $name |
|
162 | + */ |
|
159 | 163 | public static function get_parameter($name) |
160 | 164 | { |
161 | 165 | if (!array_key_exists($name, self::$parameters)) { |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | $mgd_config = midgard_connection::get_instance()->config; |
57 | 57 | $mgdschema_file = $mgd_config->vardir . '/mgdschema_classes.php'; |
58 | - if ( file_exists($mgdschema_file) |
|
58 | + if (file_exists($mgdschema_file) |
|
59 | 59 | && !unlink($mgdschema_file)) { |
60 | 60 | throw new \RuntimeException('Could not unlink ' . $mgdschema_file); |
61 | 61 | } |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | $cms = $em->getMetadataFactory()->getAllMetadata(); |
73 | 73 | |
74 | 74 | // create storage |
75 | - if ( !midgard_storage::create_base_storage() |
|
75 | + if (!midgard_storage::create_base_storage() |
|
76 | 76 | && midgard_connection::get_instance()->get_error_string() != 'MGD_ERR_OK') { |
77 | 77 | throw new \Exception("Failed to create base database structures" . midgard_connection::get_instance()->get_error_string()); |
78 | 78 | } |
@@ -56,6 +56,9 @@ discard block |
||
56 | 56 | return true; |
57 | 57 | } |
58 | 58 | |
59 | + /** |
|
60 | + * @param string $classname |
|
61 | + */ |
|
59 | 62 | public static function create_class_storage($classname) |
60 | 63 | { |
61 | 64 | $em = connection::get_em(); |
@@ -87,6 +90,11 @@ discard block |
||
87 | 90 | $generator->generateProxyClass($cm, $filename); |
88 | 91 | } |
89 | 92 | |
93 | + /** |
|
94 | + * @param Doctrine\ORM\EntityManager $em |
|
95 | + * |
|
96 | + * @return ClassMetadata |
|
97 | + */ |
|
90 | 98 | private static function get_cm($em, $classname) |
91 | 99 | { |
92 | 100 | if (!class_exists($classname)) { |
@@ -29,6 +29,9 @@ |
||
29 | 29 | |
30 | 30 | private $replication_enabled = true; |
31 | 31 | |
32 | + /** |
|
33 | + * @return integer |
|
34 | + */ |
|
32 | 35 | public static function get_instance() |
33 | 36 | { |
34 | 37 | if (self::$instance === null) { |
@@ -96,6 +96,9 @@ |
||
96 | 96 | return true; |
97 | 97 | } |
98 | 98 | |
99 | + /** |
|
100 | + * @param string $guid |
|
101 | + */ |
|
99 | 102 | public static function get_object_by_guid($guid) |
100 | 103 | { |
101 | 104 | if (!mgd_is_guid($guid)) { |
@@ -19,6 +19,9 @@ |
||
19 | 19 | } |
20 | 20 | } |
21 | 21 | |
22 | + /** |
|
23 | + * @param string $operator |
|
24 | + */ |
|
22 | 25 | public function add_constraint($name, $operator, $value) |
23 | 26 | { |
24 | 27 | try { |
@@ -30,6 +30,9 @@ discard block |
||
30 | 30 | public $cachedir = '/var/cache/midgard2'; |
31 | 31 | public $gdathreads = false; |
32 | 32 | |
33 | + /** |
|
34 | + * @param string $path |
|
35 | + */ |
|
33 | 36 | public function read_file_at_path($path) |
34 | 37 | { |
35 | 38 | if ( !file_exists($path) |
@@ -122,6 +125,9 @@ discard block |
||
122 | 125 | return true; |
123 | 126 | } |
124 | 127 | |
128 | + /** |
|
129 | + * @param string $key |
|
130 | + */ |
|
125 | 131 | private function convert_to_storage($key, $value) |
126 | 132 | { |
127 | 133 | if (is_bool($value)) { |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | public function read_file_at_path($path) |
34 | 34 | { |
35 | - if ( !file_exists($path) |
|
35 | + if (!file_exists($path) |
|
36 | 36 | || !is_readable($path)) { |
37 | 37 | return false; |
38 | 38 | } |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | $subdirs = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'A', 'B', 'C', 'D', 'E', 'F']; |
146 | 146 | foreach ($subdirs as $dir) { |
147 | 147 | foreach ($subdirs as $subdir) { |
148 | - if ( !is_dir($this->blobdir . '/' . $dir . '/' . $subdir) |
|
148 | + if (!is_dir($this->blobdir . '/' . $dir . '/' . $subdir) |
|
149 | 149 | && !mkdir($this->blobdir . '/' . $dir . '/' . $subdir, 0777, true)) { |
150 | 150 | return false; |
151 | 151 | } |