1 | <?php |
||
11 | class DMSDocumentCartExtension extends DataExtension |
||
|
|||
12 | { |
||
13 | /** |
||
14 | * @var DMSDocumentCartController |
||
15 | */ |
||
16 | private $cartController; |
||
17 | |||
18 | private static $db = array( |
||
19 | 'AllowedInCart' => 'Boolean', |
||
20 | 'MaximumCartQuantity' => 'Int', |
||
21 | // Running total of print requests on this document |
||
22 | 'PrintRequestCount' => 'Int', |
||
23 | ); |
||
24 | |||
25 | private static $summary_fields = array( |
||
26 | 'PrintRequestCount' => 'Print Requests', |
||
27 | ); |
||
28 | |||
29 | /** |
||
30 | * Returns if a Document is permitted to reflect in a cart |
||
31 | * |
||
32 | * @return boolean |
||
33 | */ |
||
34 | public function isAllowedInCart() |
||
38 | |||
39 | public function updateCMSFields(FieldList $fields) |
||
63 | |||
64 | /** |
||
65 | * Increments the number of times a document was printed |
||
66 | * |
||
67 | * @return DMSDocument |
||
68 | */ |
||
69 | public function incrementPrintRequest() |
||
76 | |||
77 | /** |
||
78 | * Checks if a given document already exists within the Cart. True if it does, false otherwise |
||
79 | * |
||
80 | * @return bool |
||
81 | */ |
||
82 | public function isInCart() |
||
86 | |||
87 | /** |
||
88 | * Returns whether the current document has a limit on how many items can be added to a single cart |
||
89 | * |
||
90 | * @return bool |
||
91 | */ |
||
92 | public function getHasQuantityLimit() |
||
96 | |||
97 | /** |
||
98 | * Get the maximum quantity of this document that can be ordered in a single cart |
||
99 | * |
||
100 | * @return int |
||
101 | */ |
||
102 | public function getMaximumQuantity() |
||
106 | |||
107 | /** |
||
108 | * Builds and returns a valid DMSDocumentController URL from the given $action link |
||
109 | * |
||
110 | * @param string $action Can be either 'add', 'remove' or 'checkout' |
||
111 | * |
||
112 | * @return string |
||
113 | * |
||
114 | * @throws DMSDocumentCartException if the provided $action is not allowed. |
||
115 | */ |
||
116 | public function getActionLink($action = 'add') |
||
132 | |||
133 | /** |
||
134 | * Retrieves a DMSDocumentCartController handle |
||
135 | * |
||
136 | * @return DMSDocumentCartController |
||
137 | */ |
||
138 | public function getCartController() |
||
146 | |||
147 | /** |
||
148 | * Retrieves a DMSDocumentCart handle |
||
149 | * |
||
150 | * @return DMSDocumentCart |
||
151 | */ |
||
152 | public function getCart() |
||
156 | |||
157 | /** |
||
158 | * Returns any validation messages that may have been in the session and clears them |
||
159 | * |
||
160 | * @return false |
||
161 | */ |
||
162 | public function getValidationResult() |
||
170 | |||
171 | /** |
||
172 | * Add a "print request count" field to the summary fields for editing a DMS document |
||
173 | * |
||
174 | * @see DMSDocument::getFieldsForFile |
||
175 | * @param FieldGroup $fieldGroup |
||
176 | */ |
||
177 | public function updateFieldsForFile(FieldGroup $fieldGroup) |
||
198 | } |
||
199 |
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.