1 <?php
2 /* --------------------------------------------------------------
3 EmailDeleter.inc.php 2015-01-29 gm
4 Gambio GmbH
5 http://www.gambio.de
6 Copyright (c) 2015 Gambio GmbH
7 Released under the GNU General Public License (Version 2)
8 [http://www.gnu.org/licenses/gpl-2.0.html]
9 --------------------------------------------------------------
10 */
11
12 MainFactory::load_class('EmailDeleterInterface');
13
14 /**
15 * Class EmailDeleter
16 *
17 * Deletes email records from the database.
18 *
19 * @category System
20 * @package Email
21 * @subpackage Repository
22 */
23 class EmailDeleter implements EmailDeleterInterface
24 {
25 /**
26 * Query builder.
27 * @var CI_DB_query_builder
28 */
29 protected $db;
30
31
32 /**
33 * Class Constructor
34 *
35 * @param CI_DB_query_builder $db Query builder.
36 */
37 public function __construct(CI_DB_query_builder $db)
38 {
39 $this->db = $db;
40 }
41
42
43 /**
44 * Removes a record from the database.
45 *
46 * This method will delete all the email relevant entities from the database. It will
47 * not throw an exception if the given record is not found.
48 *
49 * @param EmailInterface $email E-Mail.
50 */
51 public function delete(EmailInterface $email)
52 {
53 $this->db->delete(array('emails', 'email_contacts', 'email_attachments'),
54 array('email_id' => (int)(string)$email->getId()));
55 }
56 }