3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
12 namespace Civi\WorkflowMessage
;
14 use Civi\Schema\Traits\ArrayFormatTrait
;
15 use Civi\Schema\Traits\BasicSpecTrait
;
16 use Civi\Schema\Traits\PhpDataTypeSpecTrait
;
17 use Civi\Schema\Traits\OptionsSpecTrait
;
21 // BasicSpecTrait: name, title, description
24 // PhpDataTypeSpecTrait: type, dataType, serialize, fkEntity
25 use PhpDataTypeSpecTrait
;
27 // OptionsSpecTrait: options, optionsCallback
30 // ArrayFormatTrait: toArray():array, loadArray($array)
39 * Allow this property to be used in alternative scopes, such as Smarty and TokenProcessor.
42 * Ex: ['Smarty' => 'smarty_name']
49 public function isRequired(): ?
bool {
50 return $this->required
;
54 * @param bool|null $required
57 public function setRequired(?
bool $required) {
58 $this->required
= $required;
65 public function getScope(): ?
array {
70 * Enable export/import in alternative scopes.
72 * @param string|array|null $scope
74 * Ex: 'tplParams as foo_bar'
75 * Ex: 'tplParams as contact_id, TokenProcessor as contactId'
76 * Ex: ['tplParams' => 'foo_bar']
79 public function setScope($scope) {
80 if (is_array($scope)) {
81 $this->scope
= $scope;
84 $parts = explode(',', $scope);
86 foreach ($parts as $part) {
87 if (preg_match('/^\s*(\S+) as (\S+)\s*$/', $part, $m)) {
88 $this->scope
[trim($m[1])] = trim($m[2]);
91 $this->scope
[trim($part)] = $this->getName();