add logs
This commit is contained in:
parent
d8f693651d
commit
a8289ceadc
@ -6,6 +6,7 @@ use App\Entity\Branch;
|
|||||||
use App\Entity\Message;
|
use App\Entity\Message;
|
||||||
use App\Form\CreateMessageType;
|
use App\Form\CreateMessageType;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Psr\Log\LoggerInterface;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
@ -14,8 +15,10 @@ use Symfony\Component\Routing\Attribute\Route;
|
|||||||
#[Route('/branches')]
|
#[Route('/branches')]
|
||||||
final class BranchController extends AbstractController
|
final class BranchController extends AbstractController
|
||||||
{
|
{
|
||||||
public function __construct(private readonly EntityManagerInterface $entityManager)
|
public function __construct(
|
||||||
{
|
private readonly EntityManagerInterface $entityManager,
|
||||||
|
private readonly LoggerInterface $logger,
|
||||||
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/{id}', name: 'branch', methods: ['GET'])]
|
#[Route('/{id}', name: 'branch', methods: ['GET'])]
|
||||||
@ -39,6 +42,12 @@ final class BranchController extends AbstractController
|
|||||||
|
|
||||||
$this->entityManager->persist($message);
|
$this->entityManager->persist($message);
|
||||||
$this->entityManager->flush();
|
$this->entityManager->flush();
|
||||||
|
$this->logger->info('Created message with id {messageId}', ['messageId' => $message->getId()]);
|
||||||
|
} else {
|
||||||
|
$this->logger->warning('Cant create message', [
|
||||||
|
'isFormSubmitted' => $form->isSubmitted(),
|
||||||
|
'isFormValid' => $form->isValid(),
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->redirectToRoute('branch', ['id' => $branch->getId()]);
|
return $this->redirectToRoute('branch', ['id' => $branch->getId()]);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user