@@ -25,6 +25,9 @@ |
||
| 25 | 25 | |
| 26 | 26 | private $value_properties = array(); |
| 27 | 27 | |
| 28 | + /** |
|
| 29 | + * @param string $class |
|
| 30 | + */ |
|
| 28 | 31 | function __construct($class, $field, $value) |
| 29 | 32 | { |
| 30 | 33 | parent::__construct($class); |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | $parsed = $this->parse_constraint_name($property); |
| 71 | 71 | |
| 72 | 72 | // for properties like up.name |
| 73 | - if ( strpos($property, ".") !== false |
|
| 73 | + if (strpos($property, ".") !== false |
|
| 74 | 74 | && !(strpos($property, "metadata") === 0)) |
| 75 | 75 | { |
| 76 | 76 | return $parsed['name'] . " as " . str_replace(".", "_", $property); |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | public function get($key) |
| 156 | 156 | { |
| 157 | - if ( !$this->_has_results() |
|
| 157 | + if (!$this->_has_results() |
|
| 158 | 158 | || !isset($this->_results[$key])) |
| 159 | 159 | { |
| 160 | 160 | return false; |
@@ -53,8 +53,7 @@ discard block |
||
| 53 | 53 | try |
| 54 | 54 | { |
| 55 | 55 | $property_select = $this->build_property_select($property); |
| 56 | - } |
|
| 57 | - catch (exception $e) |
|
| 56 | + } catch (exception $e) |
|
| 58 | 57 | { |
| 59 | 58 | return false; |
| 60 | 59 | } |
@@ -103,8 +102,7 @@ discard block |
||
| 103 | 102 | try |
| 104 | 103 | { |
| 105 | 104 | $properties[] = $this->build_property_select($this->key_property); |
| 106 | - } |
|
| 107 | - catch (exception $e) |
|
| 105 | + } catch (exception $e) |
|
| 108 | 106 | { |
| 109 | 107 | throw new exception('Property "' . $this->key_property . '" not found in "' . $this->classname . '"', exception::INVALID_PROPERTY); |
| 110 | 108 | } |
@@ -37,6 +37,9 @@ |
||
| 37 | 37 | //?? |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | + /** |
|
| 41 | + * @return integer |
|
| 42 | + */ |
|
| 40 | 43 | public static function get_instance() |
| 41 | 44 | { |
| 42 | 45 | if (self::$instance === null) |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | return is_object($this->config); |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | - public function connect($signal, $callback, $userdata = '???' ) |
|
| 87 | + public function connect($signal, $callback, $userdata = '???') |
|
| 88 | 88 | { |
| 89 | 89 | |
| 90 | 90 | } |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | return connection::get_user(); |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - public function set_loglevel($level, $callback = '???' ) |
|
| 126 | + public function set_loglevel($level, $callback = '???') |
|
| 127 | 127 | { |
| 128 | 128 | if (!in_array($level, $this->available_loglevels)) |
| 129 | 129 | { |
@@ -106,6 +106,9 @@ |
||
| 106 | 106 | return true; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | + /** |
|
| 110 | + * @param string $guid |
|
| 111 | + */ |
|
| 109 | 112 | public static function get_object_by_guid($guid) |
| 110 | 113 | { |
| 111 | 114 | if (!mgd_is_guid($guid)) |
@@ -37,7 +37,7 @@ |
||
| 37 | 37 | { |
| 38 | 38 | throw exception::object_purged(); |
| 39 | 39 | } |
| 40 | - if ( !$include_deleted |
|
| 40 | + if (!$include_deleted |
|
| 41 | 41 | && $result["object_action"] == subscriber::ACTION_DELETE) |
| 42 | 42 | { |
| 43 | 43 | throw exception::object_deleted(); |
@@ -24,8 +24,7 @@ discard block |
||
| 24 | 24 | try |
| 25 | 25 | { |
| 26 | 26 | $result = $qb->getQuery()->getSingleResult(); |
| 27 | - } |
|
| 28 | - catch (\Doctrine\ORM\NoResultException $e) |
|
| 27 | + } catch (\Doctrine\ORM\NoResultException $e) |
|
| 29 | 28 | { |
| 30 | 29 | $result = null; |
| 31 | 30 | } |
@@ -67,8 +66,7 @@ discard block |
||
| 67 | 66 | try |
| 68 | 67 | { |
| 69 | 68 | $classname = self::resolve_classname($guid, true); |
| 70 | - } |
|
| 71 | - catch (exception $e) |
|
| 69 | + } catch (exception $e) |
|
| 72 | 70 | { |
| 73 | 71 | return false; |
| 74 | 72 | } |
@@ -95,8 +93,7 @@ discard block |
||
| 95 | 93 | { |
| 96 | 94 | $om = new objectmanager(connection::get_em()); |
| 97 | 95 | $om->undelete($entity); |
| 98 | - } |
|
| 99 | - catch (\Exception $e) |
|
| 96 | + } catch (\Exception $e) |
|
| 100 | 97 | { |
| 101 | 98 | exception::internal($e); |
| 102 | 99 | return false; |
@@ -22,6 +22,9 @@ |
||
| 22 | 22 | } |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | + /** |
|
| 26 | + * @param string $operator |
|
| 27 | + */ |
|
| 25 | 28 | public function add_constraint($name, $operator, $value) |
| 26 | 29 | { |
| 27 | 30 | try |
@@ -15,8 +15,7 @@ discard block |
||
| 15 | 15 | try |
| 16 | 16 | { |
| 17 | 17 | return parent::add_constraint_with_property($name, $operator, $value); |
| 18 | - } |
|
| 19 | - catch (exception $e) |
|
| 18 | + } catch (exception $e) |
|
| 20 | 19 | { |
| 21 | 20 | return false; |
| 22 | 21 | } |
@@ -27,8 +26,7 @@ discard block |
||
| 27 | 26 | try |
| 28 | 27 | { |
| 29 | 28 | return parent::add_constraint($name, $operator, $value); |
| 30 | - } |
|
| 31 | - catch (exception $e) |
|
| 29 | + } catch (exception $e) |
|
| 32 | 30 | { |
| 33 | 31 | return false; |
| 34 | 32 | } |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | /** |
| 277 | - * @return boolean Indicating success |
|
| 277 | + * @return boolean|null Indicating success |
|
| 278 | 278 | */ |
| 279 | 279 | public static function import_from_xml($xml, $force = false) |
| 280 | 280 | { |
@@ -302,6 +302,9 @@ discard block |
||
| 302 | 302 | $blob->write_content($blob->content); |
| 303 | 303 | } |
| 304 | 304 | |
| 305 | + /** |
|
| 306 | + * @return string|null |
|
| 307 | + */ |
|
| 305 | 308 | private static function resolve_link_id(ClassMetadata $cm, dbobject $object, $name) |
| 306 | 309 | { |
| 307 | 310 | if ($object->$name == 0) |
@@ -387,7 +390,7 @@ discard block |
||
| 387 | 390 | * |
| 388 | 391 | * @param SimpleXMLElement $node |
| 389 | 392 | * @param boolean $force |
| 390 | - * @return dbobject |
|
| 393 | + * @return blob |
|
| 391 | 394 | */ |
| 392 | 395 | private static function blob_from_xml(SimpleXMLElement $node, $force) |
| 393 | 396 | { |
@@ -398,6 +401,9 @@ discard block |
||
| 398 | 401 | return $blob; |
| 399 | 402 | } |
| 400 | 403 | |
| 404 | + /** |
|
| 405 | + * @param string $guid |
|
| 406 | + */ |
|
| 401 | 407 | private static function get_object_action($guid) |
| 402 | 408 | { |
| 403 | 409 | $result = connection::get_em() |
@@ -425,6 +431,9 @@ discard block |
||
| 425 | 431 | } |
| 426 | 432 | } |
| 427 | 433 | |
| 434 | + /** |
|
| 435 | + * @return string|null |
|
| 436 | + */ |
|
| 428 | 437 | private static function convert_value($value) |
| 429 | 438 | { |
| 430 | 439 | if ($value instanceof midgard_datetime) |
@@ -15,7 +15,6 @@ |
||
| 15 | 15 | use Doctrine\Common\Persistence\Mapping\ClassMetadata; |
| 16 | 16 | use midgard\portable\api\error\exception; |
| 17 | 17 | use midgard\portable\api\blob; |
| 18 | -use midgard\portable\storage\objectmanager; |
|
| 19 | 18 | use Doctrine\ORM\NoResultException; |
| 20 | 19 | |
| 21 | 20 | class midgard_replicator |
@@ -225,14 +225,14 @@ discard block |
||
| 225 | 225 | break; |
| 226 | 226 | } |
| 227 | 227 | |
| 228 | - if ( $dbobject->id > 0 |
|
| 228 | + if ($dbobject->id > 0 |
|
| 229 | 229 | && $dbobject->metadata->revised >= $object->metadata->revised) |
| 230 | 230 | { |
| 231 | 231 | midgard_connection::get_instance()->set_error(exception::OBJECT_IMPORTED); |
| 232 | 232 | return false; |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | - if ( $dbobject->metadata->deleted |
|
| 235 | + if ($dbobject->metadata->deleted |
|
| 236 | 236 | && !$object->metadata->deleted) |
| 237 | 237 | { |
| 238 | 238 | if (!midgard_object_class::undelete($dbobject->guid)) |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | } |
| 242 | 242 | $dbobject->metadata_deleted = false; |
| 243 | 243 | } |
| 244 | - else if ( !$dbobject->metadata->deleted |
|
| 244 | + else if (!$dbobject->metadata->deleted |
|
| 245 | 245 | && $object->metadata->deleted) |
| 246 | 246 | { |
| 247 | 247 | return $dbobject->delete(); |
@@ -112,8 +112,7 @@ discard block |
||
| 112 | 112 | if (strpos($name, 'metadata_') === 0) |
| 113 | 113 | { |
| 114 | 114 | $metadata[substr($name, 9)] = $object->$name; |
| 115 | - } |
|
| 116 | - else |
|
| 115 | + } else |
|
| 117 | 116 | { |
| 118 | 117 | $node->addChild($name, self::convert_value($object->$name)); |
| 119 | 118 | } |
@@ -159,13 +158,11 @@ discard block |
||
| 159 | 158 | if ($node->getName() == 'midgard_blob') |
| 160 | 159 | { |
| 161 | 160 | $ret[] = self::blob_from_xml($node, $force); |
| 162 | - } |
|
| 163 | - else |
|
| 161 | + } else |
|
| 164 | 162 | { |
| 165 | 163 | $ret[] = self::object_from_xml($node, $force); |
| 166 | 164 | } |
| 167 | - } |
|
| 168 | - catch (\Exception $e) |
|
| 165 | + } catch (\Exception $e) |
|
| 169 | 166 | { |
| 170 | 167 | connection::log()->warning($e->getMessage()); |
| 171 | 168 | } |
@@ -240,8 +237,7 @@ discard block |
||
| 240 | 237 | return false; |
| 241 | 238 | } |
| 242 | 239 | $dbobject->metadata_deleted = false; |
| 243 | - } |
|
| 244 | - else if ( !$dbobject->metadata->deleted |
|
| 240 | + } else if ( !$dbobject->metadata->deleted |
|
| 245 | 241 | && $object->metadata->deleted) |
| 246 | 242 | { |
| 247 | 243 | return $dbobject->delete(); |
@@ -284,8 +280,7 @@ discard block |
||
| 284 | 280 | if ($object instanceof blob) |
| 285 | 281 | { |
| 286 | 282 | self::import_blob($object, $force); |
| 287 | - } |
|
| 288 | - else |
|
| 283 | + } else |
|
| 289 | 284 | { |
| 290 | 285 | self::import_object($object, $force); |
| 291 | 286 | } |
@@ -367,8 +362,7 @@ discard block |
||
| 367 | 362 | try |
| 368 | 363 | { |
| 369 | 364 | $value = self::resolve_link_guid($cm, $field, $value); |
| 370 | - } |
|
| 371 | - catch (NoResultException $e) |
|
| 365 | + } catch (NoResultException $e) |
|
| 372 | 366 | { |
| 373 | 367 | if (!$force) |
| 374 | 368 | { |
@@ -61,6 +61,9 @@ discard block |
||
| 61 | 61 | return true; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | + /** |
|
| 65 | + * @param string $classname |
|
| 66 | + */ |
|
| 64 | 67 | public static function create_class_storage($classname) |
| 65 | 68 | { |
| 66 | 69 | $em = connection::get_em(); |
@@ -95,6 +98,11 @@ discard block |
||
| 95 | 98 | $generator->generateProxyClass($cm, $filename); |
| 96 | 99 | } |
| 97 | 100 | |
| 101 | + /** |
|
| 102 | + * @param Doctrine\ORM\EntityManagerInterface $em |
|
| 103 | + * |
|
| 104 | + * @return ClassMetadata |
|
| 105 | + */ |
|
| 98 | 106 | private static function get_cm($em, $classname) |
| 99 | 107 | { |
| 100 | 108 | if (!class_exists($classname)) |
@@ -107,16 +107,14 @@ |
||
| 107 | 107 | try |
| 108 | 108 | { |
| 109 | 109 | return $factory->getMetadataFor($classname); |
| 110 | - } |
|
| 111 | - catch (MappingException $e) |
|
| 110 | + } catch (MappingException $e) |
|
| 112 | 111 | { |
| 113 | 112 | // add namespace |
| 114 | 113 | $classname = $em->getConfiguration()->getEntityNamespace("midgard") . '\\' . $classname; |
| 115 | 114 | try |
| 116 | 115 | { |
| 117 | 116 | return $factory->getMetadataFor($classname); |
| 118 | - } |
|
| 119 | - catch (MappingException $e) |
|
| 117 | + } catch (MappingException $e) |
|
| 120 | 118 | { |
| 121 | 119 | // check for merged classes (duplicate tablenames) |
| 122 | 120 | $classname = get_class(new $classname); |
@@ -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; |
@@ -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) |
@@ -136,6 +139,9 @@ discard block |
||
| 136 | 139 | return true; |
| 137 | 140 | } |
| 138 | 141 | |
| 142 | + /** |
|
| 143 | + * @param string $key |
|
| 144 | + */ |
|
| 139 | 145 | private function convert_to_storage($key, $value) |
| 140 | 146 | { |
| 141 | 147 | 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 | { |
| 38 | 38 | return false; |
@@ -47,8 +47,7 @@ discard block |
||
| 47 | 47 | // TODO: find out if this could be moved to read_data() |
| 48 | 48 | private function apply_config(array $config) |
| 49 | 49 | { |
| 50 | - $mapping = array |
|
| 51 | - ( |
|
| 50 | + $mapping = array( |
|
| 52 | 51 | 'type' => 'dbtype', |
| 53 | 52 | 'name' => 'database', |
| 54 | 53 | 'username' => 'dbuser', |
@@ -166,7 +165,7 @@ discard block |
||
| 166 | 165 | { |
| 167 | 166 | foreach ($subdirs as $subdir) |
| 168 | 167 | { |
| 169 | - if ( !is_dir($this->blobdir . '/' . $dir . '/' . $subdir) |
|
| 168 | + if (!is_dir($this->blobdir . '/' . $dir . '/' . $subdir) |
|
| 170 | 169 | && !mkdir($this->blobdir . '/' . $dir . '/' . $subdir, 0777, true)) |
| 171 | 170 | { |
| 172 | 171 | return false; |
@@ -80,8 +80,7 @@ discard block |
||
| 80 | 80 | if (!$user) |
| 81 | 81 | { |
| 82 | 82 | $prefix = '/etc/midgard2/conf.d'; |
| 83 | - } |
|
| 84 | - else |
|
| 83 | + } else |
|
| 85 | 84 | { |
| 86 | 85 | $prefix = getenv('HOME') . '/.midgard2/conf.d'; |
| 87 | 86 | } |
@@ -93,8 +92,7 @@ discard block |
||
| 93 | 92 | if (!$user) |
| 94 | 93 | { |
| 95 | 94 | $prefix = '/etc/midgard2/conf.d'; |
| 96 | - } |
|
| 97 | - else |
|
| 95 | + } else |
|
| 98 | 96 | { |
| 99 | 97 | $prefix = getenv('HOME') . '/.midgard2/conf.d'; |
| 100 | 98 | } |
@@ -141,8 +139,7 @@ discard block |
||
| 141 | 139 | if (is_bool($value)) |
| 142 | 140 | { |
| 143 | 141 | $value = ($value) ? 'true' : 'false'; |
| 144 | - } |
|
| 145 | - else if ($value === '') |
|
| 142 | + } else if ($value === '') |
|
| 146 | 143 | { |
| 147 | 144 | $value = '""'; |
| 148 | 145 | } |
@@ -64,6 +64,9 @@ discard block |
||
| 64 | 64 | parent::__set($field, $value); |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | + /** |
|
| 68 | + * @param string $field |
|
| 69 | + */ |
|
| 67 | 70 | public function __get($field) |
| 68 | 71 | { |
| 69 | 72 | if ( $field === 'metadata' |
@@ -111,6 +114,9 @@ discard block |
||
| 111 | 114 | return null; |
| 112 | 115 | } |
| 113 | 116 | |
| 117 | + /** |
|
| 118 | + * @param integer $id |
|
| 119 | + */ |
|
| 114 | 120 | public function get_by_id($id) |
| 115 | 121 | { |
| 116 | 122 | $entity = connection::get_em()->find(get_class($this), $id); |
@@ -151,6 +157,9 @@ discard block |
||
| 151 | 157 | return true; |
| 152 | 158 | } |
| 153 | 159 | |
| 160 | + /** |
|
| 161 | + * @param string $guid |
|
| 162 | + */ |
|
| 154 | 163 | public function get_by_guid($guid) |
| 155 | 164 | { |
| 156 | 165 | if (!mgd_is_guid($guid)) |
@@ -526,7 +535,8 @@ discard block |
||
| 526 | 535 | } |
| 527 | 536 | |
| 528 | 537 | /** |
| 529 | - * @return int |
|
| 538 | + * @param integer $up |
|
| 539 | + * @return \Doctrine\ORM\QueryBuilder |
|
| 530 | 540 | */ |
| 531 | 541 | protected function get_uniquefield_query($classname, $field, $part, $upfield, $up) |
| 532 | 542 | { |
@@ -619,6 +629,9 @@ discard block |
||
| 619 | 629 | } |
| 620 | 630 | } |
| 621 | 631 | |
| 632 | + /** |
|
| 633 | + * @param string $value |
|
| 634 | + */ |
|
| 622 | 635 | public function set_parameter($domain, $name, $value) |
| 623 | 636 | { |
| 624 | 637 | $constraints = array |
@@ -712,7 +725,7 @@ discard block |
||
| 712 | 725 | * |
| 713 | 726 | * @param array $constraints |
| 714 | 727 | * @param boolean $delete_blob |
| 715 | - * @return boolean False if one or more attachments couldn't be deleted |
|
| 728 | + * @return integer False if one or more attachments couldn't be deleted |
|
| 716 | 729 | * @todo Implement delete_blob & return value |
| 717 | 730 | */ |
| 718 | 731 | public function purge_attachments(array $constraints = array(), $delete_blob = true) |
@@ -817,6 +830,9 @@ discard block |
||
| 817 | 830 | return new \midgard_reflection_property(get_called_class()); |
| 818 | 831 | } |
| 819 | 832 | |
| 833 | + /** |
|
| 834 | + * @param string $guid |
|
| 835 | + */ |
|
| 820 | 836 | public function set_guid($guid) |
| 821 | 837 | { |
| 822 | 838 | parent::__set('guid', $guid); |
@@ -829,8 +845,8 @@ discard block |
||
| 829 | 845 | |
| 830 | 846 | /** |
| 831 | 847 | * helper function for managing the isapproved and islocked metadata properties |
| 832 | - * @param string $propertyName the property to manage (either isapproved or islocked) |
|
| 833 | - * @param bool $newval |
|
| 848 | + * @param string $action |
|
| 849 | + * @param boolean $value |
|
| 834 | 850 | * @return boolean |
| 835 | 851 | */ |
| 836 | 852 | private function manage_meta_property($action, $value) |
@@ -883,7 +883,7 @@ |
||
| 883 | 883 | |
| 884 | 884 | public function approve() |
| 885 | 885 | { |
| 886 | - return $this->manage_meta_property("approve", true); |
|
| 886 | + return $this->manage_meta_property("approve", true); |
|
| 887 | 887 | } |
| 888 | 888 | |
| 889 | 889 | public function is_approved() |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | public function __get($field) |
| 68 | 68 | { |
| 69 | - if ( $field === 'metadata' |
|
| 69 | + if ($field === 'metadata' |
|
| 70 | 70 | && property_exists($this, 'metadata') |
| 71 | 71 | && $this->metadata === null) |
| 72 | 72 | { |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | if ($this->$candidate !== null) |
| 93 | 93 | { |
| 94 | 94 | //Proxies become stale if the object itself is detached, so we have to re-fetch |
| 95 | - if ( $this->$candidate instanceof \Doctrine\ORM\Proxy\Proxy |
|
| 95 | + if ($this->$candidate instanceof \Doctrine\ORM\Proxy\Proxy |
|
| 96 | 96 | && $this->$candidate->__isInitialized()) |
| 97 | 97 | { |
| 98 | 98 | try |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | } |
| 122 | 122 | // According to Doctrine documentation, proxies should be transparent, but in practice, |
| 123 | 123 | // there will be problems if we don't force-load |
| 124 | - if ( $entity instanceof \Doctrine\ORM\Proxy\Proxy |
|
| 124 | + if ($entity instanceof \Doctrine\ORM\Proxy\Proxy |
|
| 125 | 125 | && !$entity->__isInitialized()) |
| 126 | 126 | { |
| 127 | 127 | try |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | exception::duplicate(); |
| 177 | 177 | return false; |
| 178 | 178 | } |
| 179 | - if ( !$this->is_unique() |
|
| 179 | + if (!$this->is_unique() |
|
| 180 | 180 | || !$this->check_parent()) |
| 181 | 181 | { |
| 182 | 182 | return false; |
@@ -238,7 +238,7 @@ discard block |
||
| 238 | 238 | midgard_connection::get_instance()->set_error(MGD_ERR_INVALID_PROPERTY_VALUE); |
| 239 | 239 | return false; |
| 240 | 240 | } |
| 241 | - if ( $check_dependencies |
|
| 241 | + if ($check_dependencies |
|
| 242 | 242 | && $this->has_dependents()) |
| 243 | 243 | { |
| 244 | 244 | exception::has_dependants(); |
@@ -282,8 +282,7 @@ discard block |
||
| 282 | 282 | $conditions = $qb->expr()->andX(); |
| 283 | 283 | if ($this->id) |
| 284 | 284 | { |
| 285 | - $parameters = array |
|
| 286 | - ( |
|
| 285 | + $parameters = array( |
|
| 287 | 286 | 'id' => $this->id |
| 288 | 287 | ); |
| 289 | 288 | $conditions->add($qb->expr()->neq('c.id', ':id')); |
@@ -337,7 +336,7 @@ discard block |
||
| 337 | 336 | { |
| 338 | 337 | $this->initialize(); |
| 339 | 338 | |
| 340 | - if ( empty($this->cm->midgard['parentfield']) |
|
| 339 | + if (empty($this->cm->midgard['parentfield']) |
|
| 341 | 340 | || empty($this->cm->midgard['parent'])) |
| 342 | 341 | { |
| 343 | 342 | return true; |
@@ -357,7 +356,7 @@ discard block |
||
| 357 | 356 | |
| 358 | 357 | foreach ($this->cm->fieldMappings as $name => $field) |
| 359 | 358 | { |
| 360 | - if ( $field['midgard:midgard_type'] == translator::TYPE_GUID |
|
| 359 | + if ($field['midgard:midgard_type'] == translator::TYPE_GUID |
|
| 361 | 360 | && !empty($this->$name) |
| 362 | 361 | && !mgd_is_guid($this->$name)) |
| 363 | 362 | { |
@@ -395,7 +394,7 @@ discard block |
||
| 395 | 394 | $stat = ($results > 0); |
| 396 | 395 | } |
| 397 | 396 | |
| 398 | - if ( !$stat |
|
| 397 | + if (!$stat |
|
| 399 | 398 | && !empty($this->cm->midgard['childtypes'])) |
| 400 | 399 | { |
| 401 | 400 | foreach ($this->cm->midgard['childtypes'] as $typename => $parentfield) |
@@ -534,8 +533,7 @@ discard block |
||
| 534 | 533 | $qb->from($classname, 'c'); |
| 535 | 534 | $conditions = $qb->expr()->andX(); |
| 536 | 535 | $conditions->add($qb->expr()->eq('c.' . $field, ':' . $field)); |
| 537 | - $parameters = array |
|
| 538 | - ( |
|
| 536 | + $parameters = array( |
|
| 539 | 537 | $field => $part |
| 540 | 538 | ); |
| 541 | 539 | |
@@ -621,10 +619,9 @@ discard block |
||
| 621 | 619 | |
| 622 | 620 | public function set_parameter($domain, $name, $value) |
| 623 | 621 | { |
| 624 | - $constraints = array |
|
| 625 | - ( |
|
| 626 | - array ('domain', '=', $domain), |
|
| 627 | - array ('name', '=', $name), |
|
| 622 | + $constraints = array( |
|
| 623 | + array('domain', '=', $domain), |
|
| 624 | + array('name', '=', $name), |
|
| 628 | 625 | ); |
| 629 | 626 | $params = $this->get_collection('midgard_parameter')->find($this->guid, $constraints); |
| 630 | 627 | |
@@ -765,7 +762,7 @@ discard block |
||
| 765 | 762 | exception::not_exists(); |
| 766 | 763 | return false; |
| 767 | 764 | } |
| 768 | - if ( $check_dependencies |
|
| 765 | + if ($check_dependencies |
|
| 769 | 766 | && $this->has_dependents()) |
| 770 | 767 | { |
| 771 | 768 | exception::has_dependants(); |
@@ -33,8 +33,7 @@ discard block |
||
| 33 | 33 | if (is_int($id)) |
| 34 | 34 | { |
| 35 | 35 | $this->get_by_id($id); |
| 36 | - } |
|
| 37 | - else if (is_string($id)) |
|
| 36 | + } else if (is_string($id)) |
|
| 38 | 37 | { |
| 39 | 38 | $this->get_by_guid($id); |
| 40 | 39 | } |
@@ -98,8 +97,7 @@ discard block |
||
| 98 | 97 | try |
| 99 | 98 | { |
| 100 | 99 | $this->$candidate->get_by_id($this->$candidate->id); |
| 101 | - } |
|
| 102 | - catch (exception $e) |
|
| 100 | + } catch (exception $e) |
|
| 103 | 101 | { |
| 104 | 102 | connection::log()->error('Failed to refresh parent from proxy: ' . $e->getMessage()); |
| 105 | 103 | return null; |
@@ -127,8 +125,7 @@ discard block |
||
| 127 | 125 | try |
| 128 | 126 | { |
| 129 | 127 | $entity->__load(); |
| 130 | - } |
|
| 131 | - catch (\Doctrine\ORM\EntityNotFoundException $e) |
|
| 128 | + } catch (\Doctrine\ORM\EntityNotFoundException $e) |
|
| 132 | 129 | { |
| 133 | 130 | throw exception::object_purged(); |
| 134 | 131 | } |
@@ -189,8 +186,7 @@ discard block |
||
| 189 | 186 | { |
| 190 | 187 | $om = new objectmanager(connection::get_em()); |
| 191 | 188 | $om->create($this); |
| 192 | - } |
|
| 193 | - catch (\Exception $e) |
|
| 189 | + } catch (\Exception $e) |
|
| 194 | 190 | { |
| 195 | 191 | exception::internal($e); |
| 196 | 192 | return false; |
@@ -216,8 +212,7 @@ discard block |
||
| 216 | 212 | { |
| 217 | 213 | $om = new objectmanager(connection::get_em()); |
| 218 | 214 | $om->update($this); |
| 219 | - } |
|
| 220 | - catch (\Exception $e) |
|
| 215 | + } catch (\Exception $e) |
|
| 221 | 216 | { |
| 222 | 217 | exception::internal($e); |
| 223 | 218 | return false; |
@@ -257,8 +252,7 @@ discard block |
||
| 257 | 252 | { |
| 258 | 253 | $om = new objectmanager(connection::get_em()); |
| 259 | 254 | $om->delete($this); |
| 260 | - } |
|
| 261 | - catch (\Exception $e) |
|
| 255 | + } catch (\Exception $e) |
|
| 262 | 256 | { |
| 263 | 257 | exception::internal($e); |
| 264 | 258 | return false; |
@@ -312,8 +306,7 @@ discard block |
||
| 312 | 306 | if ($this->{$this->cm->midgard['upfield']} === null) |
| 313 | 307 | { |
| 314 | 308 | $conditions->add($qb->expr()->isNull('c.' . $this->cm->midgard['upfield'])); |
| 315 | - } |
|
| 316 | - else |
|
| 309 | + } else |
|
| 317 | 310 | { |
| 318 | 311 | $conditions->add($qb->expr()->eq('c.' . $this->cm->midgard['upfield'], ':' . $this->cm->midgard['upfield'])); |
| 319 | 312 | $parameters[$this->cm->midgard['upfield']] = $this->{$this->cm->midgard['upfield']}; |
@@ -480,14 +473,12 @@ discard block |
||
| 480 | 473 | $parentclass = $this->cm->fullyQualifiedClassName($this->cm->midgard['parent']); |
| 481 | 474 | $parentfield = $parent_cm->midgard['upfield']; |
| 482 | 475 | $upfield = $this->cm->midgard['parentfield']; |
| 483 | - } |
|
| 484 | - else if (!empty($this->cm->midgard['upfield'])) |
|
| 476 | + } else if (!empty($this->cm->midgard['upfield'])) |
|
| 485 | 477 | { |
| 486 | 478 | $parentclass = get_class($this); |
| 487 | 479 | $upfield = $this->cm->midgard['upfield']; |
| 488 | 480 | $parentfield = $upfield; |
| 489 | - } |
|
| 490 | - else |
|
| 481 | + } else |
|
| 491 | 482 | { |
| 492 | 483 | return false; |
| 493 | 484 | } |
@@ -546,8 +537,7 @@ discard block |
||
| 546 | 537 | ->add($qb->expr()->isNull('c.' . $upfield)) |
| 547 | 538 | ->add($qb->expr()->eq('c.' . $upfield, '0')); |
| 548 | 539 | $conditions->add($empty_conditions); |
| 549 | - } |
|
| 550 | - else |
|
| 540 | + } else |
|
| 551 | 541 | { |
| 552 | 542 | $conditions->add($qb->expr()->eq('c.' . $upfield, ':' . $upfield)); |
| 553 | 543 | $parameters[$upfield] = $up; |
@@ -612,8 +602,7 @@ discard block |
||
| 612 | 602 | try |
| 613 | 603 | { |
| 614 | 604 | return $qb->getQuery()->getOneOrNullResult(Query::HYDRATE_SINGLE_SCALAR); |
| 615 | - } |
|
| 616 | - catch (\Doctrine\ORM\NoResultException $e) |
|
| 605 | + } catch (\Doctrine\ORM\NoResultException $e) |
|
| 617 | 606 | { |
| 618 | 607 | return null; |
| 619 | 608 | } |
@@ -638,8 +627,7 @@ discard block |
||
| 638 | 627 | $stat = $param->delete(); |
| 639 | 628 | } |
| 640 | 629 | return $stat; |
| 641 | - } |
|
| 642 | - else |
|
| 630 | + } else |
|
| 643 | 631 | { |
| 644 | 632 | exception::not_exists(); |
| 645 | 633 | return false; |
@@ -668,8 +656,7 @@ discard block |
||
| 668 | 656 | } |
| 669 | 657 | midgard_connection::get_instance()->set_error(MGD_ERR_OK); |
| 670 | 658 | return true; |
| 671 | - } |
|
| 672 | - catch (\Exception $e) |
|
| 659 | + } catch (\Exception $e) |
|
| 673 | 660 | { |
| 674 | 661 | exception::internal($e); |
| 675 | 662 | return false; |
@@ -740,8 +727,7 @@ discard block |
||
| 740 | 727 | $om->create($att); |
| 741 | 728 | midgard_connection::get_instance()->set_error(MGD_ERR_OK); |
| 742 | 729 | return $att; |
| 743 | - } |
|
| 744 | - catch (\Exception $e) |
|
| 730 | + } catch (\Exception $e) |
|
| 745 | 731 | { |
| 746 | 732 | exception::internal($e); |
| 747 | 733 | return null; |
@@ -776,13 +762,11 @@ discard block |
||
| 776 | 762 | { |
| 777 | 763 | $om = new objectmanager(connection::get_em()); |
| 778 | 764 | $om->purge($this); |
| 779 | - } |
|
| 780 | - catch (\Doctrine\ORM\EntityNotFoundException $e) |
|
| 765 | + } catch (\Doctrine\ORM\EntityNotFoundException $e) |
|
| 781 | 766 | { |
| 782 | 767 | exception::not_exists(); |
| 783 | 768 | return false; |
| 784 | - } |
|
| 785 | - catch (\Exception $e) |
|
| 769 | + } catch (\Exception $e) |
|
| 786 | 770 | { |
| 787 | 771 | exception::internal($e); |
| 788 | 772 | return false; |
@@ -844,12 +828,10 @@ discard block |
||
| 844 | 828 | if ($action == 'lock') |
| 845 | 829 | { |
| 846 | 830 | $flag = 'islocked'; |
| 847 | - } |
|
| 848 | - else if ($action == 'approve') |
|
| 831 | + } else if ($action == 'approve') |
|
| 849 | 832 | { |
| 850 | 833 | $flag = 'isapproved'; |
| 851 | - } |
|
| 852 | - else |
|
| 834 | + } else |
|
| 853 | 835 | { |
| 854 | 836 | throw new exception('Unsupported action ' . $action); |
| 855 | 837 | } |
@@ -869,8 +851,7 @@ discard block |
||
| 869 | 851 | { |
| 870 | 852 | $om = new objectmanager(connection::get_em()); |
| 871 | 853 | $om->{$action}($this); |
| 872 | - } |
|
| 873 | - catch (\Exception $e) |
|
| 854 | + } catch (\Exception $e) |
|
| 874 | 855 | { |
| 875 | 856 | exception::internal($e); |
| 876 | 857 | return false; |