33
44namespace Flowpack \DecoupledContentStore \Transfer \Dto ;
55
6+ use Flowpack \DecoupledContentStore \Core \Domain \ValueObject \RedisInstanceIdentifier ;
7+ use Flowpack \DecoupledContentStore \Exception \InvalidTransferConfigException ;
68use Neos \Flow \Annotations as Flow ;
79
810/**
@@ -15,24 +17,31 @@ final class RedisKeyPostfixForEachRelease
1517 private const TRANSFER_MODE_DUMP = 'dump ' ;
1618
1719 protected string $ redisKeyPostfix ;
18- protected bool $ transfer ;
20+ protected array $ transfer ;
1921 protected string $ transferMode ;
2022 protected bool $ isRequired ;
2123
2224 /**
2325 * @param string $redisKeyPostfix
24- * @param bool $transfer
26+ * @param bool|array $transfer
2527 * @param string $transferMode
2628 * @param bool $isRequired
2729 */
28- private function __construct (string $ redisKeyPostfix , bool $ transfer , string $ transferMode , bool $ isRequired )
30+ private function __construct (string $ redisKeyPostfix , $ transfer , string $ transferMode , bool $ isRequired )
2931 {
3032 if (!in_array ($ transferMode , [self ::TRANSFER_MODE_HASH_INCREMENTAL , self ::TRANSFER_MODE_DUMP ])) {
3133 throw new \RuntimeException ('TransferMode ' . $ transferMode . ' not supported. ' );
3234 }
3335
36+ if (is_bool ($ transfer )) {
37+ $ this ->transfer = [
38+ '* ' => $ transfer
39+ ];
40+ } else {
41+ $ this ->transfer = $ transfer ;
42+ }
43+
3444 $ this ->redisKeyPostfix = $ redisKeyPostfix ;
35- $ this ->transfer = $ transfer ;
3645 $ this ->transferMode = $ transferMode ;
3746 $ this ->isRequired = $ isRequired ;
3847 }
@@ -51,9 +60,15 @@ public static function fromArray(array $in): self
5160 /**
5261 * @return bool
5362 */
54- public function shouldTransfer (): bool
63+ public function shouldTransfer (RedisInstanceIdentifier $ redisInstanceIdentifier ): bool
5564 {
56- return $ this ->transfer ;
65+ if (array_key_exists ($ redisInstanceIdentifier ->getIdentifier (), $ this ->transfer )) {
66+ return $ this ->transfer [$ redisInstanceIdentifier ->getIdentifier ()];
67+ }
68+ if (array_key_exists ('* ' , $ this ->transfer )) {
69+ return $ this ->transfer ['* ' ];
70+ }
71+ throw new InvalidTransferConfigException ('No valid transfer mode is configured. ' );
5772 }
5873
5974 public function isRequired (): bool
0 commit comments