|
1
|
|
|
<?php |
|
2
|
|
|
class Install_Helper_Shop { |
|
3
|
|
|
|
|
4
|
|
|
private $kernel; |
|
5
|
|
|
private $db; |
|
6
|
|
|
|
|
7
|
|
|
public function __construct($kernel, $db) { |
|
8
|
|
|
$this->kernel = $kernel; |
|
9
|
|
|
$this->db = $db; |
|
10
|
|
|
} |
|
11
|
|
|
|
|
12
|
|
View Code Duplication |
public function create() { |
|
|
|
|
|
|
13
|
|
|
|
|
14
|
|
|
require_once 'Intraface/modules/shop/Shop.php'; |
|
15
|
|
|
$shop = new Intraface_modules_shop_Shop; |
|
16
|
|
|
$shop->intranet_id = $this->kernel->intranet->getId(); |
|
17
|
|
|
$shop->name = 'test'; |
|
18
|
|
|
$shop->description = 'test'; |
|
19
|
|
|
$shop->identifier = 'test'; |
|
20
|
|
|
$shop->show_online = 1; |
|
21
|
|
|
$shop->payment_link = '/demo/1/shop/1/basket/onlinepayment'; |
|
22
|
|
|
$shop->confirmation = ''; |
|
23
|
|
|
$shop->receipt = '<h3>Vi har modtaget din ordre</h3><p>Nu sker der følgende:</p><p>Vi sender, du pakker du</p>'; |
|
24
|
|
|
|
|
25
|
|
|
$shop->save(); |
|
26
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
return 1; |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
View Code Duplication |
public function createWithDefaultCurrency() { |
|
|
|
|
|
|
32
|
|
|
|
|
33
|
|
|
require_once 'Intraface/modules/shop/Shop.php'; |
|
34
|
|
|
$shop = new Intraface_modules_shop_Shop; |
|
35
|
|
|
$shop->intranet_id = $this->kernel->intranet->getId(); |
|
36
|
|
|
$shop->name = 'test'; |
|
37
|
|
|
$shop->description = 'test'; |
|
38
|
|
|
$shop->identifier = 'test'; |
|
39
|
|
|
$shop->default_currency_id = 1; |
|
40
|
|
|
$shop->show_online = 1; |
|
41
|
|
|
$shop->confirmation = ''; |
|
42
|
|
|
$shop->receipt = '<h3>Vi har modtaget din ordre</h3><p>Nu sker der følgende:</p><p>Vi sender, du pakker du</p>'; |
|
43
|
|
|
|
|
44
|
|
|
$shop->save(); |
|
45
|
|
|
|
|
46
|
|
|
|
|
47
|
|
|
return 1; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function createCategory($name = 'Category 1', $identifier = 'category1', $parent = 0) { |
|
51
|
|
|
|
|
52
|
|
|
$category = new Intraface_Category($this->kernel, $this->db, new Intraface_Category_Type('shop', 1)); |
|
53
|
|
|
$category->setIdentifier($identifier); |
|
54
|
|
|
$category->setName($name); |
|
55
|
|
|
$category->setParentId($parent); |
|
56
|
|
|
$category->save(); |
|
57
|
|
|
|
|
58
|
|
|
return $category; |
|
59
|
|
|
|
|
60
|
|
|
} |
|
61
|
|
|
} |
|
62
|
|
|
?> |
|
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.