Controller/ResourceController.php
public function createAction(Request $request)
    {
        $saveAndClose = $request->get("save_and_close");
        
        $resource = $this->createNew();
        $form = $this->getForm($resource);

        if ($request->isMethod('POST') && $form->submit($request)->isValid()) {
            $resource = $this->domainManager->create($resource);

            if (null === $resource) {
                return $this->redirectHandler->redirectToIndex();
            }

            if($saveAndClose !== null) {
                return $this->redirectHandler->redirectTo($resource);
            }else {
                return $this->redirectHandler->redirectToRoute($this->config->getRedirectRoute('update'),['id' => $resource->getId()]);
            }
        }

        if ($this->config->isApiRequest()) {
            return $this->handleView($this->view($form));
        }

        $view = $this
            ->view()
            ->setTemplate($this->config->getTemplate('create.html'))
            ->setData(array(
                $this->config->getResourceName() => $resource,
                'form'                           => $form->createView()
            ))
        ;

        return $this->handleView($view);
    }
public function createAction(Request $request)
    {
        $saveAndClose = $request->get("save_and_close");
        
        $resource = $this->createNew();
        $form = $this->getForm($resource);

        if ($request->isMethod('POST') && $form->submit($request)->isValid()) {
            $resource = $this->domainManager->create($resource);

            if (null === $resource) {
                return $this->redirectHandler->redirectToIndex();
            }

            if($saveAndClose !== null) {
                return $this->redirectHandler->redirectTo($resource);
            }else {
                return $this->redirectHandler->redirectToRoute($this->config->getRedirectRoute('update'),['id' => $resource->getId()]);
            }
        }

        if ($this->config->isApiRequest()) {
            return $this->handleView($this->view($form));
        }

        $view = $this
            ->view()
            ->setTemplate($this->config->getTemplate('create.html'))
            ->setData(array(
                $this->config->getResourceName() => $resource,
                'form'                           => $form->createView()
            ))
        ;

        return $this->handleView($view);
    }
@param Request $request

@return RedirectResponse|Response