| @@ 104-129 (lines=26) @@ | ||
| 101 | * |
|
| 102 | * @return mixed |
|
| 103 | */ |
|
| 104 | public function update(Request $request, $version) |
|
| 105 | { |
|
| 106 | $segments = $this->getSegments($request); |
|
| 107 | $paths = []; |
|
| 108 | $path = ''; |
|
| 109 | foreach ($segments as $segment) { |
|
| 110 | $path .= "#$segment"; |
|
| 111 | $paths[] = $path; |
|
| 112 | } |
|
| 113 | ||
| 114 | foreach ($paths as $i => $path) { |
|
| 115 | $record = $this->fetchRecord($path); |
|
| 116 | if ($record) { |
|
| 117 | $this->invalidateChildren($record, $version); |
|
| 118 | } else { |
|
| 119 | $record = $this->createRecord(); |
|
| 120 | } |
|
| 121 | $this->updateVersion($record, $version); |
|
| 122 | if (isset($paths[$i + 1])) { |
|
| 123 | $this->addChild($record, $paths[$i + 1]); |
|
| 124 | } |
|
| 125 | $this->cache->set($path, $record); |
|
| 126 | } |
|
| 127 | ||
| 128 | return $version; |
|
| 129 | } |
|
| 130 | ||
| 131 | /** |
|
| 132 | * @param Request $request |
|
| @@ 137-161 (lines=25) @@ | ||
| 134 | * |
|
| 135 | * @return mixed |
|
| 136 | */ |
|
| 137 | public function register(Request $request, $version) |
|
| 138 | { |
|
| 139 | $segments = $this->getSegments($request); |
|
| 140 | $paths = []; |
|
| 141 | $path = ''; |
|
| 142 | foreach ($segments as $segment) { |
|
| 143 | $path .= "#$segment"; |
|
| 144 | $paths[] = $path; |
|
| 145 | } |
|
| 146 | ||
| 147 | foreach ($paths as $i => $path) { |
|
| 148 | $record = $this->fetchRecord($path); |
|
| 149 | if (!$record) { |
|
| 150 | $record = $this->createRecord($version); |
|
| 151 | } |
|
| 152 | if (isset($paths[$i + 1])) { |
|
| 153 | $this->addChild($record, $paths[$i + 1]); |
|
| 154 | } |
|
| 155 | $this->saveRecord($path, $record); |
|
| 156 | } |
|
| 157 | $record = $this->createRecord($version); |
|
| 158 | $this->cache->set($this->createKeyFromSegments($segments), $record); |
|
| 159 | ||
| 160 | return $version; |
|
| 161 | } |
|
| 162 | ||
| 163 | /** |
|
| 164 | * @param array $record |
|