| @@ -27,18 +27,38 @@ | ||
| 27 | 27 | |
| 28 | 28 | /** @var array<string, FollowUpAdapterInterface> */ |
| 29 | 29 | private $adapters = array(); |
| 30 | 30 | |
| 31 | + /** @var array<string, GlobalFollowUpAdapterInterface> */ | |
| 32 | + private $globals = array(); | |
| 33 | + | |
| 31 | 34 | /** @var bool */ |
| 32 | 35 | private $hookFired = false; |
| 33 | 36 | |
| 34 | 37 | public function register( FollowUpAdapterInterface $adapter ): void { |
| 38 | + if ( $adapter instanceof GlobalFollowUpAdapterInterface ) { | |
| 39 | + $this->globals[ $adapter->getIntegration() ] = $adapter; | |
| 40 | + return; | |
| 41 | + } | |
| 35 | 42 | $this->adapters[ $adapter->getIntegration() ] = $adapter; |
| 36 | 43 | } |
| 37 | 44 | |
| 45 | + /** | |
| 46 | + * Form or global adapter by the integration stored on a row. | |
| 47 | + */ | |
| 38 | 48 | public function get( string $integration ): ?FollowUpAdapterInterface { |
| 39 | 49 | $this->fireHookOnce(); |
| 40 | - return $this->adapters[ $integration ] ?? null; | |
| 50 | + return $this->adapters[ $integration ] ?? $this->globals[ $integration ] ?? null; | |
| 51 | + } | |
| 52 | + | |
| 53 | + /** | |
| 54 | + * Adapters that follow up every opt-in (since 5.8.0). | |
| 55 | + * | |
| 56 | + * @return array<string, GlobalFollowUpAdapterInterface> | |
| 57 | + */ | |
| 58 | + public function globals(): array { | |
| 59 | + $this->fireHookOnce(); | |
| 60 | + return $this->globals; | |
| 41 | 61 | } |
| 42 | 62 | |
| 43 | 63 | /** |
| 44 | 64 | * Find the adapter responsible for an opt-in. |