2025-01-09 10:21:26 +03:30
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Controller;
|
|
|
|
|
|
2025-01-10 20:17:54 +03:30
|
|
|
use App\Entity\Cat;
|
2025-01-09 10:21:26 +03:30
|
|
|
use App\Entity\Post;
|
2025-01-10 20:17:54 +03:30
|
|
|
use App\Entity\Tree;
|
2025-01-09 10:21:26 +03:30
|
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
|
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
|
use Symfony\Component\Routing\Attribute\Route;
|
|
|
|
|
|
|
|
|
|
class PageController extends AbstractController
|
|
|
|
|
{
|
|
|
|
|
#[Route('/page/{url}', name: 'app_page')]
|
2025-01-09 15:31:04 +03:30
|
|
|
public function app_page(EntityManagerInterface $entityManagerInterface, string $url): Response
|
2025-01-09 10:21:26 +03:30
|
|
|
{
|
2025-01-09 15:31:04 +03:30
|
|
|
$item = $entityManagerInterface->getRepository(Post::class)->findByUrlFilterCat($url, 'plain');
|
|
|
|
|
if (!$item)
|
|
|
|
|
throw $this->createNotFoundException();
|
|
|
|
|
return $this->render('post/page.html.twig', [
|
|
|
|
|
'item' => $item,
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[Route('/blog/{page}', name: 'app_blog_home')]
|
2025-01-10 20:17:54 +03:30
|
|
|
public function app_blog_home(EntityManagerInterface $entityManagerInterface, $page = 1): Response
|
2025-01-09 15:31:04 +03:30
|
|
|
{
|
2025-02-24 16:42:42 +03:30
|
|
|
$perpage = 9;
|
2025-01-10 20:17:54 +03:30
|
|
|
$posts = $entityManagerInterface->getRepository(Post::class)->findByCat('blog',$perpage,$page);
|
|
|
|
|
$cat = $entityManagerInterface->getRepository(Cat::class)->findOneBy(['code'=>'blog']);
|
|
|
|
|
$count = $entityManagerInterface->getRepository(Post::class)->count(['cat'=>$cat]);
|
|
|
|
|
if(fmod($count,$perpage) == 0){
|
|
|
|
|
$maxpages = $count/$perpage;
|
|
|
|
|
}
|
|
|
|
|
else{
|
|
|
|
|
$maxpages = ($count/$perpage) + 1;
|
|
|
|
|
}
|
|
|
|
|
$maxpages = $count / $perpage;
|
2025-01-09 15:31:04 +03:30
|
|
|
return $this->render('post/blog_home.html.twig', [
|
2025-01-10 20:17:54 +03:30
|
|
|
'posts' => $posts,
|
|
|
|
|
'page' => $page,
|
|
|
|
|
'perpage'=> $perpage,
|
|
|
|
|
'count' => $count,
|
|
|
|
|
'maxpages' => $maxpages
|
2025-01-09 15:31:04 +03:30
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[Route('/blog/post/{url}', name: 'app_blog_post')]
|
|
|
|
|
public function app_blog_post(EntityManagerInterface $entityManagerInterface, string $url): Response
|
|
|
|
|
{
|
|
|
|
|
$item = $entityManagerInterface->getRepository(Post::class)->findByUrlFilterCat($url, 'blog');
|
|
|
|
|
if (!$item)
|
|
|
|
|
throw $this->createNotFoundException();
|
2025-01-10 20:17:54 +03:30
|
|
|
if (!$item->getViews())
|
|
|
|
|
$item->setViews(1);
|
|
|
|
|
else
|
|
|
|
|
$item->setViews($item->getViews() + 1);
|
|
|
|
|
$entityManagerInterface->persist($item);
|
|
|
|
|
|
|
|
|
|
return $this->render('post/blog_post.html.twig', [
|
|
|
|
|
'item' => $item,
|
|
|
|
|
'posts' => $entityManagerInterface->getRepository(Post::class)->findByCat('blog',3),
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[Route('/api_docs/{url}', name: 'app_api_docs')]
|
|
|
|
|
public function app_api_docs(EntityManagerInterface $entityManagerInterface, string $url='home'): Response
|
|
|
|
|
{
|
|
|
|
|
$item = $entityManagerInterface->getRepository(Post::class)->findByUrlFilterCat($url, 'api');
|
|
|
|
|
if (!$item)
|
|
|
|
|
throw $this->createNotFoundException();
|
|
|
|
|
|
|
|
|
|
//get list of trees
|
|
|
|
|
$tress = $entityManagerInterface->getRepository(Tree::class)->findAllByCat('api');
|
|
|
|
|
return $this->render('post/api_docs.html.twig', [
|
|
|
|
|
'item' => $item,
|
|
|
|
|
'trees' => $tress,
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[Route('/guide/{url}', name: 'app_guide')]
|
|
|
|
|
public function app_guide(EntityManagerInterface $entityManagerInterface, string $url='home'): Response
|
|
|
|
|
{
|
|
|
|
|
$item = $entityManagerInterface->getRepository(Post::class)->findByUrlFilterCat($url, 'guide');
|
|
|
|
|
if (!$item)
|
|
|
|
|
throw $this->createNotFoundException();
|
|
|
|
|
|
|
|
|
|
//get list of trees
|
|
|
|
|
$tress = $entityManagerInterface->getRepository(Tree::class)->findAllByCat('guide');
|
|
|
|
|
return $this->render('post/guide.html.twig', [
|
2025-01-09 10:21:26 +03:30
|
|
|
'item' => $item,
|
2025-01-10 20:17:54 +03:30
|
|
|
'trees' => $tress,
|
2025-01-09 10:21:26 +03:30
|
|
|
]);
|
|
|
|
|
}
|
2025-01-11 01:29:38 +03:30
|
|
|
|
|
|
|
|
#[Route('/changes', name: 'app_changes')]
|
|
|
|
|
public function app_changes(EntityManagerInterface $entityManagerInterface): Response
|
|
|
|
|
{
|
|
|
|
|
$posts = $entityManagerInterface->getRepository(Post::class)->findAllByCat('changelog');
|
|
|
|
|
return $this->render('post/versions.html.twig', [
|
|
|
|
|
'items' => $posts,
|
|
|
|
|
]);
|
|
|
|
|
}
|
2025-01-09 10:21:26 +03:30
|
|
|
}
|