| @@ 17-41 (lines=25) @@ | ||
| 14 | * @method Payment current() |
|
| 15 | * @method Payment getAt($offset) |
|
| 16 | */ |
|
| 17 | class PaymentCollection extends Collection |
|
| 18 | { |
|
| 19 | const ID = 'id'; |
|
| 20 | protected $type = '\Commercetools\Core\Model\Payment\Payment'; |
|
| 21 | ||
| 22 | ||
| 23 | protected function indexRow($offset, $row) |
|
| 24 | { |
|
| 25 | if ($row instanceof Payment) { |
|
| 26 | $id = $row->getId(); |
|
| 27 | } else { |
|
| 28 | $id = isset($row[static::ID]) ? $row[static::ID] : null; |
|
| 29 | } |
|
| 30 | $this->addToIndex(static::ID, $offset, $id); |
|
| 31 | } |
|
| 32 | ||
| 33 | /** |
|
| 34 | * @param $id |
|
| 35 | * @return Payment |
|
| 36 | */ |
|
| 37 | public function getById($id) |
|
| 38 | { |
|
| 39 | return $this->getBy(static::ID, $id); |
|
| 40 | } |
|
| 41 | } |
|
| 42 | ||
| @@ 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 | ||
| @@ 15-39 (lines=25) @@ | ||
| 12 | * @method AddressCollection add(Address $element) |
|
| 13 | * @method Address getAt($offset) |
|
| 14 | */ |
|
| 15 | class AddressCollection extends Collection |
|
| 16 | { |
|
| 17 | const ID = 'id'; |
|
| 18 | ||
| 19 | protected $type = '\Commercetools\Core\Model\Common\Address'; |
|
| 20 | ||
| 21 | protected function indexRow($offset, $row) |
|
| 22 | { |
|
| 23 | if ($row instanceof Address) { |
|
| 24 | $name = $row->getId(); |
|
| 25 | } else { |
|
| 26 | $name = $row[static::ID]; |
|
| 27 | } |
|
| 28 | $this->addToIndex(static::ID, $offset, $name); |
|
| 29 | } |
|
| 30 | ||
| 31 | /** |
|
| 32 | * @param $id |
|
| 33 | * @return Address|null |
|
| 34 | */ |
|
| 35 | public function getById($id = null) |
|
| 36 | { |
|
| 37 | return $this->getBy(static::ID, $id); |
|
| 38 | } |
|
| 39 | } |
|
| 40 | ||
| @@ 17-41 (lines=25) @@ | ||
| 14 | * @method AttributeDefinitionCollection add(AttributeDefinition $element) |
|
| 15 | * @method AttributeDefinition getAt($offset) |
|
| 16 | */ |
|
| 17 | class AttributeDefinitionCollection extends Collection |
|
| 18 | { |
|
| 19 | protected $type = '\Commercetools\Core\Model\ProductType\AttributeDefinition'; |
|
| 20 | ||
| 21 | const NAME = 'name'; |
|
| 22 | ||
| 23 | protected function indexRow($offset, $row) |
|
| 24 | { |
|
| 25 | if ($row instanceof AttributeDefinition) { |
|
| 26 | $name = $row->getName(); |
|
| 27 | } else { |
|
| 28 | $name = $row[static::NAME]; |
|
| 29 | } |
|
| 30 | $this->addToIndex(static::NAME, $offset, $name); |
|
| 31 | } |
|
| 32 | ||
| 33 | /** |
|
| 34 | * @param $name |
|
| 35 | * @return AttributeDefinition |
|
| 36 | */ |
|
| 37 | public function getByName($name) |
|
| 38 | { |
|
| 39 | return $this->getBy(static::NAME, $name); |
|
| 40 | } |
|
| 41 | } |
|
| 42 | ||