commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
ApprovalRuleUpdateActionModel.php
1 <?php
2 
3 declare(strict_types=1);
10 
15 use stdClass;
16 
21 {
22  public const DISCRIMINATOR_VALUE = '';
27  protected $action;
28 
33  private static $discriminatorClasses = [
34  'setApprovers' => ApprovalRuleSetApproversActionModel::class,
35  'setCustomField' => ApprovalRuleSetCustomFieldActionModel::class,
36  'setCustomType' => ApprovalRuleSetCustomTypeActionModel::class,
37  'setDescription' => ApprovalRuleSetDescriptionActionModel::class,
38  'setKey' => ApprovalRuleSetKeyActionModel::class,
39  'setName' => ApprovalRuleSetNameActionModel::class,
40  'setPredicate' => ApprovalRuleSetPredicateActionModel::class,
41  'setRequesters' => ApprovalRuleSetRequestersActionModel::class,
42  'setStatus' => ApprovalRuleSetStatusActionModel::class,
43  ];
44 
48  public function __construct(
49  ?string $action = null
50  ) {
51  $this->action = $action;
52  }
53 
58  public function getAction()
59  {
60  if (is_null($this->action)) {
62  $data = $this->raw(self::FIELD_ACTION);
63  if (is_null($data)) {
64  return null;
65  }
66  $this->action = (string) $data;
67  }
68 
69  return $this->action;
70  }
71 
72 
73 
74 
75 
80  public static function resolveDiscriminatorClass($value): string
81  {
83  if (is_object($value) && isset($value->$fieldName)) {
85  $discriminatorValue = $value->$fieldName;
86  if (isset(self::$discriminatorClasses[$discriminatorValue])) {
87  return self::$discriminatorClasses[$discriminatorValue];
88  }
89  }
90  if (is_array($value) && isset($value[$fieldName])) {
92  $discriminatorValue = $value[$fieldName];
93  if (isset(self::$discriminatorClasses[$discriminatorValue])) {
94  return self::$discriminatorClasses[$discriminatorValue];
95  }
96  }
97 
99  $type = ApprovalRuleUpdateActionModel::class;
100  return $type;
101  }
102 }