1 <?php
2
3 /* --------------------------------------------------------------
4 ProductAttributeRepositoryDeleter.inc.php 2016-01-08
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 /**
14 * Class ProductAttributeRepositoryDeleter
15 *
16 * @category System
17 * @package ProductModule
18 * @subpackage Deleter
19 */
20 class ProductAttributeRepositoryDeleter implements ProductAttributeRepositoryDeleterInterface
21 {
22 /**
23 * @var CI_DB_query_builder
24 */
25 protected $db;
26
27 /**
28 * @var string
29 */
30 protected $tableName = 'products_attributes';
31
32
33 /**
34 * Initialize the product attribute repository deleter.
35 *
36 * @param CI_DB_query_builder $db Instance to perform db delete actions.
37 */
38 public function __construct(CI_DB_query_builder $db)
39 {
40 $this->db = $db;
41 }
42
43
44 /**
45 * Removes a product attribute entity by the given product attribute id.
46 *
47 * @param IdType $productAttributeId Id of attribute entity to delete.
48 *
49 * @return ProductAttributeRepositoryDeleter|$this Same instance for chained method calls.
50 */
51 public function deleteAttributeById(IdType $productAttributeId)
52 {
53 $this->db->delete($this->tableName, array('products_attributes_id' => $productAttributeId->asInt()));
54
55 return $this;
56 }
57
58
59 /**
60 * Removes all product attributes entities that belongs to the given product entity id.
61 *
62 * @param IdType $productId Id of product entity which belongs to the product attribute entities to delete.
63 *
64 * @return ProductAttributeRepositoryDeleter|$this Same instance for chained method calls.
65 */
66 public function deleteAttributesByProductId(IdType $productId)
67 {
68 $this->db->delete($this->tableName, array('products_id' => $productId->asInt()));
69
70 return $this;
71 }
72 }