Beispiel #1
0
 public function configure()
 {
     if (null !== ($response = $this->checkAuth(array(AdminResources::MODULE), array('LocalPickup'), AccessManager::UPDATE))) {
         return $response;
     }
     $form = $this->createForm('localpickup.form');
     $errmes = null;
     try {
         $vform = $this->validateForm($form);
         $price = $vform->get('price')->getData();
         if (preg_match("#^\\d\\.?\\d*\$#", $price)) {
             $newprice = new LocalPickupShipping();
             $newprice->setPrice((double) $price)->save();
         } else {
             $errmes = Translator::getInstance()->trans("price must be a number !");
         }
         return $this->redirectToConfigurationPage();
     } catch (\Exception $e) {
         $errmes = $this->createStandardFormValidationErrorMessage($e);
     }
     if (null !== $errmes) {
         $this->setupFormErrorContext('configuration', $errmes, $form);
         $response = $this->render("module-configure", ['module_code' => 'LocalPickup']);
     }
     return $response;
 }
 public function configure()
 {
     if (null !== ($response = $this->checkAuth(array(AdminResources::MODULE), array('LocalPickup'), AccessManager::UPDATE))) {
         return $response;
     }
     $form = new \LocalPickup\Form\SetDeliveryPrice($this->getRequest());
     $errmes = "";
     try {
         $vform = $this->validateForm($form);
         $price = $vform->get('price')->getData();
         if (preg_match("#^\\d\\.?\\d*\$#", $price)) {
             $newprice = new LocalPickupShipping();
             $newprice->setPrice((double) $price)->save();
         } else {
             $errmes = Translator::getInstance()->trans("price must be a number !");
         }
     } catch (\Exception $e) {
         $errmes = $e->getMessage();
     }
     $this->redirectToRoute("admin.module.configure", array("errmes" => $errmes), array('module_code' => "LocalPickup", '_controller' => 'Thelia\\Controller\\Admin\\ModuleController::configureAction'));
 }
 /**
  * Exclude object from result
  *
  * @param ChildLocalPickupShipping $localPickupShipping Object to remove from the list of results
  *
  * @return ChildLocalPickupShippingQuery The current query, for fluid interface
  */
 public function prune($localPickupShipping = null)
 {
     if ($localPickupShipping) {
         $this->addUsingAlias(LocalPickupShippingTableMap::ID, $localPickupShipping->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }