@@ 17-41 (lines=25) @@ | ||
14 | * @method Transaction current() |
|
15 | * @method Transaction getAt($offset) |
|
16 | */ |
|
17 | class TransactionCollection extends Collection |
|
18 | { |
|
19 | const INTERACTION_ID = 'interactionId'; |
|
20 | protected $type = '\Commercetools\Core\Model\Payment\Transaction'; |
|
21 | ||
22 | ||
23 | protected function indexRow($offset, $row) |
|
24 | { |
|
25 | if ($row instanceof Transaction) { |
|
26 | $id = $row->getInteractionId(); |
|
27 | } else { |
|
28 | $id = isset($row[static::INTERACTION_ID]) ? $row[static::INTERACTION_ID] : null; |
|
29 | } |
|
30 | $this->addToIndex(static::INTERACTION_ID, $offset, $id); |
|
31 | } |
|
32 | ||
33 | /** |
|
34 | * @param $id |
|
35 | * @return Payment |
|
36 | */ |
|
37 | public function getByInteractionId($id) |
|
38 | { |
|
39 | return $this->getBy(static::INTERACTION_ID, $id); |
|
40 | } |
|
41 | } |
|
42 |
@@ 17-41 (lines=25) @@ | ||
14 | * @method ApiError current() |
|
15 | * @method ApiError getAt($offset) |
|
16 | */ |
|
17 | class ErrorContainer extends Collection |
|
18 | { |
|
19 | const CODE = 'code'; |
|
20 | ||
21 | protected $type = '\Commercetools\Core\Error\ApiError'; |
|
22 | ||
23 | protected function indexRow($offset, $row) |
|
24 | { |
|
25 | if ($row instanceof ApiError) { |
|
26 | $id = $row->getCode(); |
|
27 | } else { |
|
28 | $id = $row[static::CODE]; |
|
29 | } |
|
30 | $this->addToIndex(static::CODE, $offset, $id); |
|
31 | } |
|
32 | ||
33 | /** |
|
34 | * @param $code |
|
35 | * @return ApiError |
|
36 | */ |
|
37 | public function getByCode($code) |
|
38 | { |
|
39 | return $this->getBy(static::CODE, $code); |
|
40 | } |
|
41 | } |
|
42 |
@@ 17-30 (lines=14) @@ | ||
14 | * @method ProductProjectionCollection add(ProductProjection $element) |
|
15 | * @method ProductProjection getAt($offset) |
|
16 | */ |
|
17 | class ProductProjectionCollection extends Collection |
|
18 | { |
|
19 | protected $type = '\Commercetools\Core\Model\Product\ProductProjection'; |
|
20 | ||
21 | protected function indexRow($offset, $row) |
|
22 | { |
|
23 | if ($row instanceof ProductProjection) { |
|
24 | $id = $row->getId(); |
|
25 | } else { |
|
26 | $id = isset($row[static::ID]) ? $row[static::ID]: null; |
|
27 | } |
|
28 | $this->addToIndex(static::ID, $offset, $id); |
|
29 | } |
|
30 | } |
|
31 |
@@ 15-39 (lines=25) @@ | ||
12 | * @method AssetSource current() |
|
13 | * @method AssetSource getAt($offset) |
|
14 | */ |
|
15 | class AssetSourceCollection extends Collection |
|
16 | { |
|
17 | const KEY = 'key'; |
|
18 | ||
19 | protected $type = '\Commercetools\Core\Model\Common\AssetSource'; |
|
20 | ||
21 | protected function indexRow($offset, $row) |
|
22 | { |
|
23 | if ($row instanceof AssetSource) { |
|
24 | $key = $row->getKey(); |
|
25 | } else { |
|
26 | $key = isset($row[static::KEY]) ? $row[static::KEY]: null; |
|
27 | } |
|
28 | $this->addToIndex(static::KEY, $offset, $key); |
|
29 | } |
|
30 | ||
31 | /** |
|
32 | * @param string $key |
|
33 | * @return AssetSource|null |
|
34 | */ |
|
35 | public function getByKey($key) |
|
36 | { |
|
37 | return $this->getBy(static::KEY, $key); |
|
38 | } |
|
39 | } |
|
40 |