示例#1
0
 /**
  * @param \Symfony\Component\HttpFoundation\Request $request
  *
  * @return array|\Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function addAction(Request $request)
 {
     $form = $this->getFactory()->createCarrierForm()->handleRequest($request);
     if ($form->isValid()) {
         $data = $form->getData();
         $carrierTransfer = new ShipmentCarrierTransfer();
         $carrierTransfer->fromArray($data, true);
         $this->getFacade()->createCarrier($carrierTransfer);
         return $this->redirectResponse('/shipment');
     }
     return $this->viewResponse(['form' => $form->createView()]);
 }
示例#2
0
 /**
  * @param \Generated\Shared\Transfer\ShipmentCarrierTransfer $carrierTransfer
  *
  * @return int
  */
 public function create(ShipmentCarrierTransfer $carrierTransfer)
 {
     $carrierEntity = new SpyShipmentCarrier();
     $carrierEntity->setName($carrierTransfer->getName())->setIsActive($carrierTransfer->getIsActive())->save();
     return $carrierEntity->getPrimaryKey();
 }