@@ -270,6 +270,9 @@ |
||
| 270 | 270 | $this->results = []; |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | + /** |
|
| 274 | + * @param Entity $instance |
|
| 275 | + */ |
|
| 273 | 276 | public function save($instance) |
| 274 | 277 | { |
| 275 | 278 | $key = $this->space->getInstanceKey($instance); |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | public function forget($id) |
| 147 | 147 | { |
| 148 | - if(array_key_exists($id, $this->persisted)) { |
|
| 148 | + if (array_key_exists($id, $this->persisted)) { |
|
| 149 | 149 | unset($this->persisted[$id]); |
| 150 | 150 | } |
| 151 | 151 | } |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | |
| 360 | 360 | public function sync($id) |
| 361 | 361 | { |
| 362 | - if(array_key_exists($id, $this->persisted)) { |
|
| 362 | + if (array_key_exists($id, $this->persisted)) { |
|
| 363 | 363 | |
| 364 | 364 | $tuple = $this->getMapper()->getClient()->getSpace($this->space->getId())->select([$id], 0)->getData()[0]; |
| 365 | 365 | |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | if (!$this->getPropertyType($property)) { |
| 114 | 114 | throw new Exception("Unknown property $property", 1); |
| 115 | 115 | } |
| 116 | - $options['parts'][] = $this->getPropertyIndex($property)+1; |
|
| 116 | + $options['parts'][] = $this->getPropertyIndex($property) + 1; |
|
| 117 | 117 | $options['parts'][] = $this->getPropertyType($property); |
| 118 | 118 | } |
| 119 | 119 | |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | public function getTupleMap() |
| 141 | 141 | { |
| 142 | 142 | $reverse = []; |
| 143 | - foreach($this->getFormat() as $i => $field) { |
|
| 143 | + foreach ($this->getFormat() as $i => $field) { |
|
| 144 | 144 | $reverse[$field['name']] = $i + 1; |
| 145 | 145 | } |
| 146 | 146 | return (object) $reverse; |
@@ -230,7 +230,7 @@ discard block |
||
| 230 | 230 | |
| 231 | 231 | public function castIndex($params, $suppressException = false) |
| 232 | 232 | { |
| 233 | - if(!count($this->getIndexes())) { |
|
| 233 | + if (!count($this->getIndexes())) { |
|
| 234 | 234 | return; |
| 235 | 235 | } |
| 236 | 236 | $keys = array_keys($params); |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | } |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | - if(!$suppressException) { |
|
| 281 | + if (!$suppressException) { |
|
| 282 | 282 | throw new Exception("No index"); |
| 283 | 283 | } |
| 284 | 284 | } |
@@ -29,9 +29,9 @@ discard block |
||
| 29 | 29 | ['root', 'right'], |
| 30 | 30 | ]; |
| 31 | 31 | |
| 32 | - foreach($indexes as $index) { |
|
| 32 | + foreach ($indexes as $index) { |
|
| 33 | 33 | $fields = array_key_exists('fields', $index) ? $index['fields'] : $index; |
| 34 | - if($space->castIndex(array_flip($fields), true) === null) { |
|
| 34 | + if ($space->castIndex(array_flip($fields), true) === null) { |
|
| 35 | 35 | $space->createIndex($index); |
| 36 | 36 | } |
| 37 | 37 | } |
@@ -39,20 +39,20 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | public function beforeCreate(Entity $entity, Space $space) |
| 41 | 41 | { |
| 42 | - if($this->isNested($space)) { |
|
| 42 | + if ($this->isNested($space)) { |
|
| 43 | 43 | |
| 44 | 44 | $repository = $space->getRepository(); |
| 45 | 45 | |
| 46 | - if($entity->parent) { |
|
| 46 | + if ($entity->parent) { |
|
| 47 | 47 | |
| 48 | 48 | $parent = $repository->findOne($entity->parent); |
| 49 | 49 | $entity->depth = $parent->depth + 1; |
| 50 | 50 | |
| 51 | 51 | $updateLeft = []; |
| 52 | 52 | $updateRight = []; |
| 53 | - foreach($repository->find(['root' => $entity->root]) as $node) { |
|
| 54 | - if($node->right >= $parent->right) { |
|
| 55 | - if($node->left > $parent->right) { |
|
| 53 | + foreach ($repository->find(['root' => $entity->root]) as $node) { |
|
| 54 | + if ($node->right >= $parent->right) { |
|
| 55 | + if ($node->left > $parent->right) { |
|
| 56 | 56 | $updateLeft[$node->left] = $node; |
| 57 | 57 | } |
| 58 | 58 | $updateRight[$node->right] = $node; |
@@ -63,13 +63,13 @@ discard block |
||
| 63 | 63 | $entity->right = $entity->left + 1; |
| 64 | 64 | |
| 65 | 65 | krsort($updateRight); |
| 66 | - foreach($updateRight as $node) { |
|
| 66 | + foreach ($updateRight as $node) { |
|
| 67 | 67 | $node->right += 2; |
| 68 | 68 | $node->save(); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | krsort($updateLeft); |
| 72 | - foreach($updateLeft as $node) { |
|
| 72 | + foreach ($updateLeft as $node) { |
|
| 73 | 73 | $node->left += 2; |
| 74 | 74 | $node->save(); |
| 75 | 75 | } |
@@ -140,12 +140,12 @@ discard block |
||
| 140 | 140 | ")->getData(); |
| 141 | 141 | |
| 142 | 142 | // remove |
| 143 | - foreach($result[0] as $id) { |
|
| 143 | + foreach ($result[0] as $id) { |
|
| 144 | 144 | $space->getRepository()->forget($id); |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | // update |
| 148 | - foreach($result[1] as $id) { |
|
| 148 | + foreach ($result[1] as $id) { |
|
| 149 | 149 | $space->getRepository()->sync($id); |
| 150 | 150 | } |
| 151 | 151 | |
@@ -155,10 +155,10 @@ discard block |
||
| 155 | 155 | public function isNested(Space $space, $force = false) |
| 156 | 156 | { |
| 157 | 157 | $spaceName = $space->getName(); |
| 158 | - if($force || !array_key_exists($spaceName, $this->nestedSpaces)) { |
|
| 158 | + if ($force || !array_key_exists($spaceName, $this->nestedSpaces)) { |
|
| 159 | 159 | |
| 160 | 160 | $fields = []; |
| 161 | - foreach($space->getFormat() as $field) { |
|
| 161 | + foreach ($space->getFormat() as $field) { |
|
| 162 | 162 | $fields[] = $field['name']; |
| 163 | 163 | } |
| 164 | 164 | |