1 | <?php |
||
11 | class CatalogManagerController extends AbstractActionController |
||
12 | { |
||
13 | protected $partialDir = '/speck-catalog/catalog-manager/partial/'; |
||
14 | |||
15 | public function init() |
||
19 | |||
20 | //find categories/products that match search terms |
||
21 | public function categorySearchChildrenAction() |
||
22 | { |
||
23 | $type = $this->params('type'); |
||
24 | $children = $this->getService($type)->getAll(); |
||
25 | |||
26 | $viewVars = array('children' => $children, 'type' => $type); |
||
27 | return $this->partialView('category-search-children', $viewVars); |
||
28 | } |
||
29 | |||
30 | public function newProductAction() |
||
31 | { |
||
32 | $this->init(); |
||
33 | $product = $this->getService('product')->getModel(); |
||
34 | return new ViewModel(array('product' => $product)); |
||
35 | } |
||
36 | |||
37 | public function categoryTreePreviewAction() |
||
38 | { |
||
39 | $siteId = $this->params('siteid'); |
||
40 | $categoryService = $this->getService('category'); |
||
41 | $categories = $categoryService->getCategoriesForTreePreview($siteId); |
||
42 | |||
43 | $viewVars = array('categories' => $categories); |
||
44 | return $this->partialView('category-tree', $viewVars); |
||
45 | } |
||
46 | |||
47 | public function productsAction() |
||
48 | { |
||
49 | $service = $this->getService('product'); |
||
50 | |||
51 | $this->init(); |
||
52 | $config = array( |
||
53 | 'p' => $this->params('p') ?: 1, |
||
54 | 'n' => 40, |
||
55 | ); |
||
56 | $service->usePaginator($config); |
||
57 | $query = $this->params()->fromQuery('query'); |
||
58 | if ($query) { |
||
59 | $products = $service->search($query); |
||
60 | } else { |
||
61 | $products = $service->getAll(); |
||
62 | } |
||
63 | return new ViewModel(array('products' => $products, 'query' => $query)); |
||
64 | } |
||
65 | |||
66 | public function categoriesAction() |
||
67 | { |
||
68 | $this->init(); |
||
69 | $sites = $this->getService('sites')->getAll(); |
||
70 | return new ViewModel(array('sites' => $sites)); |
||
71 | } |
||
72 | |||
73 | public function productAction() |
||
74 | { |
||
75 | $this->init(); |
||
76 | $productService = $this->getService('product'); |
||
77 | $product = $productService->getFullProduct($this->params('id')); |
||
78 | |||
79 | $vars = array('product' => $product); |
||
80 | return new ViewModel($vars); |
||
81 | } |
||
82 | |||
83 | |||
84 | //returns main view variable(product/option/etc) |
||
85 | protected function persist($class, $form) |
||
103 | |||
104 | public function updateProductAction() |
||
105 | { |
||
106 | $formData = $this->params()->fromPost(); |
||
107 | $form = $this->getService('form')->getForm('product', null, $formData); |
||
108 | |||
109 | if ($form->isValid()) { |
||
110 | $product = $this->persist('product', $form); |
||
111 | return $this->getResponse()->setContent($product->getProductId()); |
||
112 | } |
||
113 | |||
114 | return $this->partialView('product', array('product' => $product)); |
||
115 | } |
||
116 | |||
117 | public function updateRecordAction() |
||
118 | { |
||
119 | $class = $this->params('class'); |
||
120 | $formData = $this->params()->fromPost(); |
||
121 | $form = $this->getService('form')->getForm($class, null, $formData); |
||
122 | |||
123 | if ($form->isValid()) { |
||
124 | $entity = $this->persist($class, $form); |
||
125 | } else { |
||
126 | $entity = $this->getService($class)->getEntity($formData); |
||
127 | } |
||
128 | |||
129 | $partial = $this->dash($class); |
||
130 | $viewVars = array(lcfirst($this->camel($class)) => $entity); |
||
131 | return $this->partialView($partial, $viewVars); |
||
132 | } |
||
133 | |||
134 | public function updateFormAction() |
||
135 | { |
||
136 | $data = $this->params()->fromPost(); |
||
137 | $form = $this->getService('form')->getForm($this->params('class'), null, $data); |
||
138 | $helper = $this->getViewHelper('speckCatalogForm'); |
||
139 | |||
140 | $html = $helper->renderFormMessages($form); |
||
141 | return $this->getResponse()->setContent($html); |
||
142 | } |
||
143 | |||
144 | public function getViewHelper($helperName) |
||
148 | |||
149 | public function findAction() |
||
150 | { |
||
151 | $post = $this->params()->fromPost(); |
||
152 | |||
153 | if (!isset($post['query'])) { |
||
154 | $search = $this->partialDir . 'search/' . $this->dash($post['child_name']); |
||
155 | $view = new ViewModel(array( |
||
156 | 'fields' => $post, |
||
157 | 'searchPartial' => $search |
||
186 | |||
187 | public function foundAction() |
||
206 | |||
207 | public function sortAction() |
||
226 | |||
227 | public function removeChildAction() |
||
245 | |||
246 | public function getService($name) |
||
251 | |||
252 | //return the partial for a new record. |
||
253 | public function newPartialAction() |
||
269 | |||
270 | public function partialView($partial, array $viewVars = null) |
||
278 | |||
279 | protected function dash($name) |
||
284 | |||
285 | protected function camel($name) |
||
290 | } |
||
291 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.