Example #1
0
 /**
  * @param object|null $resource
  *
  * @return FormInterface
  */
 public function getForm($resource = null)
 {
     if ($this->config->isApiRequest()) {
         return $this->container->get('form.factory')->createNamed('', $this->config->getFormType(), $resource);
     }
     return $this->createForm($this->config->getFormType(), $resource);
 }
Example #2
0
 /**
  * @param object|null $resource
  *
  * @return FormInterface
  */
 public function getForm($resource = null)
 {
     if ($this->config->isApiRequest()) {
         return $this->container->get('form.factory')->createNamed('', $this->config->getFormType(), $resource);
     }
     $form = $this->config->getFormType();
     if (strpos($form, '\\') !== false) {
         $form = new $form();
     }
     return $this->createForm($form, $resource);
 }
Example #3
0
 /**
  * @param Request $request
  * @param integer $movement
  *
  * @return RedirectResponse
  */
 protected function move(Request $request, $movement)
 {
     $resource = $this->findOr404($request);
     $this->domainManager->move($resource, $movement);
     if ($this->config->isApiRequest()) {
         if ($resource instanceof ResourceEvent) {
             throw new HttpException($resource->getErrorCode(), $resource->getMessage());
         }
         return $this->handleView($this->view($resource, 204));
     }
     return $this->redirectHandler->redirectToIndex();
 }
Example #4
0
 /**
  * @param Request $request
  * @param boolean $enabled
  *
  * @return RedirectResponse|Response
  */
 protected function toggle(Request $request, $enabled)
 {
     $this->isGrantedOr403('update');
     $resource = $this->findOr404($request);
     $resource->setEnabled($enabled);
     $this->domainManager->update($resource, $enabled ? 'enable' : 'disable');
     if ($this->config->isApiRequest()) {
         if ($resource instanceof ResourceEvent) {
             throw new HttpException($resource->getErrorCode(), $resource->getMessage());
         }
         return $this->handleView($this->view($resource, 204));
     }
     return $this->redirectHandler->redirectToIndex();
 }