get('agrid.content_manager')->createContent(); if ($content == null) return null; return $this->redirectToRoute('agrid_content_edit',[ 'content'=>$content->getId(), ]); } public function editContent(ContainerInterface $container, AGridContent $content, string $mode, string $lang){ // $routingElement = $content->getMapping($lang); // // if(!$routingElement instanceof RoutingElement) // $routingElement = $container->get('agrid.route_manager')->create($content,$lang); return $this->render('@AGrid/agrid_content/content.html.twig', [ 'content' => $content, 'mode' => $mode, 'lang' => $lang, 'metadatas' => '' ]); } public function addRow(AGridContent $content, ContainerInterface $container,Request $request ){ $col = null; if($request->get('col') > 0) $col = $container->get('agrid.col_manager')->getById($request->get('col')); try { $row = $container->get('agrid.content_manager')->addRow($content, $col); } catch (LoaderError $e) { } catch (RuntimeError $e) { } catch (SyntaxError $e) { } // try { // $container->get('agrid.content_manager')->makeCache($content); // } catch (LoaderError $e) { // } catch (RuntimeError $e) { // } catch (SyntaxError $e) { // } return $this->render('@AGrid/include/row.html.twig',[ 'content'=>$content, 'row'=>$row, 'mode'=> $request->get('mode'), 'lang'=> $request->get('lang') ]); } /** * @param AGridContent $content * @param ContainerInterface $container * @param Request $request * @return Response */ public function colsSwitch(AGridContent $content, ContainerInterface $container, Request $request) { $temp = explode('-',$request->get('row')); $row = $container->get('agrid.row_manager')->getById($temp[1]); if($row instanceof AGridRow) { $temp = explode('-', $request->get('col')); $container->get('agrid.col_manager')->changeParentRow($temp[1], $row); } // try { // $container->get('agrid.content_manager')->makeCache($content); // } catch (LoaderError $e) { // } catch (RuntimeError $e) { // } catch (SyntaxError $e) { // } return new Response("OK"); } public function saveEditor(AGridContent $content, ContainerInterface $container, Request $request){ $id_module = $request->get('module'); $data = $request->get('html'); $lang = $request->get('lang'); $container->get('agrid.module_manager')->saveHTML($id_module, $lang , $data); // try { // $container->get('agrid.content_manager')->makeCache($content); // } catch (LoaderError $e) { // } catch (RuntimeError $e) { // } catch (SyntaxError $e) { // } return new Response(); } public function rowsOrder(AGridContent $content, ContainerInterface $container, Request $request) { $rows = $request->get('rows'); foreach ($rows as $value=>$col_temp) { $temp = explode('-',$col_temp); $container->get('agrid.row_manager')->changeOrder($temp[1], $value); } // try { // $container->get('agrid.content_manager')->makeCache($content); // } catch (LoaderError $e) { // } catch (RuntimeError $e) { // } catch (SyntaxError $e) { // } return new Response("OK"); } public function deleteRow(AGridContent $content, ContainerInterface $container, Request $request) { $row_id = $request->get('row'); $row = $container->get('agrid.row_manager')->getById($row_id); if($row instanceof AGridRow) $container->get('agrid.row_manager')->delete($row); // try { // $container->get('agrid.content_manager')->makeCache($content); // } catch (LoaderError $e) { // } catch (RuntimeError $e) { // } catch (SyntaxError $e) { // } return new Response(); } /** * @param ContainerInterface $container * @param AGridContent $content * @param Request $request * @return Response */ public function addCol(ContainerInterface $container,AGridContent $content, Request $request) { $row = $container->get('agrid.row_manager')->getById($request->get('row')); if($row instanceof AGridRow) { $pageColModule = $container->get('agrid.content_manager')->addCol($content, $row); return $this->render('@AGrid/include/row.html.twig',[ 'content' => $content, 'pageColModule'=>$pageColModule, 'row'=>$row, 'mode'=> $request->get('mode'), 'lang'=> $request->get('lang') ]); } // $container->get('agrid.content_manager')->makeCache($content); return new Response('Error'); } public function colSize(AGridContent $content, ContainerInterface $container, Request $request) { $classes = $container->get('agrid.col_manager')->setSize((int)$request->get('col'),$request->get('mode'), (int)$request->get('size') ); return new Response($classes); } public function colsOrder(AGridContent $content,ContainerInterface $container, Request $request) { $temp = explode('-',$request->get('row')); $row = $container->get('agrid.row_manager')->getById($temp[1]); if($row instanceof AGridRow){ $cols = $request->get('cols'); foreach ($cols as $value=>$col_temp){ $temp = explode('-',$col_temp); $container->get('agrid.col_manager')->changeOrder($temp[1], $value); } } // try { // $container->get('agrid.content_manager')->makeCache($content); // } catch (LoaderError $e) { // } catch (RuntimeError $e) { // } catch (SyntaxError $e) { // } return new Response("OK"); } /** * @param AGridContent $content * @param ContainerInterface $container * @param Request $request * @return Response */ public function deleteCol(AGridContent $content, ContainerInterface $container, Request $request) { $col_id = $request->get('col'); $col = $container->get('agrid.col_manager')->getById($col_id); if($col instanceof AGridCol) $container->get('agrid.col_manager')->delete($col); // $container->get('agrid.content_manager')->makeCache($content); return new Response(); } }