|
3 | 3 |
|
4 | 4 | namespace Netlogix\JsonApiOrg\Consumer\Domain\Model; |
5 | 5 |
|
| 6 | +use Countable; |
6 | 7 | use Generator; |
| 8 | +use IteratorAggregate; |
7 | 9 | use Neos\Cache\Frontend\VariableFrontend; |
8 | 10 | use Neos\Flow\Cache\CacheManager; |
| 11 | +use Neos\Flow\Log\ThrowableStorageInterface; |
9 | 12 | use Neos\Flow\Utility\Now; |
10 | 13 | use Psr\Http\Message\UriInterface; |
| 14 | +use Throwable; |
11 | 15 |
|
12 | | -class ResourceProxyIterator implements \IteratorAggregate, \Countable |
| 16 | +class ResourceProxyIterator implements IteratorAggregate, Countable |
13 | 17 | { |
| 18 | + protected ?ThrowableStorageInterface $throwableStorage; |
| 19 | + |
14 | 20 | /** |
15 | 21 | * @var VariableFrontend |
16 | 22 | */ |
@@ -61,6 +67,11 @@ public function injectNow(Now $now) |
61 | 67 | $this->now = $now; |
62 | 68 | } |
63 | 69 |
|
| 70 | + public function injectThrowableStorage(ThrowableStorageInterface $throwableStorage): void |
| 71 | + { |
| 72 | + $this->throwableStorage = $throwableStorage; |
| 73 | + } |
| 74 | + |
64 | 75 | public function initialize(callable $convertResourceDefinitionToResourceProxy): self |
65 | 76 | { |
66 | 77 | $result = $this->jsonResult ?? []; |
@@ -139,14 +150,25 @@ public function saveToCache(int $lifetime, string ...$tags): self |
139 | 150 | 'eTag' => $eTag, |
140 | 151 | ]; |
141 | 152 |
|
142 | | - $this->cache->set($identifier, $cacheData, $tags, $lifetime); |
| 153 | + try { |
| 154 | + $this->cache->set($identifier, $cacheData, $tags, $lifetime); |
| 155 | + } catch (Throwable $t) { |
| 156 | + $this->throwableStorage?->logThrowable($t); |
| 157 | + } |
| 158 | + |
143 | 159 | return $this; |
144 | 160 | } |
145 | 161 |
|
146 | 162 | public function loadFromCache(): self |
147 | 163 | { |
148 | 164 | $identifier = sha1($this->uri); |
149 | | - $cacheData = $this->cache->get($identifier); |
| 165 | + $cacheData = null; |
| 166 | + try { |
| 167 | + $cacheData = $this->cache->get($identifier); |
| 168 | + } catch (Throwable $t) { |
| 169 | + $this->throwableStorage?->logThrowable($t); |
| 170 | + } |
| 171 | + |
150 | 172 | if (is_array($cacheData)) { |
151 | 173 | $this->jsonResult = $cacheData['jsonResult'] ?? null; |
152 | 174 | $this->eTag = $cacheData['eTag'] ?? ''; |
|
0 commit comments