commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
ApprovalFlowUpdateActionModel.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  'approve' => ApprovalFlowApproveActionModel::class,
35  'reject' => ApprovalFlowRejectActionModel::class,
36  'setCustomField' => ApprovalFlowSetCustomFieldActionModel::class,
37  'setCustomType' => ApprovalFlowSetCustomTypeActionModel::class,
38  ];
39 
43  public function __construct(
44  ?string $action = null
45  ) {
46  $this->action = $action;
47  }
48 
53  public function getAction()
54  {
55  if (is_null($this->action)) {
57  $data = $this->raw(self::FIELD_ACTION);
58  if (is_null($data)) {
59  return null;
60  }
61  $this->action = (string) $data;
62  }
63 
64  return $this->action;
65  }
66 
67 
68 
69 
70 
75  public static function resolveDiscriminatorClass($value): string
76  {
78  if (is_object($value) && isset($value->$fieldName)) {
80  $discriminatorValue = $value->$fieldName;
81  if (isset(self::$discriminatorClasses[$discriminatorValue])) {
82  return self::$discriminatorClasses[$discriminatorValue];
83  }
84  }
85  if (is_array($value) && isset($value[$fieldName])) {
87  $discriminatorValue = $value[$fieldName];
88  if (isset(self::$discriminatorClasses[$discriminatorValue])) {
89  return self::$discriminatorClasses[$discriminatorValue];
90  }
91  }
92 
94  $type = ApprovalFlowUpdateActionModel::class;
95  return $type;
96  }
97 }