Exemplo n.º 1
0
 public function preset($id)
 {
     // Validate only exists for JSON.
     if (empty($this->params['ajax'])) {
         $this->undefined();
     }
     $preset = LayoutObject::preset($id);
     if (!$preset) {
         throw new \RuntimeException('Preset not found', 404);
     }
     $layout = new LayoutObject($id, $preset);
     $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->prepareWidths()->toJson(), 'deleted' => $deleted, 'message' => $message]);
 }