1 <?php
2
3 /* --------------------------------------------------------------
4 ProductRepositoryDeleter.inc.php 2015-12-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 ProductRepositoryDeleter
15 *
16 * @category System
17 * @package Product
18 * @subpackage Repositories
19 */
20 class ProductRepositoryDeleter implements ProductRepositoryDeleterInterface
21 {
22 /**
23 * Database connection.
24 *
25 * @var CI_DB_query_builder
26 */
27 protected $db;
28
29
30 /**
31 * ProductRepositoryDeleter constructor.
32 *
33 * @param CI_DB_query_builder $db
34 */
35 public function __construct(CI_DB_query_builder $db)
36 {
37 $this->db = $db;
38 }
39
40
41 /**
42 * Removes a product by the given product id.
43 *
44 * @param IdType $productId Id of product entity.
45 *
46 * @return ProductRepositoryDeleter Same instance for chained method calls.
47 */
48 public function deleteById(IdType $productId)
49 {
50 $this->db->delete(array('products', 'products_description', 'products_to_categories'),
51 array('products_id' => $productId->asInt()));
52
53 return $this;
54 }
55 }