1 <?php
2
3 /* --------------------------------------------------------------
4 CategoryRepositoryDeleter.inc.php 2015-11-25
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 CategoryRepositoryDeleter
15 *
16 * This class deletes category records from the database and is used in the category repository among the classes for
17 * writing and reading category records.
18 *
19 * @category System
20 * @package Category
21 * @subpackage Repositories
22 */
23 class CategoryRepositoryDeleter implements CategoryRepositoryDeleterInterface
24 {
25 /**
26 * Database connector.
27 *
28 * @var CI_DB_query_builder
29 */
30 protected $db;
31
32
33 /**
34 * CategoryRepositoryDeleter constructor.
35 *
36 * @param CI_DB_query_builder $db Database connector.
37 */
38 public function __construct(CI_DB_query_builder $db)
39 {
40 $this->db = $db;
41 }
42
43
44 /**
45 * Deletes a specific category entity.
46 *
47 * @param IdType $categoryId Category ID.
48 *
49 * @return CategoryRepositoryDeleter Same instance for chained method calls.
50 */
51 public function deleteById(IdType $categoryId)
52 {
53 $this->db->delete(array('categories', 'categories_description'),
54 array('categories_id' => $categoryId->asInt()));
55
56 return $this;
57 }
58 }