src/Model/Common/Reference.php 1 location
|
@@ 59-68 (lines=10) @@
|
56 |
|
* @param Context|callable $context |
57 |
|
* @return static |
58 |
|
*/ |
59 |
|
public static function fromArray(array $data, $context = null) |
60 |
|
{ |
61 |
|
if (get_called_class() == 'Commercetools\Core\Model\Common\Reference' && isset($data[static::TYPE_ID])) { |
62 |
|
$className = static::referenceType($data[static::TYPE_ID]); |
63 |
|
if (class_exists($className)) { |
64 |
|
return new $className($data, $context); |
65 |
|
} |
66 |
|
} |
67 |
|
return new static($data, $context); |
68 |
|
} |
69 |
|
|
70 |
|
protected static function referenceType($typeId) |
71 |
|
{ |
src/Model/Subscription/Delivery.php 1 location
|
@@ 49-60 (lines=12) @@
|
46 |
|
return isset($types[$typeId]) ? $types[$typeId] : '\Commercetools\Core\Model\Subscription\Delivery'; |
47 |
|
} |
48 |
|
|
49 |
|
public static function fromArray(array $data, $context = null) |
50 |
|
{ |
51 |
|
if (get_called_class() == 'Commercetools\Core\Model\Subscription\Delivery' && |
52 |
|
isset($data[static::NOTIFICATION_TYPE]) |
53 |
|
) { |
54 |
|
$className = static::destinationType($data[static::NOTIFICATION_TYPE]); |
55 |
|
if (class_exists($className)) { |
56 |
|
return new $className($data, $context); |
57 |
|
} |
58 |
|
} |
59 |
|
return new static($data, $context); |
60 |
|
} |
61 |
|
} |
62 |
|
|
src/Model/Subscription/Destination.php 1 location
|
@@ 37-46 (lines=10) @@
|
34 |
|
return isset($types[$typeId]) ? $types[$typeId] : '\Commercetools\Core\Model\Subscription\Destination'; |
35 |
|
} |
36 |
|
|
37 |
|
public static function fromArray(array $data, $context = null) |
38 |
|
{ |
39 |
|
if (get_called_class() == 'Commercetools\Core\Model\Subscription\Destination' && isset($data[static::TYPE])) { |
40 |
|
$className = static::destinationType($data[static::TYPE]); |
41 |
|
if (class_exists($className)) { |
42 |
|
return new $className($data, $context); |
43 |
|
} |
44 |
|
} |
45 |
|
return new static($data, $context); |
46 |
|
} |
47 |
|
} |
48 |
|
|