Inheritance: extends Elcodi\Plugin\CustomShippingBundle\Entity\Interfaces\ShippingPriceRangeInterface, extends Elcodi\Plugin\CustomShippingBundle\Entity\Interfaces\ShippingWeightRangeInterface, extends Elcodi\Component\Core\Entity\Interfaces\EnabledInterface, extends Elcodi\Component\Core\Entity\Interfaces\IdentifiableInterface
コード例 #1
0
 /**
  * Edit and Saves category
  *
  * @param FormInterface          $form          Form
  * @param CarrierInterface       $carrier       Carrier
  * @param ShippingRangeInterface $shippingRange Shipping range
  * @param boolean                $isValid       Is valid
  *
  * @return RedirectResponse Redirect response
  *
  * @Route(
  *      path = "/{id}",
  *      name = "admin_shipping_range_edit",
  *      requirements = {
  *          "id" = "\d+",
  *      },
  *      methods = {"GET"}
  * )
  * @Route(
  *      path = "/{id}/update",
  *      name = "admin_shipping_range_update",
  *      requirements = {
  *          "id" = "\d+",
  *      },
  *      methods = {"POST"}
  * )
  *
  * @Route(
  *      path = "/new",
  *      name = "admin_shipping_range_new",
  *      methods = {"GET"}
  * )
  * @Route(
  *      path = "/new/update",
  *      name = "admin_shipping_range_save",
  *      methods = {"POST"}
  * )
  *
  * @EntityAnnotation(
  *      class = "elcodi.entity.carrier.class",
  *      mapping = {
  *          "id" = "~carrierId~"
  *      },
  *      name = "carrier"
  * )
  * @EntityAnnotation(
  *      class = {
  *          "factory" = "elcodi_plugin.custom_shipping.factory.shipping_range",
  *          "method" = "create",
  *          "static" = false
  *      },
  *      mapping = {
  *          "id" = "~id~"
  *      },
  *      mappingFallback = true,
  *      name = "shippingRange",
  *      persist = true
  * )
  * @FormAnnotation(
  *      class = "elcodi_plugin_custom_shipping_form_type_shipping_range",
  *      name  = "form",
  *      entity = "shippingRange",
  *      handleRequest = true,
  *      validate = "isValid"
  * )
  *
  * @Template
  */
 public function editAction(FormInterface $form, CarrierInterface $carrier, ShippingRangeInterface $shippingRange, $isValid)
 {
     if ($isValid) {
         /**
          * We must add the default Carrier
          */
         $shippingRange->setCarrier($carrier);
         $this->flush($shippingRange);
         $this->addFlash('success', $this->get('translator')->trans('admin.shipping_range.saved'));
         return $this->redirectToRoute('admin_carrier_edit', ['id' => $carrier->getId()]);
     }
     return ['shippingRange' => $shippingRange, 'carrier' => $carrier, 'form' => $form->createView()];
 }
コード例 #2
0
 /**
  * Given ShippingRange zones are satisfied by a cart,
  *
  * @param CartInterface          $cart          Cart
  * @param ShippingRangeInterface $shippingRange Carrier Range
  *
  * @return boolean ShippingRange is satisfied by cart
  */
 private function isShippingRangeZonesSatisfiedByCart(CartInterface $cart, ShippingRangeInterface $shippingRange)
 {
     $deliveryAddress = $cart->getDeliveryAddress();
     $shippingRange->getToZone()->getName();
     return $deliveryAddress === null || $this->zoneMatcher->isAddressContainedInZone($deliveryAddress, $shippingRange->getToZone());
 }