WorkflowMessage - Add assertValid(), renderTemplate(), sendTemplate() helpers to...
[civicrm-core.git] / Civi / WorkflowMessage / GenericWorkflowMessage.php
1 <?php
2
3 /*
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC. All rights reserved. |
6 | |
7 | This work is published under the GNU AGPLv3 license with some |
8 | permitted exceptions and without any warranty. For full license |
9 | and copyright information, see https://civicrm.org/licensing |
10 +--------------------------------------------------------------------+
11 */
12
13 namespace Civi\WorkflowMessage;
14
15 use Civi\Schema\Traits\MagicGetterSetterTrait;
16 use Civi\WorkflowMessage\Traits\FinalHelperTrait;
17 use Civi\WorkflowMessage\Traits\ReflectiveWorkflowTrait;
18
19 /**
20 * Generic base-class for describing the inputs for a workflow email template.
21 *
22 * @method $this setContactId(int|null $contactId)
23 * @method int|null getContactId()
24 */
25 class GenericWorkflowMessage implements WorkflowMessageInterface {
26
27 // Implement getFields(), import(), export(), validate() - All methods based on inspecting class properties (`ReflectionClass`).
28 // Define stub methods exportExtraTokenContext(), exportExtraTplParams(), etc.
29 use ReflectiveWorkflowTrait;
30
31 // Implement __call() - Public and protected properties are automatically given a default getter/setter. These may be overridden/customized.
32 use MagicGetterSetterTrait;
33
34 // Implement assertValid(), renderTemplate(), sendTemplate() - Sugary stub methods that delegate to real APIs.
35 use FinalHelperTrait;
36
37 /**
38 * WorkflowMessage constructor.
39 *
40 * @param array $imports
41 * List of values to import.
42 * Ex: ['tplParams' => [...tplValues...], 'tokenContext' => [...tokenData...]]
43 * Ex: ['modelProps' => [...classProperties...]]
44 */
45 public function __construct(array $imports = []) {
46 WorkflowMessage::importAll($this, $imports);
47 }
48
49 /**
50 * The contact receiving this message.
51 *
52 * @var int
53 * @scope tokenContext
54 */
55 protected $contactId;
56
57 }