public function edit() { $group = ProductFileGroup::getInstanceByID((int) $this->request->get('id'), true); return new JSONResponse($group->toArray()); }
/** * @role update */ public function sort() { $target = $this->request->get('target'); preg_match('/_(\\d+)$/', $target, $match); // Get group. foreach ($this->request->get($this->request->get('target'), array()) as $position => $key) { if (empty($key)) { continue; } $file = ProductFile::getInstanceByID((int) $key); $file->position->set((int) $position); if (isset($match[1])) { $file->productFileGroup->set(ProductFileGroup::getInstanceByID((int) $match[1])); } else { $file->productFileGroup->setNull(); } $file->save(); } return new JSONResponse(false, 'success'); }