commercetools-sdk-php-v2
The commercetools platform, import-api and PHP sdks generated from our api reference.
StateUpdateActionModel.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  'addRoles' => StateAddRolesActionModel::class,
35  'changeInitial' => StateChangeInitialActionModel::class,
36  'changeKey' => StateChangeKeyActionModel::class,
37  'changeType' => StateChangeTypeActionModel::class,
38  'removeRoles' => StateRemoveRolesActionModel::class,
39  'setDescription' => StateSetDescriptionActionModel::class,
40  'setName' => StateSetNameActionModel::class,
41  'setRoles' => StateSetRolesActionModel::class,
42  'setTransitions' => StateSetTransitionsActionModel::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 = StateUpdateActionModel::class;
100  return $type;
101  }
102 }