Deprecated : Optional parameter $limit declared before required parameter $order is implicitly treated as a required parameter in /home/u536844918/domains/danzelklassic.com/siteFiles/lib/boab/cms-bundle/src/Repository/ContentRepositoryInterface.php on line 33
Deprecated : Optional parameter $limit declared before required parameter $order is implicitly treated as a required parameter in /home/u536844918/domains/danzelklassic.com/siteFiles/lib/boab/cms-bundle/src/Repository/ContentRepository.php on line 316
Deprecated : Optional parameter $orderBy declared before required parameter $order is implicitly treated as a required parameter in /home/u536844918/domains/danzelklassic.com/siteFiles/lib/boab/cms-bundle/src/Repository/ContentRepository.php on line 316
Deprecated : Optional parameter $data declared before required parameter $page is implicitly treated as a required parameter in /home/u536844918/domains/danzelklassic.com/siteFiles/lib/boab/cms-bundle/src/Manager/ContentTypeManager.php on line 178
Symfony Profiler
<?php
namespace Boab\CmsBundle\Controller ;
use Symfony\Component\HttpFoundation\Request ;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException ;
use Boab\CmsBundle\Controller\BaseController ;
use Boab\CmsBundle\Manager\ContentTypeManagerInterface ;
use Boab\CmsBundle\Event\PageShowEvent ;
use Boab\CmsBundle\View\Annotation\Template ;
use Boab\CmsBundle\Repository\ContentRepositoryInterface ;
use Boab\CmsBundle\Repository\TermRepositoryInterface ;
use Boab\CmsBundle\Events ;
use Boab\CmsBundle\Entity\RouteInterface ;
use Symfony\Component\HttpFoundation\JsonResponse ;
use Symfony\Component\Serializer\SerializerInterface ;
/**
* @template(theme="kantua")
*/
class ContentController extends BaseController
{
private $contentRepository ;
private $contentTypeManager ;
private $termRepository ;
public function __construct (
ContentRepositoryInterface $contentRepository ,
ContentTypeManagerInterface $contentTypeManager ,
TermRepositoryInterface $termRepository
)
{
$this -> contentRepository = $contentRepository ;
$this -> contentTypeManager = $contentTypeManager ;
$this -> termRepository = $termRepository ;
}
/**
* Get List of contents
*
* @param Request $request
*
* @param [type] $routeDocument
*
* @return void
*/
public function listAction ( Request $request , RouteInterface $routeDocument , $template )
{
$pageNumber = $request -> get ( 'page' , 1 );
$form = $this -> contentTypeManager -> getSearchForm ( $routeDocument -> getContentType (),[
"action" => $this -> router -> generate ( "app.search_content" , [ "type" => $routeDocument -> getContentType ()])
]);
$view = $this -> viewManager -> load ( $template );
if( $form ){
$view -> form = $form -> createView ();
}
$pagination = $this -> contentTypeManager -> getCollection ( $request , $pageNumber );
$view -> pagination = $pagination ;
$view -> collection = $pagination -> getItems ();
$view -> routeDocument = $routeDocument ;
$view -> pageTitle = $routeDocument -> getTitle ();
$view -> layout = $this -> themeManager -> getLayout ( $routeDocument -> getLayoutType ());
return $view ;
}
/**
* Get List of contents
*
* @param Request $request
*
* @param [type] $routeDocument
*
* @return void
*/
public function showAction ( Request $request , RouteInterface $routeDocument , $template = null )
{
$content = $this -> contentTypeManager -> getContent ( $request );
if(! $content ){
throw new NotFoundHttpException ( 'Page not found' );
}
$view = $this -> viewManager -> load ( $template );
$event = new PageShowEvent ( $request , $content );
$this -> eventDispatcher -> dispatch ( $event , Events :: PAGE_SHOW );
$view -> content = $content ;
$view -> pageTitle = $content -> getTitle ();
$view -> layout = $this -> themeManager -> getLayout ( $routeDocument -> getLayoutType ());
return $view ;
}
/**
* Get List of contents related to a category
*
* @param Request $request
*
* @param [type] $routeDocument
*
*/
public function categoryAction ( Request $request , RouteInterface $routeDocument , $template )
{
$term = $this -> termRepository -> findTermByRouteId ( $routeDocument -> getId ());
$pagination = $this -> contentRepository -> findContentByTermId ( $term -> getId ());
$view = $this -> viewManager -> load ( $term -> getTemplate () ? $term -> getTemplate () : $template );
$view -> pageTitle = $routeDocument -> getTitle ();
$view -> pagination = $pagination ;
$view -> collection = $pagination -> getItems ();
$view -> term = $term ;
//$view->layout = $this->themeManager->getLayout($routeDocument->getLayoutType());
return $view ;
}
public function searchAction ( Request $request , SerializerInterface $serializer , string $type )
{
$form = $this -> contentTypeManager -> getSearchForm ( $type );
$page = $request -> get ( "page" , 1 );
$form -> handleRequest ( $request );
if( $form -> isSubmitted () && $form -> isValid ()){
$collection = $this -> contentTypeManager -> filterResults ( $form -> getData (), $page );
return new JsonResponse ([
"query" => $form -> getData ()[ "query" ],
"data" => $serializer -> normalize ( $collection , 'json' )
]);
}
return new JsonResponse ([
"status" => "error" ,
"message" => "Something went wrong" ,
]);
}
}