@@ 46-69 (lines=24) @@ | ||
43 | * |
|
44 | * @throws ShopsException |
|
45 | */ |
|
46 | public function add($shelfData, $shelfBanner, $shelfName) |
|
47 | { |
|
48 | if (is_callable($shelfData)) { |
|
49 | $shelf = call_user_func($shelfData, new ShelfData()); |
|
50 | if (!($shelf instanceof ShelfData)) { |
|
51 | throw new ShopsException('必须返回 Shop\Data\Shelf class'); |
|
52 | } |
|
53 | $shelfData = $shelf->toArray(); |
|
54 | } |
|
55 | ||
56 | //todo 判断出bug |
|
57 | //if (!is_array($shelfData)) throw new ShopsException('$shelfData 必须是数组'); |
|
58 | ||
59 | $this->response = $this->http->jsonPost(self::API_ADD, array( |
|
60 | 'shelf_data' => array( |
|
61 | 'module_infos' => $shelfData, |
|
62 | ), |
|
63 | 'shelf_banner' => $shelfBanner, |
|
64 | 'shelf_name' => $shelfName, |
|
65 | )); |
|
66 | ||
67 | return $this->getResponse(); |
|
68 | } |
|
69 | ||
70 | /** |
|
71 | * 删除货架 |
|
72 | * |
|
@@ 98-119 (lines=22) @@ | ||
95 | * |
|
96 | * @throws ShopsException |
|
97 | */ |
|
98 | public function update($shelfData, $shelfId, $shelfBanner, $shelfName) |
|
99 | { |
|
100 | if (is_callable($shelfData)) { |
|
101 | $shelf = call_user_func($shelfData, new ShelfData()); |
|
102 | if (!($shelf instanceof ShelfData)) { |
|
103 | throw new ShopsException('必须返回 Shop\Data\Shelf class'); |
|
104 | } |
|
105 | $shelfData = $shelf->toArray(); |
|
106 | } |
|
107 | ||
108 | //todo 判断出bug |
|
109 | //if (!is_array($shelfData)) throw new ShopsException('$shelfData 必须是数组'); |
|
110 | ||
111 | $this->response = $this->http->jsonPost(self::API_UPDATE, array( |
|
112 | 'shelf_id' => $shelfId, |
|
113 | 'shelf_data' => array( |
|
114 | 'module_infos' => $shelfData, |
|
115 | ), |
|
116 | 'shelf_banner' => $shelfBanner, |
|
117 | 'shelf_name' => $shelfName, |
|
118 | )); |
|
119 | ||
120 | return $this->getResponse(); |
|
121 | } |
|
122 |