Exemplo n.º 1
0
 public function preset($id)
 {
     // Validate only exists for JSON.
     if (empty($this->params['ajax'])) {
         $this->undefined();
     }
     $layout = LayoutObject::preset($id);
     if (!$layout) {
         throw new \RuntimeException('Preset not found', 404);
     }
     $layout = new LayoutObject($id, $layout);
     $input = $this->request->post->getJson('layout');
     $deleted = isset($input) ? $layout->clearSections()->copySections($input) : [];
     $message = $deleted ? $this->container['admin.theme']->render('@gantry-admin/ajax/particles-loss.html.twig', ['particles' => $deleted]) : null;
     return new JsonResponse(['title' => ucwords(trim(str_replace('_', ' ', $id))), 'preset' => json_encode($layout->preset), 'data' => $layout->toJson(), 'deleted' => $deleted, 'message' => $message]);
 }
Exemplo n.º 2
0
 public function preset($id)
 {
     // Validate only exists for JSON.
     if (empty($this->params['ajax'])) {
         $this->undefined();
     }
     $layout = LayoutObject::preset($id);
     if (!$layout) {
         throw new \RuntimeException('Preset not found', 404);
     }
     $layout = new LayoutObject($id, $layout);
     $deleted = isset($_POST['layout']) ? $layout->clearSections()->copySections(json_decode($_POST['layout'])) : [];
     $message = $deleted ? sprintf('Warning: Following sections could not be found from the new layout: %s.', implode(', ', $deleted)) : null;
     return new JsonResponse(['title' => ucwords(trim(str_replace('_', ' ', $id))), 'preset' => json_encode($layout->preset), 'data' => $layout->toJson(), 'deleted' => $deleted, 'message' => $message]);
 }