| 1 |
<?php |
| 2 |
/** |
| 3 |
* Contract between the core and an add-on that manages subscription groups. |
| 4 |
* |
| 5 |
* @package Forge12\DoubleOptIn\Subscription |
| 6 |
* @since 5.12.0 |
| 7 |
*/ |
| 8 |
|
| 9 |
declare( strict_types=1 ); |
| 10 |
|
| 11 |
namespace Forge12\DoubleOptIn\Subscription; |
| 12 |
|
| 13 |
if ( ! defined( 'ABSPATH' ) ) { |
| 14 |
exit; |
| 15 |
} |
| 16 |
|
| 17 |
/** |
| 18 |
* @api |
| 19 |
* |
| 20 |
* Consumers (admin list, opt-out page, export, analytics) only ever talk to |
| 21 |
* this interface, never to the add-on that implements it. Without an |
| 22 |
* add-on the {@see NullSubscriptionGroupResolver} answers "no groups" and |
| 23 |
* every consumer behaves exactly as before. |
| 24 |
*/ |
| 25 |
interface SubscriptionGroupResolverInterface { |
| 26 |
|
| 27 |
/** |
| 28 |
* The group a record belongs to, or null when it is in none. |
| 29 |
* |
| 30 |
* @param int $formId The record's form id. |
| 31 |
* @param string $formRef The record's form instance reference, if any. |
| 32 |
*/ |
| 33 |
public function groupForForm( int $formId, string $formRef = '' ): ?SubscriptionGroup; |
| 34 |
|
| 35 |
/** |
| 36 |
* A group by its key, or null when it does not exist. |
| 37 |
*/ |
| 38 |
public function findGroup( string $key ): ?SubscriptionGroup; |
| 39 |
|
| 40 |
/** |
| 41 |
* All groups, for selection lists. |
| 42 |
* |
| 43 |
* @return SubscriptionGroup[] |
| 44 |
*/ |
| 45 |
public function groups(): array; |
| 46 |
} |
| 47 |
|