corrections review 107

This commit is contained in:
Julie Lenaerts 2021-09-28 09:33:47 +02:00
parent d60b6aa3c4
commit 93c0197cdb
3 changed files with 38 additions and 35 deletions

View File

@ -73,14 +73,14 @@ class DocumentAccompanyingCourseController extends AbstractController
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::SEE, $course); $this->denyAccessUnlessGranted(AccompanyingPeriodVoter::SEE, $course);
$documents = $em $documents = $em
->getRepository("ChillDocStoreBundle:AccompanyingCourseDocument") ->getRepository(AccompanyingCourseDocument::class)
->findBy( ->findBy(
['course' => $course], ['course' => $course],
['date' => 'DESC'] ['date' => 'DESC']
); );
return $this->render( return $this->render(
'ChillDocStoreBundle:AccompanyingCourseDocument:index.html.twig', '@ChillDocStore/AccompanyingCourseDocument/index.html.twig',
[ [
'documents' => $documents, 'documents' => $documents,
'accompanyingCourse' => $course 'accompanyingCourse' => $course
@ -122,7 +122,7 @@ class DocumentAccompanyingCourseController extends AbstractController
$this->addFlash('error', $this->translator->trans("This form contains errors")); $this->addFlash('error', $this->translator->trans("This form contains errors"));
} }
return $this->render('ChillDocStoreBundle:AccompanyingCourseDocument:new.html.twig', [ return $this->render('@ChillDocStore/AccompanyingCourseDocument/new.html.twig', [
'document' => $document, 'document' => $document,
'form' => $form->createView(), 'form' => $form->createView(),
'accompanyingCourse' => $course, 'accompanyingCourse' => $course,
@ -138,7 +138,7 @@ class DocumentAccompanyingCourseController extends AbstractController
$this->denyAccessUnlessGranted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_SEE', $document); $this->denyAccessUnlessGranted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_SEE', $document);
return $this->render( return $this->render(
'ChillDocStoreBundle:AccompanyingCourseDocument:show.html.twig', '@ChillDocStore/AccompanyingCourseDocument/show.html.twig',
['document' => $document, 'accompanyingCourse' => $course]); ['document' => $document, 'accompanyingCourse' => $course]);
} }
@ -171,7 +171,7 @@ class DocumentAccompanyingCourseController extends AbstractController
} }
return $this->render( return $this->render(
'ChillDocStoreBundle:AccompanyingCourseDocument:edit.html.twig', '@ChillDocStore/AccompanyingCourseDocument/edit.html.twig',
[ [
'document' => $document, 'document' => $document,
'form' => $form->createView(), 'form' => $form->createView(),

View File

@ -3,8 +3,9 @@
namespace Chill\DocStoreBundle\Repository; namespace Chill\DocStoreBundle\Repository;
use App\Entity\AccompanyingCourseDocument; use App\Entity\AccompanyingCourseDocument;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; use Chill\DocStoreBundle\Entity\AccompanyingCourseDocument as EntityAccompanyingCourseDocument;
use Doctrine\Persistence\ManagerRegistry; use Doctrine\ORM\EntityManagerInterface;
use Doctrine\Persistence\ObjectRepository;
/** /**
* @method AccompanyingCourseDocument|null find($id, $lockMode = null, $lockVersion = null) * @method AccompanyingCourseDocument|null find($id, $lockMode = null, $lockVersion = null)
@ -12,39 +13,41 @@ use Doctrine\Persistence\ManagerRegistry;
* @method AccompanyingCourseDocument[] findAll() * @method AccompanyingCourseDocument[] findAll()
* @method AccompanyingCourseDocument[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) * @method AccompanyingCourseDocument[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
*/ */
class AccompanyingCourseDocumentRepository extends ServiceEntityRepository class AccompanyingCourseDocumentRepository implements ObjectRepository
{ {
public function __construct(ManagerRegistry $registry) private EntityRepository $repository;
public function __construct(EntityManagerInterface $entityManager)
{ {
parent::__construct($registry, AccompanyingCourseDocument::class); $this->repository = $entityManager->getRepository(EntityAccompanyingCourseDocument::class);
} }
// /** public function getClassName()
// * @return AccompanyingCourseDocument[] Returns an array of AccompanyingCourseDocument objects
// */
/*
public function findByExampleField($value)
{ {
return $this->createQueryBuilder('a') return EntityAccompanyingCourseDocument::class;
->andWhere('a.exampleField = :val')
->setParameter('val', $value)
->orderBy('a.id', 'ASC')
->setMaxResults(10)
->getQuery()
->getResult()
;
} }
public function find($id): ?EntityAccompanyingCourseDocument
{
return $this->repository->find($id);
}
/**
* @return EntityAccompanyingCourseDocument[]
*/ */
/* public function findAll(): array
public function findOneBySomeField($value): ?AccompanyingCourseDocument
{ {
return $this->createQueryBuilder('a') return $this->repository->findAll();
->andWhere('a.exampleField = :val') }
->setParameter('val', $value)
->getQuery() public function findBy(array $criteria, $orderBy = null, $limit = null, $offset = null): array
->getOneOrNullResult() {
; return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
}
public function findOneBy(array $criteria): ?EntityAccompanyingCourseDocument
{
return $this->repository->findOneBy($criteria);
} }
*/
} }

View File

@ -21,8 +21,8 @@
<ul class="record_actions"> <ul class="record_actions">
<li class="cancel"> <li class="cancel">
<a href="{{ path('accompanying_course_document_index', {'course': accompanyingCourse.id}) }}" class="btn btn-cancel"> <a href="{{ chill_return_path_or('accompanying_course_document_index', {'course': accompanyingCourse.id}) }}" class="btn btn-cancel">
{{ 'Back to the list' | trans }} {{ 'Cancel' | trans }}
</a> </a>
</li> </li>
<li class="edit"> <li class="edit">