Compare commits

..

3 Commits

Author SHA1 Message Date
a8289ceadc add logs 2025-02-13 19:26:08 +03:00
d8f693651d kek 2025-02-13 18:32:17 +03:00
4ae36306aa )) 2025-02-13 18:25:14 +03:00
3 changed files with 14 additions and 3 deletions

View File

@@ -95,4 +95,5 @@ RUN set -eux; \
composer dump-autoload --classmap-authoritative --no-dev; \
composer dump-env prod; \
composer run-script --no-dev post-install-cmd; \
chmod +x bin/console; sync;
chmod +x bin/console; \
sync;

View File

@@ -63,6 +63,7 @@
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"asset-map:compile": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd",
"importmap:install": "symfony-cmd"
},

View File

@@ -6,6 +6,7 @@ use App\Entity\Branch;
use App\Entity\Message;
use App\Form\CreateMessageType;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -14,8 +15,10 @@ use Symfony\Component\Routing\Attribute\Route;
#[Route('/branches')]
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'])]
@@ -39,6 +42,12 @@ final class BranchController extends AbstractController
$this->entityManager->persist($message);
$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()]);