public function postCampaignAction(Request $request)
    {
        $campaign = new Campaign();

        $campaignType = $this->get('campaignchain.core.form.type.campaign');
        $campaignType->setView('rest');
        $campaignType->setBundleName(ScheduledCampaignController::BUNDLE_NAME);
        $campaignType->setModuleIdentifier(ScheduledCampaignController::MODULE_IDENTIFIER);

        $form = $this->createForm($campaignType, $campaign);

        $form->handleRequest($request);

        if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();

            // Make sure that data stays intact by using transactions.
            try {
                $em->getConnection()->beginTransaction();

                $em->persist($campaign);

                // We need the campaign ID for storing the hooks. Hence we must flush here.
                $em->flush();

                /** @var HookService $hookService */
                $hookService = $this->get('campaignchain.core.hook');
                $hookService->processHooks(ScheduledCampaignController::BUNDLE_NAME, ScheduledCampaignController::MODULE_IDENTIFIER, $campaign, $form, true);
                $campaign = $hookService->getEntity();
                $em->flush();

                $em->getConnection()->commit();
            } catch (\Exception $e) {
                $em->getConnection()->rollback();

                return $this->errorResponse($e->getMessage());
            }

            return $this->response(['campaign' => ['id' => $campaign->getId()]]);
        }

        return $this->errorResponse($form);
    }