1 | <?php |
||
6 | class DMSDocumentCart extends ViewableData |
||
|
|||
7 | { |
||
8 | /** |
||
9 | * A handle to the classes' {@link DMSCartBackendInterface} |
||
10 | * |
||
11 | * @var DMSCartBackendInterface |
||
12 | */ |
||
13 | protected $backend; |
||
14 | |||
15 | /** |
||
16 | * Variable to control whether a cart is being updated or not |
||
17 | * |
||
18 | * @var bool |
||
19 | */ |
||
20 | private $viewOnly = false; |
||
21 | |||
22 | /** |
||
23 | * Instantiate a cart backend either by that provided, or a session default |
||
24 | * |
||
25 | * @param DMSCartBackendInterface $backend |
||
26 | * @throws DMSDocumentCartException If a backend was provided but doesn't implement the backend interface |
||
27 | */ |
||
28 | public function __construct($backend = null) |
||
36 | |||
37 | /** |
||
38 | * Returns all the cart items as an array |
||
39 | * |
||
40 | * @return ArrayList |
||
41 | */ |
||
42 | public function getItems() |
||
55 | |||
56 | /** |
||
57 | * Gets a partial caching key that can be used to prevent the getItems method from hitting the database every |
||
58 | * time to check whether a document exists. Includes a hash of the valid items in the cart (including their |
||
59 | * quantity). |
||
60 | * |
||
61 | * @return string |
||
62 | */ |
||
63 | public function getCartSummaryCacheKey() |
||
67 | |||
68 | /** |
||
69 | * Add an {@link DMSRequestItem} object into the cart. |
||
70 | * |
||
71 | * @param DMSRequestItem $item |
||
72 | * |
||
73 | * @return DMSDocumentCart |
||
74 | */ |
||
75 | public function addItem(DMSRequestItem $item) |
||
81 | |||
82 | /** |
||
83 | * Get a {@link DMSRequestItem} object from the cart. |
||
84 | * |
||
85 | * @param int $itemID The ID of the item |
||
86 | * |
||
87 | * @return DMSRequestItem|boolean |
||
88 | */ |
||
89 | public function getItem($itemID) |
||
93 | |||
94 | /** |
||
95 | * Removes a {@link DMSRequestItem} from the cart by it's id |
||
96 | * |
||
97 | * @param DMSRequestItem $item |
||
98 | * |
||
99 | * @return DMSDocumentCart |
||
100 | */ |
||
101 | public function removeItem(DMSRequestItem $item) |
||
107 | |||
108 | /** |
||
109 | * Removes a {@link DMSRequestItem} from the cart by it's id |
||
110 | * |
||
111 | * @param int $itemID |
||
112 | * |
||
113 | * @return DMSDocumentCart |
||
114 | */ |
||
115 | public function removeItemByID($itemID) |
||
121 | |||
122 | /** |
||
123 | * Adjusts (increments, decrements or amends) the quantity of an {@link DMSRequestItem}.' |
||
124 | * A positive $quantity increments the total, whereas a negative value decrements the total. A cart item |
||
125 | * is removed completely if it's value reaches <= 0. |
||
126 | * |
||
127 | * @param int $itemID |
||
128 | * @param int $quantity |
||
129 | * |
||
130 | * @return DMSDocumentCart |
||
131 | */ |
||
132 | public function updateItemQuantity($itemID, $quantity) |
||
147 | |||
148 | /** |
||
149 | * Completely empties a cart |
||
150 | * |
||
151 | * @return DMSDocumentCart |
||
152 | */ |
||
153 | public function emptyCart() |
||
159 | |||
160 | /** |
||
161 | * Checks if a cart is empty. |
||
162 | * Returns true if cart is empty, false otherwise. |
||
163 | * |
||
164 | * @return boolean |
||
165 | */ |
||
166 | public function isCartEmpty() |
||
172 | |||
173 | /** |
||
174 | * Set the backURL to be a Session variable for the current Document Cart |
||
175 | * |
||
176 | * @param string $backURL |
||
177 | * |
||
178 | * @return DMSDocumentCart |
||
179 | */ |
||
180 | public function setBackUrl($backURL) |
||
186 | |||
187 | /** |
||
188 | * Returns the backURL for the current Document Cart |
||
189 | * |
||
190 | * @return string |
||
191 | */ |
||
192 | public function getBackUrl() |
||
196 | |||
197 | /** |
||
198 | * Sets the recipients info as an array (e.g. array('Name'=>'Joe','Surname'=>'Soap')) |
||
199 | * |
||
200 | * @param array $receiverInfo |
||
201 | * |
||
202 | * @return DMSDocumentCart |
||
203 | */ |
||
204 | public function setReceiverInfo($receiverInfo) |
||
210 | |||
211 | /** |
||
212 | * Retrieves the recipients info as an array (e.g. array('Name'=>'Joe','Surname'=>'Soap')) |
||
213 | * |
||
214 | * @return array |
||
215 | */ |
||
216 | public function getReceiverInfo() |
||
220 | |||
221 | /** |
||
222 | * Returns the recipients in a Viewable format |
||
223 | * |
||
224 | * @return ArrayData|bool |
||
225 | */ |
||
226 | public function getReceiverInfoNice() |
||
230 | |||
231 | /** |
||
232 | * Gets the backend handler |
||
233 | * |
||
234 | * @return DMSSessionBackend |
||
235 | */ |
||
236 | public function getBackend() |
||
240 | |||
241 | /** |
||
242 | * Checks if an item exists within a cart. Returns true (if exists) or false. |
||
243 | * |
||
244 | * @param int $itemID |
||
245 | * |
||
246 | * @return bool |
||
247 | */ |
||
248 | public function isInCart($itemID) |
||
252 | |||
253 | /** |
||
254 | * Persists a cart submission to the database |
||
255 | * |
||
256 | * @param Form $form |
||
257 | * |
||
258 | * @return int |
||
259 | */ |
||
260 | public function saveSubmission(Form $form) |
||
278 | |||
279 | /** |
||
280 | * Returns true if the cart is being updated. False otherwise |
||
281 | * @return bool |
||
282 | */ |
||
283 | public function isViewOnly() |
||
287 | |||
288 | /** |
||
289 | * Sets the updating flag |
||
290 | * |
||
291 | * @param bool $viewOnly |
||
292 | * @return DMSDocumentCart |
||
293 | */ |
||
294 | public function setViewOnly($viewOnly) |
||
299 | |||
300 | /** |
||
301 | * Displays a view-only table of the cart items. |
||
302 | * |
||
303 | * @return HTMLText |
||
304 | */ |
||
305 | public function getSummary() |
||
309 | |||
310 | /** |
||
311 | * Utility method to link to the current controllers action |
||
312 | * |
||
313 | * @param string $action |
||
314 | * @return string |
||
315 | */ |
||
316 | public function getLink($action = null) |
||
320 | } |
||
321 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.