@@ -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 | } |
@@ -25,6 +25,10 @@ |
||
| 25 | 25 | |
| 26 | 26 | private $value_properties = array(); |
| 27 | 27 | |
| 28 | + /** |
|
| 29 | + * @param string $class |
|
| 30 | + * @param string $field |
|
| 31 | + */ |
|
| 28 | 32 | public function __construct($class, $field, $value) |
| 29 | 33 | { |
| 30 | 34 | parent::__construct($class); |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | $parsed = $this->parse_constraint_name($property); |
| 64 | 64 | |
| 65 | 65 | // for properties like up.name |
| 66 | - if ( strpos($property, ".") !== false |
|
| 66 | + if (strpos($property, ".") !== false |
|
| 67 | 67 | && !(strpos($property, "metadata") === 0)) { |
| 68 | 68 | return $parsed['name'] . " as " . str_replace(".", "_", $property); |
| 69 | 69 | } |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | public function get($key) |
| 136 | 136 | { |
| 137 | - if ( !$this->_has_results() |
|
| 137 | + if (!$this->_has_results() |
|
| 138 | 138 | || !isset($this->_results[$key])) { |
| 139 | 139 | return false; |
| 140 | 140 | } |
@@ -117,6 +117,9 @@ discard block |
||
| 117 | 117 | return null; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | + /** |
|
| 121 | + * @param integer $id |
|
| 122 | + */ |
|
| 120 | 123 | public function get_by_id($id) |
| 121 | 124 | { |
| 122 | 125 | $entity = connection::get_em()->find(get_class($this), $id); |
@@ -150,6 +153,9 @@ discard block |
||
| 150 | 153 | return true; |
| 151 | 154 | } |
| 152 | 155 | |
| 156 | + /** |
|
| 157 | + * @param string $guid |
|
| 158 | + */ |
|
| 153 | 159 | public function get_by_guid($guid) |
| 154 | 160 | { |
| 155 | 161 | if (!mgd_is_guid($guid)) { |
@@ -492,6 +498,7 @@ discard block |
||
| 492 | 498 | } |
| 493 | 499 | |
| 494 | 500 | /** |
| 501 | + * @param integer $up |
|
| 495 | 502 | * @return QueryBuilder |
| 496 | 503 | */ |
| 497 | 504 | protected function get_uniquefield_query($classname, $field, $part, $upfield, $up) |
@@ -593,7 +600,7 @@ discard block |
||
| 593 | 600 | /** |
| 594 | 601 | * @param string $domain |
| 595 | 602 | * @param string $name |
| 596 | - * @param mixed $value |
|
| 603 | + * @param string $value |
|
| 597 | 604 | * @return boolean |
| 598 | 605 | */ |
| 599 | 606 | public function set_parameter($domain, $name, $value) |
@@ -799,6 +806,9 @@ discard block |
||
| 799 | 806 | return new \midgard_reflection_property(get_called_class()); |
| 800 | 807 | } |
| 801 | 808 | |
| 809 | + /** |
|
| 810 | + * @param string $guid |
|
| 811 | + */ |
|
| 802 | 812 | public function set_guid($guid) |
| 803 | 813 | { |
| 804 | 814 | parent::__set('guid', $guid); |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | |
| 81 | 81 | public function __get($field) |
| 82 | 82 | { |
| 83 | - if ( $field === 'metadata' |
|
| 83 | + if ($field === 'metadata' |
|
| 84 | 84 | && $this->metadata === null |
| 85 | 85 | && $this instanceof metadata_interface) { |
| 86 | 86 | $this->metadata = new metadata($this); |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | foreach ($candidates as $candidate) { |
| 103 | 103 | if ($this->$candidate !== null) { |
| 104 | 104 | //Proxies become stale if the object itself is detached, so we have to re-fetch |
| 105 | - if ( $this->$candidate instanceof \Doctrine\ORM\Proxy\Proxy |
|
| 105 | + if ($this->$candidate instanceof \Doctrine\ORM\Proxy\Proxy |
|
| 106 | 106 | && $this->$candidate->__isInitialized()) { |
| 107 | 107 | try { |
| 108 | 108 | $this->$candidate->get_by_id($this->$candidate->id); |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | } |
| 127 | 127 | // According to Doctrine documentation, proxies should be transparent, but in practice, |
| 128 | 128 | // there will be problems if we don't force-load |
| 129 | - if ( $entity instanceof \Doctrine\ORM\Proxy\Proxy |
|
| 129 | + if ($entity instanceof \Doctrine\ORM\Proxy\Proxy |
|
| 130 | 130 | && !$entity->__isInitialized()) { |
| 131 | 131 | try { |
| 132 | 132 | $entity->__load(); |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | exception::duplicate(); |
| 176 | 176 | return false; |
| 177 | 177 | } |
| 178 | - if ( !$this->is_unique() |
|
| 178 | + if (!$this->is_unique() |
|
| 179 | 179 | || !$this->check_parent()) { |
| 180 | 180 | return false; |
| 181 | 181 | } |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | midgard_connection::get_instance()->set_error(MGD_ERR_INVALID_PROPERTY_VALUE); |
| 232 | 232 | return false; |
| 233 | 233 | } |
| 234 | - if ( $check_dependencies |
|
| 234 | + if ($check_dependencies |
|
| 235 | 235 | && $this->has_dependents()) { |
| 236 | 236 | exception::has_dependants(); |
| 237 | 237 | return false; |
@@ -322,7 +322,7 @@ discard block |
||
| 322 | 322 | { |
| 323 | 323 | $this->initialize(); |
| 324 | 324 | |
| 325 | - if ( empty($this->cm->midgard['parentfield']) |
|
| 325 | + if (empty($this->cm->midgard['parentfield']) |
|
| 326 | 326 | || empty($this->cm->midgard['parent'])) { |
| 327 | 327 | return true; |
| 328 | 328 | } |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | $this->initialize(); |
| 340 | 340 | |
| 341 | 341 | foreach ($this->cm->fieldMappings as $name => $field) { |
| 342 | - if ( $field['midgard:midgard_type'] == translator::TYPE_GUID |
|
| 342 | + if ($field['midgard:midgard_type'] == translator::TYPE_GUID |
|
| 343 | 343 | && !empty($this->$name) |
| 344 | 344 | && !mgd_is_guid($this->$name)) { |
| 345 | 345 | exception::invalid_property_value("'" . $name . "' property's value is not a guid."); |
@@ -375,7 +375,7 @@ discard block |
||
| 375 | 375 | $stat = ($results > 0); |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | - if ( !$stat |
|
| 378 | + if (!$stat |
|
| 379 | 379 | && !empty($this->cm->midgard['childtypes'])) { |
| 380 | 380 | foreach ($this->cm->midgard['childtypes'] as $typename => $parentfield) { |
| 381 | 381 | $qb = connection::get_em()->createQueryBuilder(); |
@@ -740,7 +740,7 @@ discard block |
||
| 740 | 740 | exception::not_exists(); |
| 741 | 741 | return false; |
| 742 | 742 | } |
| 743 | - if ( $check_dependencies |
|
| 743 | + if ($check_dependencies |
|
| 744 | 744 | && $this->has_dependents()) { |
| 745 | 745 | exception::has_dependants(); |
| 746 | 746 | return false; |
@@ -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 { |
@@ -65,6 +65,7 @@ discard block |
||
| 65 | 65 | * This is basically a workaround for some quirks when merging detached entities with changed associations |
| 66 | 66 | * |
| 67 | 67 | * @todo: This may or may not be a bug in Doctrine |
| 68 | + * @param dbobject $source |
|
| 68 | 69 | */ |
| 69 | 70 | private function copy_associations($source, $target) |
| 70 | 71 | { |
@@ -222,6 +223,9 @@ discard block |
||
| 222 | 223 | return $entity; |
| 223 | 224 | } |
| 224 | 225 | |
| 226 | + /** |
|
| 227 | + * @param dbobject $target |
|
| 228 | + */ |
|
| 225 | 229 | private function copy_metadata($source, $target, $action = 'update') |
| 226 | 230 | { |
| 227 | 231 | if (!$source instanceof metadata) { |
@@ -95,6 +95,9 @@ |
||
| 95 | 95 | $type->add_property($property); |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | + /** |
|
| 99 | + * @param string $name |
|
| 100 | + */ |
|
| 98 | 101 | private function add_mixin($name, type $type) |
| 99 | 102 | { |
| 100 | 103 | if (empty($this->mixins[$name])) { |