draft submit form #14

This commit is contained in:
ghost 2023-10-05 00:15:00 +03:00
parent ffa568275f
commit 731624d886
5 changed files with 340 additions and 130 deletions

View file

@ -0,0 +1,37 @@
<?php
namespace App\Service;
use App\Entity\Page;
use App\Repository\PageRepository;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
class PageService
{
private EntityManagerInterface $entityManager;
private PageRepository $pageRepository;
private ParameterBagInterface $parameterBagInterface;
public function __construct(
EntityManagerInterface $entityManager,
ParameterBagInterface $parameterBagInterface
)
{
$this->entityManager = $entityManager;
$this->pageRepository = $entityManager->getRepository(Page::class);
$this->parameterBagInterface = $parameterBagInterface;
}
public function new(): ?Page
{
return new Page();
}
public function save(Page $page) : void
{
$this->entityManager->persist($page);
$this->entityManager->flush();
}
}