WIP: Implement admin CRUD

This commit is contained in:
Björn Fromme committed 2023-09-26 17:44:01 +02:00
1 parent 3e0353c79b
commit c55fd85314
63 files changed
+1367 -532

No files matched your search

@@ -0,0 +1,47 @@
<?php
namespace App\Controller\Admin\System\JobProfile;
use App\Entity\JobProfile;
use App\Form\JobProfileType;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
class CreateController extends AbstractController
{
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly LoggerInterface $logger
) {
}
#[Route('/admin/system/job-profile/create', name: 'app_admin_system_job_profile_create')]
#[IsGranted('ROLE_ADMIN')]
public function index(Request $request): Response
{
$jobProfile = new JobProfile();
$form = $this->createForm(JobProfileType::class, $jobProfile);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->entityManager->persist($jobProfile);
$this->entityManager->flush();
$this->addFlash('success', 'Das Job-Profil wurde angelegt');
$this->logger->info('Create Job profile', [
'job_profile' => $jobProfile->getName(),
]);
return $this->redirectToRoute('app_admin_system_job_profile_index');
}
return $this->render('admin/system/job_profile/create.html.twig', [
'form' => $form
]);
}
}
@@ -0,0 +1,29 @@
<?php
namespace App\Controller\Admin\System\JobProfile;
use App\Repository\JobProfileRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
class IndexController extends AbstractController
{
public function __construct(private readonly JobProfileRepository $jobProfileRepository)
{}
#[Route('/admin/system/job-profile', name: 'app_admin_system_job_profile_index')]
#[IsGranted('ROLE_ADMIN')]
public function index(): Response
{
$jobProfiles = $this
->jobProfileRepository
->getList()
;
return $this->render('admin/system/job_profile/index.html.twig', [
'jobProfiles' => $jobProfiles,
]);
}
}
@@ -0,0 +1,47 @@
<?php
namespace App\Controller\Admin\System\Training;
use App\Entity\Training;
use App\Form\TrainingType;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
class CreateController extends AbstractController
{
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly LoggerInterface $logger
) {
}
#[Route('/admin/system/training/create', name: 'app_admin_system_training_create')]
#[IsGranted('ROLE_ADMIN')]
public function index(Request $request): Response
{
$training = new Training();
$form = $this->createForm(TrainingType::class, $training);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->entityManager->persist($training);
$this->entityManager->flush();
$this->addFlash('success', 'Die Fortbildung wurde angelegt');
$this->logger->info('Create training', [
'training' => $training->getName(),
]);
return $this->redirectToRoute('app_admin_system_training_index');
}
return $this->render('admin/system/training/create.html.twig', [
'form' => $form
]);
}
}
@@ -0,0 +1,45 @@
<?php
namespace App\Controller\Admin\System\Training;
use App\Entity\Training;
use App\Form\TrainingType;
use Doctrine\ORM\EntityManagerInterface;
use Psr\Log\LoggerInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
class EditController extends AbstractController
{
public function __construct(
private readonly EntityManagerInterface $entityManager,
private readonly LoggerInterface $logger
) {
}
#[Route('/admin/system/training/edit/{id}', name: 'app_admin_system_training_edit')]
#[IsGranted('ROLE_ADMIN')]
public function index(Training $training, Request $request): Response
{
$form = $this->createForm(TrainingType::class, $training);
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$this->entityManager->flush();
$this->addFlash('success', 'Die Fortbildung wurde aktualisiert');
$this->logger->info('Update training', [
'training' => $training->getName(),
]);
return $this->redirectToRoute('app_admin_system_training_index');
}
return $this->render('admin/system/training/edit.html.twig', [
'form' => $form
]);
}
}
@@ -0,0 +1,29 @@
<?php
namespace App\Controller\Admin\System\Training;
use App\Repository\TrainingRepository;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
class IndexController extends AbstractController
{
public function __construct(private readonly TrainingRepository $trainingRepository)
{}
#[Route('/admin/system/training', name: 'app_admin_system_training_index')]
#[IsGranted('ROLE_ADMIN')]
public function index(): Response
{
$trainings = $this
->trainingRepository
->getList()
;
return $this->render('admin/system/training/index.html.twig', [
'trainings' => $trainings,
]);
}
}
@@ -0,0 +1,44 @@
<?php
namespace App\Controller\Admin\Teamer;
use App\Repository\TeamerRepository;
use Knp\Component\Pager\PaginatorInterface;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;
class IndexController extends AbstractController
{
public function __construct(
private readonly TeamerRepository $teamerRepository,
private readonly PaginatorInterface $paginator
) {
}
#[Route('/admin/teamer', name: 'app_admin_teamer_index')]
#[IsGranted('ROLE_ADMIN')]
public function index(Request $request): Response
{
$query = $this
->teamerRepository
->getListQuery()
;
$pagination = $this->paginator->paginate(
$query,
$request->query->getInt('page', 1),
10,
[
'defaultSortFieldName' => 'teamer.lastName',
'defaultSortDirection' => 'asc',
]
);
return $this->render('admin/teamer/index.html.twig', [
'pagination' => $pagination,
]);
}
}
@@ -13,6 +13,6 @@ class AvailabilitiesController extends AbstractController
#[IsGranted('ROLE_TEAMER')]
public function index(): Response
{
return $this->render('');
return $this->render('teamer/profile/availabilities.html.twig');
}
}
@@ -71,10 +71,10 @@ class IndexController extends AbstractController
'user' => $user->getUserIdentifier(),
]);
return $this->redirectToRoute('app_teamer_profile');
return $this->redirectToRoute('app_teamer_profile_index');
}
return $this->render('teamer/profile.html.twig', [
return $this->render('teamer/profile/index.html.twig', [
'form' => $form->createView(),
'teamer' => $teamer,
'errors' => $errors,
@@ -13,6 +13,6 @@ class SkillsController extends AbstractController
#[IsGranted('ROLE_TEAMER')]
public function index(): Response
{
return $this->render('');
return $this->render('teamer/profile/skills.html.twig');
}
}
+2
View File
@@ -8,6 +8,7 @@ use App\Repository\JobProfileRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Uid\Uuid;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: JobProfileRepository::class)]
class JobProfile implements BlameableEntityInterface, TimestampableEntityInterface
@@ -24,6 +25,7 @@ class JobProfile implements BlameableEntityInterface, TimestampableEntityInterfa
private string $uuid;
#[ORM\Column(length: 255)]
#[Assert\NotBlank(message: 'Bitte gib die Bezeichnung an')]
private ?string $name = null;
#[ORM\ManyToOne]
+15
View File
@@ -111,6 +111,9 @@ class Teamer implements TimestampableEntityInterface
#[ORM\OneToMany(mappedBy: 'teamer', targetEntity: Disposition::class)]
private Collection $dispositions;
#[ORM\OneToOne(mappedBy: 'teamer')]
private ?User $user = null;
public function __construct()
{
$this->uuid = Uuid::v4();
@@ -600,4 +603,16 @@ class Teamer implements TimestampableEntityInterface
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): static
{
$this->user = $user;
return $this;
}
}
+1 -1
View File
@@ -36,7 +36,7 @@ class User implements UserInterface, TimestampableEntityInterface
#[ORM\Column(nullable: true)]
private ?\DateTimeImmutable $lastLoginAt = null;
#[ORM\OneToOne(cascade: ['persist', 'remove'])]
#[ORM\OneToOne(inversedBy: 'user', cascade: ['persist', 'remove'])]
private ?Teamer $teamer = null;
public function __construct()
+55
View File
@@ -0,0 +1,55 @@
<?php
namespace App\Form;
use App\Entity\JobProfile;
use App\Entity\License;
use App\Entity\Training;
use Doctrine\ORM\EntityRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class JobProfileType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('name', TextType::class, [
'label' => 'Bezeichnung',
])
->add('requiredTraining', EntityType::class, [
'label' => 'vorausgesetzte Fortbildung',
'required' => false,
'placeholder' => 'keine',
'class' => Training::class,
'choice_label' => 'name',
'query_builder' => function (EntityRepository $repository) {
return $repository->createQueryBuilder('job_profile')
->orderBy('job_profile.name', 'ASC')
;
},
])
->add('requiredLicenses', ChoiceType::class, [
'label' => 'vorausgesetzte Lizenzen',
'required' => false,
'expanded' => true,
'multiple' => true,
'choices' => [
'Skilehrer*in' => License::TYPE_SKI,
'Snowboardlehrer*in' => License::TYPE_SNOWBOARD,
],
])
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => JobProfile::class,
]);
}
}
+28
View File
@@ -0,0 +1,28 @@
<?php
namespace App\Form;
use App\Entity\Training;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
class TrainingType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('name', TextType::class, [
'label' => 'Bezeichnung',
])
;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => Training::class,
]);
}
}
+40 -14
View File
@@ -20,17 +20,9 @@ abstract class AbstractMenuBuilder
) {
}
protected function assertMobile(array $options): bool
protected function createRootElement(): ItemInterface
{
return isset($options['mobile']) && true === (bool) $options['mobile'];
}
protected function createRootElement(string $class): ItemInterface
{
return $this
->factory->createItem('root')
->setChildrenAttribute('class', $class)
;
return $this->factory->createItem('root');
}
protected function getDefaultRouteParameters(string $parameter = 'id', string $default = '0'): array
@@ -38,7 +30,40 @@ abstract class AbstractMenuBuilder
return [$parameter => $this->requestStack->getMainRequest()->get($parameter, $default)];
}
protected function addLogoutItem(ItemInterface $menu, bool $isMobile = false): void
protected function addAdminItem(ItemInterface $menu): void
{
if ($this->security->isGranted('ROLE_ADMIN')) {
$menu
->addChild('Adminbereich', ['route' => 'app_admin_index'])
->setChildrenAttribute('title', 'Adminbereich')
->setExtra('icon', 'user')
;
}
}
protected function addManagerItem(ItemInterface $menu): void
{
if ($this->security->isGranted('ROLE_MANAGER')) {
$menu
->addChild('Managerbereich', ['route' => 'app_manager_index'])
->setChildrenAttribute('title', 'Managerbereich')
->setExtra('icon', 'user')
;
}
}
protected function addTeamerItem(ItemInterface $menu): void
{
if ($this->security->isGranted('ROLE_TEAMER')) {
$menu
->addChild('Teamerbereich', ['route' => 'app_teamer_index'])
->setChildrenAttribute('title', 'Teamerbereich')
->setExtra('icon', 'user')
;
}
}
protected function addLogoutItem(ItemInterface $menu): void
{
$token = $this->security->getToken();
@@ -55,19 +80,20 @@ abstract class AbstractMenuBuilder
'class' => 'icon-link',
])
->setExtra('icon', 'logout')
->setExtra('icon_only', false === $isMobile)
;
} else {
$menu
->addChild('Logout', ['route' => 'app_security_logout'])
->setLinkAttributes([
'title' => 'Logout',
'class' => 'icon-link',
])
->setExtra('icon', 'logout')
->setExtra('icon_only', false === $isMobile)
;
}
}
protected function addDivider(ItemInterface $menu): void
{
$menu->addChild('%DIVIDER%');
}
}
+93 -14
View File
@@ -6,25 +6,104 @@ use Knp\Menu\ItemInterface;
class AdminMenuBuilder extends AbstractMenuBuilder
{
public function createHeaderMenu(array $options): ItemInterface
{
$menu = $this->createRootElement();
$this->addLogoutItem($menu);
return $menu;
}
public function createMainMenu(array $options): ItemInterface
{
$menu = $this->createRootElement();
return $menu;
}
$menu
->addChild('Dashboard', ['route' => 'app_admin_index'])
->setChildrenAttribute('title', 'Dashboard')
->setExtra('icon', 'lab')
;
public function createMobileMenu(array $options): ItemInterface
{
$menu = $this->createRootElement(true);
$this->addLogoutItem($menu, true);
$menu
->addChild('Einsatzübersicht', ['route' => 'app_admin_index'])
->setChildrenAttribute('title', 'Einsatzübersicht')
->setExtra('icon', 'calendar')
;
$menu
->addChild('Bewerbungsübersicht', ['route' => 'app_admin_index'])
->setChildrenAttribute('title', 'Bewerbungsübersicht')
->setExtra('icon', 'mail')
;
$menu
->addChild('Dokumentenübersicht', ['route' => 'app_admin_index'])
->setChildrenAttribute('title', 'Dokumentenübersicht')
->setExtra('icon', 'document')
;
$menu
->addChild('Teamerübersicht', ['route' => 'app_admin_teamer_index'])
->setChildrenAttribute('title', 'Teamerübersicht')
->setExtra('icon', 'users')
;
$systemMenu = $menu
->addChild('Einstellungen')
->setExtra('icon', 'settings')
;
$feeMenu = $systemMenu
->addChild('Honorare', [
'route' => 'app_admin_system_fee_index',
'linkAttributes' => [
'title' => 'Honorare',
],
'displayChildren' => false,
])
;
$feeMenu
->addChild('Honorar anlegen', [
'route' => 'app_admin_system_fee_create',
])
;
$feeMenu
->addChild('Honorar bearbeiten', [
'route' => 'app_admin_system_fee_edit',
'routeParameters' => $this->getDefaultRouteParameters(),
])
;
$trainingMenu = $systemMenu
->addChild('Fortbildungen', [
'route' => 'app_admin_system_training_index',
'linkAttributes' => [
'title' => 'Fortbildungen',
],
'displayChildren' => false,
])
;
$trainingMenu
->addChild('Fortbildung anlegen', [
'route' => 'app_admin_system_training_create',
])
;
$trainingMenu
->addChild('Fortbildung bearbeiten', [
'route' => 'app_admin_system_training_edit',
'routeParameters' => $this->getDefaultRouteParameters(),
])
;
$jobProfileMenu = $systemMenu
->addChild('Job-Profile', [
'route' => 'app_admin_system_job_profile_index',
'linkAttributes' => [
'title' => 'Fortbildungen',
],
'displayChildren' => false,
])
;
$jobProfileMenu
->addChild('Job-Profil anlegen', [
'route' => 'app_admin_system_job_profile_create',
])
;
$this->addDivider($menu);
$this->addManagerItem($menu);
$this->addTeamerItem($menu);
$this->addLogoutItem($menu);
return $menu;
}
+3 -17
View File
@@ -6,27 +6,13 @@ use Knp\Menu\ItemInterface;
class ManagerMenuBuilder extends AbstractMenuBuilder
{
public function createHeaderMenu(array $options): ItemInterface
{
$menu = $this->createRootElement();
$this->addLogoutItem($menu);
return $menu;
}
public function createMainMenu(array $options): ItemInterface
{
$menu = $this->createRootElement();
return $menu;
}
public function createMobileMenu(array $options): ItemInterface
{
$menu = $this->createRootElement(true);
$this->addLogoutItem($menu, true);
$this->addAdminItem($menu);
$this->addTeamerItem($menu);
$this->addLogoutItem($menu);
return $menu;
}
+45 -50
View File
@@ -6,86 +6,81 @@ use Knp\Menu\ItemInterface;
class TeamerMenuBuilder extends AbstractMenuBuilder
{
public function createHeaderMenu(array $options): ItemInterface
{
$menu = $this->createRootElement('menu menu--header');
$this->addLogoutItem($menu);
return $menu;
}
public function createMainMenu(array $options): ItemInterface
{
$menu = $this->createRootElement('menu menu--main');
$menu = $this->createRootElement();
$menu
->addChild('Einsatzübersicht', ['route' => 'app_teamer_disposition_index'])
->setLinkAttributes([
'title' => 'Einsatzübersicht',
'class' => 'icon-link',
])
->addChild('Einsatzübersicht', ['route' => 'app_teamer_index'])
->setChildrenAttribute('title', 'Einsatzübersicht')
->setExtra('icon', 'calendar')
->setExtra('icon_only', false)
;
$profileMenu = $menu
->addChild('Mein Profil')
->setExtra('icon', 'user')
->setExtra('icon_only', false)
->setLinkAttribute('title', 'Mein Profil')
;
$profileMenu
->addChild('Stammdaten und Foto', ['route' => 'app_teamer_profile_index'])
->setLinkAttributes([
'title' => 'Mein Profil',
])
->setLinkAttribute('title', 'Stammdaten und Foto')
;
$profileMenu
->addChild('Jobprofile & Skills', ['route' => 'app_teamer_profile_skills'])
->setLinkAttributes([
'title' => 'Jobprofile & Skills',
])
->setLinkAttribute('title', 'Jobprofile & Skills')
;
$profileMenu
->addChild('Meine Verfügbarkeit', ['route' => 'app_teamer_profile_availabilities'])
->setLinkAttributes([
'title' => 'Meine Verfügbarkeit',
])
->setLinkAttribute('title', 'Meine Verfügbarkeit')
;
$dispositionMenu = $menu
->addChild('Meine Einsätze')
->setExtra('icon', 'calendar')
->setExtra('icon_only', false)
->setExtra('icon', 'bus')
;
$dispositionMenu
->addChild('Merkliste', ['route' => 'app_teamer_disposition_watchlist'])
->setLinkAttributes([
'title' => 'Merkliste',
])
->setLinkAttribute('title', 'Merkliste')
;
$dispositionMenu
->addChild('Offene Bewerbungen', ['route' => 'app_teamer_disposition_watchlist'])
->setLinkAttribute('title', 'Offene Bewerbungen')
;
$dispositionMenu
->addChild('Nächste Einsätze', ['route' => 'app_teamer_disposition_watchlist'])
->setLinkAttribute('title', 'Nächste Einsätze')
;
$dispositionMenu
->addChild('Letzte Einsätze', ['route' => 'app_teamer_disposition_watchlist'])
->setLinkAttribute('title', 'Letzte Einsätze')
;
$dispositionMenu
->addChild('Meine Dokumente', ['route' => 'app_teamer_disposition_watchlist'])
->setLinkAttribute('title', 'Meine Dokumente')
;
$dispositionMenu
->addChild('Mein Feedback', ['route' => 'app_teamer_disposition_watchlist'])
->setLinkAttribute('title', 'Mein Feedback')
;
return $menu;
}
public function createMobileMenu(array $options): ItemInterface
{
$menu = $this->createRootElement('menu menu--mobile');
$menu
->addChild('Profil', ['route' => 'app_teamer_profile_index'])
->setLinkAttributes([
'title' => 'Mein Profil',
'class' => 'icon-link',
])
->setExtra('icon', 'user')
->setExtra('icon_only', false)
$faqMenu = $menu
->addChild('FAQ &amp; Kontakt')
->setExtra('icon', 'info')
;
$faqMenu
->addChild('FAQ', ['route' => 'app_teamer_disposition_watchlist'])
->setLinkAttribute('title', 'FAQ')
;
$faqMenu
->addChild('Kontakt', ['route' => 'app_teamer_disposition_watchlist'])
->setLinkAttribute('title', 'Kontakt')
;
$this->addLogoutItem($menu, true);
$this->addDivider($menu);
$this->addAdminItem($menu);
$this->addManagerItem($menu);
$this->addLogoutItem($menu);
return $menu;
}
+9 -39
View File
@@ -21,46 +21,16 @@ class JobProfileRepository extends ServiceEntityRepository
parent::__construct($registry, JobProfile::class);
}
public function save(JobProfile $entity, bool $flush = false): void
public function getList(): array
{
$this->getEntityManager()->persist($entity);
$qb = $this->createQueryBuilder('job_profile');
if ($flush) {
$this->getEntityManager()->flush();
}
return $qb
->select('job_profile', 'required_training')
->leftJoin('job_profile.requiredTraining', 'required_training')
->orderBy('job_profile.name', 'ASC')
->getQuery()
->getResult()
;
}
public function remove(JobProfile $entity, bool $flush = false): void
{
$this->getEntityManager()->remove($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
// /**
// * @return JobProfile[] Returns an array of JobProfile objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('j')
// ->andWhere('j.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('j.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?JobProfile
// {
// return $this->createQueryBuilder('j')
// ->andWhere('j.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}
+7 -39
View File
@@ -4,6 +4,7 @@ namespace App\Repository;
use App\Entity\Teamer;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\ORM\Query;
use Doctrine\Persistence\ManagerRegistry;
/**
@@ -21,46 +22,13 @@ class TeamerRepository extends ServiceEntityRepository
parent::__construct($registry, Teamer::class);
}
public function save(Teamer $entity, bool $flush = false): void
public function getListQuery(): Query
{
$this->getEntityManager()->persist($entity);
$qb = $this->createQueryBuilder('teamer');
if ($flush) {
$this->getEntityManager()->flush();
}
return $qb
->select('teamer', 'user')
->leftJoin('teamer.user', 'user')
->getQuery();
}
public function remove(Teamer $entity, bool $flush = false): void
{
$this->getEntityManager()->remove($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
// /**
// * @return Teamer[] Returns an array of Teamer objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('t')
// ->andWhere('t.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('t.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?Teamer
// {
// return $this->createQueryBuilder('t')
// ->andWhere('t.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}
+9 -39
View File
@@ -21,46 +21,16 @@ class TrainingRepository extends ServiceEntityRepository
parent::__construct($registry, Training::class);
}
public function save(Training $entity, bool $flush = false): void
public function getList(): array
{
$this->getEntityManager()->persist($entity);
$qb = $this->createQueryBuilder('training');
if ($flush) {
$this->getEntityManager()->flush();
}
return $qb
->select('training', 'training_attendance')
->leftJoin('training.trainingAttendances', 'training_attendance')
->orderBy('training.name', 'ASC')
->getQuery()
->getResult()
;
}
public function remove(Training $entity, bool $flush = false): void
{
$this->getEntityManager()->remove($entity);
if ($flush) {
$this->getEntityManager()->flush();
}
}
// /**
// * @return Training[] Returns an array of Training objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('t')
// ->andWhere('t.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('t.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
// public function findOneBySomeField($value): ?Training
// {
// return $this->createQueryBuilder('t')
// ->andWhere('t.exampleField = :val')
// ->setParameter('val', $value)
// ->getQuery()
// ->getOneOrNullResult()
// ;
// }
}
+1 -1
View File
@@ -45,7 +45,7 @@ class AppRuntime implements RuntimeExtensionInterface
return $this->intlExtension->formatCurrency($amount, 'EUR');
}
public function renderIcon(Environment $environment, string $icon, string $classes = 'w-6 h-6'): string
public function renderIcon(Environment $environment, string $icon, string $classes = 'w-5 h-5'): string
{
return $environment->render('_partials/_icon.html.twig', [
'icon' => $icon,