/**
  * Publish path
  * Create all needed resources for path to be played
  * 
  * @Route(
  *     "/publish/{id}/{redirect}",
  *     name         = "innova_path_publish",
  *     requirements = {"id" = "\d+"},
  *     options      = {"expose" = true}
  * )
  * @Method({"GET", "PUT"})
  */
 public function publishAction(Path $path, $redirect = false, Request $request)
 {
     $this->pathManager->checkAccess('EDIT', $path);
     $response = array();
     try {
         $this->publishingManager->publish($path);
         // Publish success
         $response['status'] = 'OK';
         $response['messages'] = array();
         $response['data'] = json_decode($path->getStructure());
         // Send updated data
     } catch (\Exception $e) {
         // Error
         $response['status'] = 'ERROR';
         $response['messages'] = array($e->getMessage());
         $response['data'] = null;
     }
     if ($redirect) {
         // That's not an AJAX call, so display a flash message and redirect the User
         $message = 'OK' === $response['status'] ? 'publish_success' : 'publish_error';
         $this->session->getFlashBag()->add('OK' === $response['status'] ? 'success' : 'error', $this->translator->trans($message, array(), 'path_wizards'));
         return new RedirectResponse($request->headers->get('referer'));
     }
     return new JsonResponse($response);
 }
 protected function publishPath(Path $path, OutputInterface $output)
 {
     $datePublished = date('H:i:s');
     try {
         if ($this->publishingManager->publish($path)) {
             $output->writeln('<comment>' . $datePublished . '</comment> <info>[ok]</info> ' . $path->getResourceNode()->getName() . ' (ID = ' . $path->getId() . ')');
         } else {
             $output->writeln('<comment>' . $datePublished . '</comment> <error>[error]</error> ' . $path->getResourceNode()->getName() . ' (ID = ' . $path->getId() . ')');
         }
     } catch (\Exception $e) {
         $output->writeln('<error>' . $e->getMessage() . '</error>');
     }
     return $this;
 }
Example #3
0
 /**
  * Publish path
  * Create all needed resources for path to be played
  * 
  * @Route(
  *     "/publish/{id}",
  *     name         = "innova_path_publish",
  *     requirements = {"id" = "\d+"},
  *     options      = {"expose" = true}
  * )
  * @Method("PUT")
  */
 public function publishAction(Path $path)
 {
     $this->pathManager->checkAccess('EDIT', $path);
     $response = array();
     try {
         $this->publishingManager->publish($path);
         // Publish success
         $response['status'] = 'OK';
         $response['messages'] = array();
         $response['data'] = json_decode($path->getStructure());
         // Send updated data
     } catch (\Exception $e) {
         // Error
         $response['status'] = 'ERROR';
         $response['messages'] = array($e->getMessage());
         $response['data'] = null;
     }
     return new JsonResponse($response);
 }