1 <?php
2
3 /* --------------------------------------------------------------
4 OrderItemAttributeRepositoryDeleter.inc.php 2015-11-10
5 Gambio GmbH
6 http://www.gambio.de
7 Copyright (c) 2015 Gambio GmbH
8 Released under the GNU General Public License (Version 2)
9 [http://www.gnu.org/licenses/gpl-2.0.html]
10 --------------------------------------------------------------
11 */
12
13 MainFactory::load_class('OrderItemAttributeRepositoryDeleterInterface');
14
15 /**
16 * Class OrderItemAttributeRepositoryDeleter
17 *
18 * @category System
19 * @package Order
20 * @subpackage Repositories
21 */
22 class OrderItemAttributeRepositoryDeleter implements OrderItemAttributeRepositoryDeleterInterface
23 {
24 /**
25 * Query builder.
26 * @var CI_DB_query_builder
27 */
28 protected $db;
29
30
31 /**
32 * OrderItemAttributeRepositoryDeleter constructor.
33 *
34 * @param CI_DB_query_builder $dbQueryBuilder Query builder.
35 */
36 public function __construct(CI_DB_query_builder $dbQueryBuilder)
37 {
38 $this->db = $dbQueryBuilder;
39 }
40
41
42 /**
43 * Removes an attribute by the given order item attribute ID.
44 *
45 * @param IdType $orderItemAttributeId ID of the order item attribute.
46 *
47 * @return OrderItemAttributeRepositoryDeleter Same instance for method chaining.
48 */
49 public function deleteAttributeById(IdType $orderItemAttributeId)
50 {
51 $this->db->delete('orders_products_attributes',
52 array('orders_products_attributes_id' => $orderItemAttributeId->asInt()));
53
54 return $this;
55 }
56
57
58 /**
59 * Removes all attributes from the order item by the given order item ID.
60 *
61 * @param IdType $orderItemId ID of the order item.
62 *
63 * @return OrderItemAttributeRepositoryDeleter Same instance for method chaining.
64 */
65 public function deleteAttributesByOrderItemId(IdType $orderItemId)
66 {
67 $this->db->delete('orders_products_attributes', array('orders_products_id' => $orderItemId->asInt()));
68
69 return $this;
70 }
71 }