Feat: Streamline and extend logging
This commit is contained in:
@@ -41,8 +41,11 @@ class CreateController extends AbstractController
|
||||
|
||||
$this->addFlash('success', 'Deine Bewerbung wurde entgegengenommen');
|
||||
$this->logger->info('Create application', [
|
||||
'teamer' => $teamer->getUuid(),
|
||||
'application' => $application->getUuid(),
|
||||
'teamer_id' => $teamer->getId(),
|
||||
'teamer_name' => (string) $teamer,
|
||||
'application_id' => $application->getId(),
|
||||
'assignment_id' => $assignment->getId(),
|
||||
'destination' => (string) $assignment->getDestination(),
|
||||
]);
|
||||
|
||||
return $this->redirectToRoute('app_teamer_index');
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Controller\Teamer\Application;
|
||||
|
||||
use App\Controller\Traits\ReturnUrlTrait;
|
||||
use App\Entity\Application;
|
||||
use App\Entity\User;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
@@ -26,11 +27,20 @@ class DeleteController extends AbstractController
|
||||
#[IsGranted('DELETE', subject: 'application')]
|
||||
public function index(Application $application, Request $request): Response
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = $this->getUser();
|
||||
$teamer = $user->getTeamer();
|
||||
$assignment = $application->getAssignment();
|
||||
|
||||
$this->entityManager->remove($application);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->logger->info('Delete application', [
|
||||
'application' => $application->getUuid(),
|
||||
'teamer_id' => $teamer->getId(),
|
||||
'teamer_name' => (string) $teamer,
|
||||
'application_id' => $application->getId(),
|
||||
'assignment_id' => $assignment->getId(),
|
||||
'destination' => (string) $assignment->getDestination(),
|
||||
]);
|
||||
|
||||
$returnUrl = $this->getReturnUrl($request, 'app_teamer_index');
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Controller\Traits\ReturnUrlTrait;
|
||||
use App\Entity\Assignment;
|
||||
use App\Entity\User;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
@@ -16,8 +17,11 @@ class ToggleController extends AbstractController
|
||||
{
|
||||
use ReturnUrlTrait;
|
||||
|
||||
public function __construct(private readonly EntityManagerInterface $entityManager)
|
||||
{}
|
||||
public function __construct(
|
||||
private readonly EntityManagerInterface $entityManager,
|
||||
private readonly LoggerInterface $logger
|
||||
) {
|
||||
}
|
||||
|
||||
#[Route('/teamer/bookmark/toggle/{uuid}', name: 'app_teamer_bookmark_toggle')]
|
||||
#[IsGranted('ROLE_TEAMER')]
|
||||
@@ -27,12 +31,21 @@ class ToggleController extends AbstractController
|
||||
$user = $this->getUser();
|
||||
$teamer = $user->getTeamer();
|
||||
|
||||
$loggerContext = [
|
||||
'assignment_id' => $assignment->getId(),
|
||||
'destination' => (string) $assignment->getDestination(),
|
||||
'teamer_id' => $teamer->getId(),
|
||||
'teamer_name' => (string) $teamer,
|
||||
];
|
||||
|
||||
if ($teamer->getBookmarks()->contains($assignment)) {
|
||||
$teamer->removeBookmark($assignment);
|
||||
$this->addFlash('success', 'Der Einsatz wurde von der Merkliste entfernt');
|
||||
$this->logger->info('Remove assignment bookmark', $loggerContext);
|
||||
} else {
|
||||
$teamer->addBookmark($assignment);
|
||||
$this->addFlash('success', 'Der Einsatz wurde auf die Merkliste gesetzt');
|
||||
$this->logger->info('Create assignment bookmark', $loggerContext);
|
||||
}
|
||||
|
||||
$this->entityManager->flush();
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Controller\Teamer\Disposition;
|
||||
|
||||
use App\Entity\Disposition;
|
||||
use App\Service\Pdf\ContractRenderer;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\HeaderUtils;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
@@ -12,8 +13,11 @@ use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
|
||||
class ContractPdfController extends AbstractController
|
||||
{
|
||||
public function __construct(private readonly ContractRenderer $renderer)
|
||||
{}
|
||||
public function __construct(
|
||||
private readonly ContractRenderer $renderer,
|
||||
private readonly LoggerInterface $logger
|
||||
) {
|
||||
}
|
||||
|
||||
#[Route('/teamer/disposition/contract/{uuid}', name: 'app_teamer_disposition_contractpdf')]
|
||||
#[IsGranted('ROLE_TEAMER')]
|
||||
@@ -23,8 +27,10 @@ class ContractPdfController extends AbstractController
|
||||
$pdf = $this->renderer->render($disposition);
|
||||
|
||||
$teamer = $disposition->getTeamer();
|
||||
$assignment = $disposition->getAssignment();
|
||||
$destination = $assignment->getDestination();
|
||||
|
||||
$filename = sprintf('Honorarvertrag_%s_%s.pdf', $teamer, $disposition->getAssignment()->getDestination());
|
||||
$filename = sprintf('Honorarvertrag_%s_%s.pdf', $teamer, $destination);
|
||||
$disposition = HeaderUtils::makeDisposition(HeaderUtils::DISPOSITION_ATTACHMENT, $filename, md5($filename));
|
||||
|
||||
$response = new Response($pdf->Output('S'));
|
||||
@@ -32,6 +38,13 @@ class ContractPdfController extends AbstractController
|
||||
$response->headers->set('Content-type', 'application/pdf');
|
||||
$response->headers->set('Content-Disposition', $disposition);
|
||||
|
||||
$this->logger->info('Create teamer contract', [
|
||||
'teamer_id' => $teamer->getId(),
|
||||
'teamer_name' => (string) $teamer,
|
||||
'assignment_id' => $assignment->getId(),
|
||||
'destination' => (string) $destination,
|
||||
]);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,9 @@
|
||||
namespace App\Controller\Teamer\Disposition;
|
||||
|
||||
use App\Entity\Disposition;
|
||||
use App\Entity\User;
|
||||
use App\Service\Common\IcsGenerator;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\HeaderUtils;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
@@ -12,13 +14,21 @@ use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
|
||||
class IcsController extends AbstractController
|
||||
{
|
||||
public function __construct(private readonly LoggerInterface $logger)
|
||||
{}
|
||||
|
||||
#[Route('/teamer/disposition/ics/{uuid}', name: 'app_teamer_disposition_ics')]
|
||||
#[IsGranted('ROLE_TEAMER')]
|
||||
#[IsGranted('VIEW', subject: 'disposition')]
|
||||
public function index(Disposition $disposition): Response
|
||||
{
|
||||
/** @var User $user */
|
||||
$user = $this->getUser();
|
||||
$teamer = $user->getTeamer();
|
||||
$assignment = $disposition->getAssignment();
|
||||
$destination = $assignment->getDestination();
|
||||
$jobProfile = $assignment->getJobProfile();
|
||||
|
||||
$ics = (new IcsGenerator($disposition))->generate();
|
||||
$filename = sprintf(
|
||||
'Einteilung_%s_%s-%s.ics',
|
||||
@@ -26,12 +36,19 @@ class IcsController extends AbstractController
|
||||
$assignment->getEffectivePeriod()->start->format('d.m.Y'),
|
||||
$assignment->getEffectivePeriod()->end->format('d.m.Y')
|
||||
);
|
||||
$disposition = HeaderUtils::makeDisposition(HeaderUtils::DISPOSITION_INLINE, $filename, md5($filename));
|
||||
$contentDisposition = HeaderUtils::makeDisposition(HeaderUtils::DISPOSITION_INLINE, $filename, md5($filename));
|
||||
|
||||
$response = new Response($ics);
|
||||
$response->setPrivate();
|
||||
$response->headers->set('Content-type', 'text/calendar');
|
||||
$response->headers->set('Content-Disposition', $disposition);
|
||||
$response->headers->set('Content-Disposition', $contentDisposition);
|
||||
|
||||
$this->logger->info('Create ICS file', [
|
||||
'assignment_id' => $assignment->getId(),
|
||||
'destination' => (string) $destination,
|
||||
'teamer_id' => $teamer->getId(),
|
||||
'teamer_name' => (string) $teamer,
|
||||
]);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ namespace App\Controller\Teamer\Disposition;
|
||||
|
||||
use App\Entity\Disposition;
|
||||
use App\Service\Pdf\InvoiceRenderer;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
use Symfony\Component\HttpFoundation\HeaderUtils;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
@@ -12,8 +13,11 @@ use Symfony\Component\Security\Http\Attribute\IsGranted;
|
||||
|
||||
class InvoicePdfController extends AbstractController
|
||||
{
|
||||
public function __construct(private readonly InvoiceRenderer $renderer)
|
||||
{}
|
||||
public function __construct(
|
||||
private readonly InvoiceRenderer $renderer,
|
||||
private readonly LoggerInterface $logger
|
||||
) {
|
||||
}
|
||||
|
||||
#[Route('/teamer/disposition/invoice/{uuid}', name: 'app_teamer_disposition_invoicepdf')]
|
||||
#[IsGranted('ROLE_TEAMER')]
|
||||
@@ -22,15 +26,24 @@ class InvoicePdfController extends AbstractController
|
||||
{
|
||||
$pdf = $this->renderer->render($disposition);
|
||||
|
||||
$assignment = $disposition->getAssignment();
|
||||
$destination = $assignment->getDestination();
|
||||
$teamer = $disposition->getTeamer();
|
||||
|
||||
$filename = sprintf('Honorarnote_%s_%s.pdf', $teamer, $disposition->getAssignment()->getDestination());
|
||||
$disposition = HeaderUtils::makeDisposition(HeaderUtils::DISPOSITION_ATTACHMENT, $filename, md5($filename));
|
||||
$contentDisposition = HeaderUtils::makeDisposition(HeaderUtils::DISPOSITION_ATTACHMENT, $filename, md5($filename));
|
||||
|
||||
$response = new Response($pdf->Output('S'));
|
||||
$response->setPrivate();
|
||||
$response->headers->set('Content-type', 'application/pdf');
|
||||
$response->headers->set('Content-Disposition', $disposition);
|
||||
$response->headers->set('Content-Disposition', $contentDisposition);
|
||||
|
||||
$this->logger->info('Create teamer invoice', [
|
||||
'teamer_id' => $teamer->getId(),
|
||||
'teamer_name' => (string) $teamer,
|
||||
'assignment_id' => $assignment->getId(),
|
||||
'destination' => (string) $destination,
|
||||
]);
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
@@ -31,8 +31,9 @@ class AddController extends AbstractController
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->logger->info('Add availability', [
|
||||
'user' => $user->getUserIdentifier(),
|
||||
'availability' => $availability,
|
||||
'teamer_id' => $teamer->getId(),
|
||||
'teamer_name' => (string) $teamer,
|
||||
'availability' => (string) $availability,
|
||||
]);
|
||||
|
||||
return $this->redirectToRoute('app_teamer_profile_availability_index');
|
||||
|
||||
@@ -47,8 +47,10 @@ class CreateController extends AbstractController
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash('success', 'Der Zeitraum wurde hinzugefügt.');
|
||||
$this->logger->info('Add availability', [
|
||||
'availability' => $availability,
|
||||
$this->logger->info('Create availability', [
|
||||
'teamer_id' => $teamer->getId(),
|
||||
'teamer_name' => (string) $teamer,
|
||||
'availability' => (string) $availability,
|
||||
]);
|
||||
|
||||
$redirectUrl = $this->generateUrl('app_teamer_profile_availability_index');
|
||||
|
||||
@@ -37,7 +37,9 @@ class DeleteController extends AbstractController
|
||||
|
||||
$this->addFlash('success', 'Der Zeitraum wurde entfernt/gelöscht.');
|
||||
$this->logger->info('Delete availability', [
|
||||
'user' => $this->getUser()->getUserIdentifier(),
|
||||
'teamer_id' => $teamer->getId(),
|
||||
'teamer_name' => (string) $teamer,
|
||||
'availability' => (string) $availability,
|
||||
]);
|
||||
|
||||
return $this->redirectToRoute('app_teamer_profile_availability_index');
|
||||
|
||||
@@ -68,7 +68,8 @@ class IndexController extends AbstractController
|
||||
|
||||
$this->addFlash('success', 'Deine Daten wurden aktualisiert');
|
||||
$this->logger->info('Update teamer profile', [
|
||||
'user' => $user->getUserIdentifier(),
|
||||
'teamer_id' => $teamer->getId(),
|
||||
'teamer_name' => (string) $teamer,
|
||||
]);
|
||||
|
||||
return $this->redirectToRoute('app_teamer_profile_index');
|
||||
@@ -97,7 +98,8 @@ class IndexController extends AbstractController
|
||||
|
||||
$this->addFlash('success', 'Dein Profilbild wurde aktualisiert');
|
||||
$this->logger->info('Update teamer photo', [
|
||||
'user' => $user->getUserIdentifier(),
|
||||
'teamer_id' => $teamer->getId(),
|
||||
'teamer_name' => (string) $teamer,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -43,7 +43,15 @@ class AddController extends AbstractController
|
||||
$this->updateCertificate($user, $license, $uploadSession);
|
||||
}
|
||||
|
||||
$form = $this->createForm(LicenseType::class, $license, ['action' => $action, 'ajax_submit' => true, 'upload_session' => $uploadSession]);
|
||||
$form = $this->createForm(
|
||||
LicenseType::class,
|
||||
$license,
|
||||
[
|
||||
'action' => $action,
|
||||
'ajax_submit' => true,
|
||||
'upload_session' => $uploadSession,
|
||||
]
|
||||
);
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
@@ -56,7 +64,9 @@ class AddController extends AbstractController
|
||||
|
||||
$this->addFlash('success', 'Die Lizenz wurde hinzugefügt.');
|
||||
$this->logger->info('Add license', [
|
||||
'user' => $user->getUserIdentifier(),
|
||||
'teamer_id' => $teamer->getId(),
|
||||
'teamer_name' => (string) $teamer,
|
||||
'license_type' => $license->getType(),
|
||||
]);
|
||||
|
||||
$redirectUrl = $this->generateUrl('app_teamer_profile_skills');
|
||||
|
||||
@@ -22,12 +22,16 @@ class DeleteController extends AbstractController
|
||||
#[IsGranted('DELETE', subject: 'license')]
|
||||
public function index(License $license): Response
|
||||
{
|
||||
$teamer = $license->getTeamer();
|
||||
|
||||
$this->entityManager->remove($license);
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash('success', 'Die Lizenz wurde gelöscht.');
|
||||
$this->logger->info('Delete license', [
|
||||
'user' => $this->getUser()->getUserIdentifier(),
|
||||
'teamer_id' => $teamer->getId(),
|
||||
'teamer_name' => (string) $teamer,
|
||||
'license_type' => $license->getType(),
|
||||
]);
|
||||
|
||||
return $this->redirectToRoute('app_teamer_profile_skills');
|
||||
|
||||
@@ -66,8 +66,9 @@ class SkillsController extends AbstractController
|
||||
$this->entityManager->flush();
|
||||
|
||||
$this->addFlash('success', 'Dein Profil wurde aktualisiert.');
|
||||
$this->logger->info('Update teamer profile', [
|
||||
'user' => $user->getUserIdentifier(),
|
||||
$this->logger->info('Update teamer skills', [
|
||||
'teamer_id' => $teamer->getId(),
|
||||
'teamer_name' => (string) $teamer,
|
||||
]);
|
||||
|
||||
return $this->redirectToRoute('app_teamer_profile_skills');
|
||||
|
||||
Reference in New Issue
Block a user