/** * @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()]); }
/** * @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(); }