- Nexxpix - OpenStudio */ class DigressivePriceController extends BaseAdminController { /** * @return mixed|\Symfony\Component\HttpFoundation\Response * @throws \Exception */ public function createAction() { if (null !== $response = $this->checkAuth(AdminResources::MODULE, 'DigressivePrice', AccessManager::CREATE)) { return $response; } // Initialize vars $request = $this->getRequest(); $cdpf = new CreateDigressivePriceForm($request); try { $form = $this->validateForm($cdpf); // Dispatch create $event = new DigressivePriceEvent( $form->get('productId')->getData(), $form->get('discount')->getData(), $form->get('quantityFrom')->getData(), $form->get('quantityTo')->getData() ); $this->dispatch('action.createDigressivePrice', $event); } catch (\Exception $e) { $this->setupFormErrorContext( "Add digressive price", $e instanceof FormValidationException ? $this->createStandardFormValidationErrorMessage($e) : $e->getMessage(), $cdpf, $e ); } return $this->generateRedirectFromRoute( 'admin.products.update', array( 'product_id' => $this->getRequest()->get('product_id'), 'current_tab' => 'product_digressive_price' ) ); } /** * @return mixed|\Symfony\Component\HttpFoundation\Response * @throws \Exception */ public function updateAction() { if (null !== $response = $this->checkAuth(AdminResources::MODULE, 'DigressivePrice', AccessManager::UPDATE)) { return $response; } // Initialize vars $request = $this->getRequest(); $udpf = new UpdateDigressivePriceForm($request); try { $form = $this->validateForm($udpf); // Dispatch update $event = new DigressivePriceFullEvent( $form->get('id')->getData(), $form->get('productId')->getData(), $form->get('discount')->getData(), $form->get('quantityFrom')->getData(), $form->get('quantityTo')->getData() ); $this->dispatch('action.updateDigressivePrice', $event); } catch (FormValidationException $e) { $this->setupFormErrorContext( "Add digressive price", $e instanceof FormValidationException ? $this->createStandardFormValidationErrorMessage($e) : $e->getMessage(), $udpf, $e ); } return $this->generateRedirectFromRoute( 'admin.products.update', array( 'product_id' => $this->getRequest()->get('product_id'), 'current_tab' => 'product_digressive_price' ) ); } /** * @return mixed|\Symfony\Component\HttpFoundation\Response * @throws \Exception */ public function deleteAction() { if (null !== $response = $this->checkAuth(AdminResources::MODULE, 'DigressivePrice', AccessManager::DELETE)) { return $response; } // Initialize vars $request = $this->getRequest(); $ddpf = new DeleteDigressivePriceForm($request); try { $form = $this->validateForm($ddpf); // Dispatch delete $event = new DigressivePriceIdEvent($form->get('id')->getData()); $this->dispatch('action.deleteDigressivePrice', $event); } catch (FormValidationException $e) { $this->setupFormErrorContext( "Add digressive price", $e instanceof FormValidationException ? $this->createStandardFormValidationErrorMessage($e) : $e->getMessage(), $ddpf, $e ); } return $this->generateRedirectFromRoute( 'admin.products.update', array( 'product_id' => $this->getRequest()->get('product_id'), 'current_tab' => 'product_digressive_price' ) ); } }