mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
phpcsfixes
This commit is contained in:
parent
bf0b7f1bb2
commit
c8e5ba4738
@ -37,10 +37,10 @@ class DocumentAccompanyingCourseController extends AbstractController
|
||||
|
||||
protected TranslatorInterface $translator;
|
||||
|
||||
private PaginatorFactory $paginatorFactory;
|
||||
|
||||
private AccompanyingCourseDocumentRepository $courseRepository;
|
||||
|
||||
private PaginatorFactory $paginatorFactory;
|
||||
|
||||
/**
|
||||
* DocumentAccompanyingCourseController constructor.
|
||||
*/
|
||||
@ -142,13 +142,12 @@ class DocumentAccompanyingCourseController extends AbstractController
|
||||
$pagination->getCurrentPageFirstItemNumber()
|
||||
);
|
||||
|
||||
|
||||
return $this->render(
|
||||
'ChillDocStoreBundle:AccompanyingCourseDocument:index.html.twig',
|
||||
[
|
||||
'documents' => $documents,
|
||||
'accompanyingCourse' => $course,
|
||||
'pagination' => $pagination
|
||||
'pagination' => $pagination,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -163,7 +163,8 @@ class DocumentPersonController extends AbstractController
|
||||
$person,
|
||||
[],
|
||||
$pagination->getItemsPerPage(),
|
||||
$pagination->getCurrentPageFirstItemNumber());
|
||||
$pagination->getCurrentPageFirstItemNumber()
|
||||
);
|
||||
|
||||
$event = new PrivacyEvent($person, [
|
||||
'element_class' => PersonDocument::class,
|
||||
@ -176,7 +177,7 @@ class DocumentPersonController extends AbstractController
|
||||
[
|
||||
'documents' => $documents,
|
||||
'person' => $person,
|
||||
'pagination' => $pagination
|
||||
'pagination' => $pagination,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@ -77,6 +77,11 @@ class Document implements HasScopeInterface, TrackCreationInterface, TrackUpdate
|
||||
*/
|
||||
private $scope;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate")
|
||||
*/
|
||||
private $template;
|
||||
|
||||
/**
|
||||
* @ORM\Column(type="text")
|
||||
* @Assert\Length(
|
||||
@ -92,12 +97,6 @@ class Document implements HasScopeInterface, TrackCreationInterface, TrackUpdate
|
||||
*/
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate")
|
||||
*/
|
||||
private $template;
|
||||
|
||||
|
||||
public function getCategory(): ?DocumentCategory
|
||||
{
|
||||
return $this->category;
|
||||
@ -133,6 +132,11 @@ class Document implements HasScopeInterface, TrackCreationInterface, TrackUpdate
|
||||
return $this->scope;
|
||||
}
|
||||
|
||||
public function getTemplate(): ?DocGeneratorTemplate
|
||||
{
|
||||
return $this->template;
|
||||
}
|
||||
|
||||
public function getTitle(): ?string
|
||||
{
|
||||
return $this->title;
|
||||
@ -143,11 +147,6 @@ class Document implements HasScopeInterface, TrackCreationInterface, TrackUpdate
|
||||
return $this->user;
|
||||
}
|
||||
|
||||
public function getTemplate(): ?DocGeneratorTemplate
|
||||
{
|
||||
return $this->template;
|
||||
}
|
||||
|
||||
public function setCategory(DocumentCategory $category): self
|
||||
{
|
||||
$this->category = $category;
|
||||
@ -183,6 +182,13 @@ class Document implements HasScopeInterface, TrackCreationInterface, TrackUpdate
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setTemplate(?DocGeneratorTemplate $template): self
|
||||
{
|
||||
$this->template = $template;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setTitle(string $title): self
|
||||
{
|
||||
$this->title = $title;
|
||||
@ -196,11 +202,4 @@ class Document implements HasScopeInterface, TrackCreationInterface, TrackUpdate
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setTemplate(?DocGeneratorTemplate $template): self
|
||||
{
|
||||
$this->template = $template;
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -90,12 +90,12 @@ class PersonDocumentType extends AbstractType
|
||||
},
|
||||
]);
|
||||
|
||||
if ($isScopeConcerned && $this->parameterBag->get('chill_main')['acl']['form_show_scopes']) {
|
||||
$builder->add('scope', ScopePickerType::class, [
|
||||
'center' => $options['center'],
|
||||
'role' => $options['role'],
|
||||
]);
|
||||
}
|
||||
if ($isScopeConcerned && $this->parameterBag->get('chill_main')['acl']['form_show_scopes']) {
|
||||
$builder->add('scope', ScopePickerType::class, [
|
||||
'center' => $options['center'],
|
||||
'role' => $options['role'],
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
|
@ -30,19 +30,13 @@ class AccompanyingCourseDocumentRepository implements ObjectRepository
|
||||
$this->repository = $em->getRepository(AccompanyingCourseDocument::class);
|
||||
}
|
||||
|
||||
public function find($id): ?AccompanyingCourseDocument
|
||||
{
|
||||
return $this->repository->find($id);
|
||||
}
|
||||
|
||||
public function buildQueryByCourse(AccompanyingPeriod $course): QueryBuilder
|
||||
{
|
||||
$qb = $this->repository->createQueryBuilder('d');
|
||||
|
||||
$qb
|
||||
->where($qb->expr()->eq('d.course', ':course'))
|
||||
->setParameter('course', $course)
|
||||
;
|
||||
->setParameter('course', $course);
|
||||
|
||||
return $qb;
|
||||
}
|
||||
@ -54,6 +48,11 @@ class AccompanyingCourseDocumentRepository implements ObjectRepository
|
||||
return $qb->getQuery()->getSingleScalarResult();
|
||||
}
|
||||
|
||||
public function find($id): ?AccompanyingCourseDocument
|
||||
{
|
||||
return $this->repository->find($id);
|
||||
}
|
||||
|
||||
public function findAll(): array
|
||||
{
|
||||
return $this->repository->findAll();
|
||||
@ -73,5 +72,4 @@ class AccompanyingCourseDocumentRepository implements ObjectRepository
|
||||
{
|
||||
return AccompanyingCourseDocument::class;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,14 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\DocStoreBundle\Repository;
|
||||
|
||||
use Chill\DocStoreBundle\Entity\PersonDocument;
|
||||
@ -13,12 +22,12 @@ use Symfony\Component\Security\Core\Security;
|
||||
|
||||
class PersonDocumentACLAwareRepository implements PersonDocumentACLAwareRepositoryInterface
|
||||
{
|
||||
private EntityManagerInterface $em;
|
||||
|
||||
private AuthorizationHelperInterface $authorizationHelper;
|
||||
|
||||
private CenterResolverDispatcher $centerResolverDispatcher;
|
||||
|
||||
private EntityManagerInterface $em;
|
||||
|
||||
private Security $security;
|
||||
|
||||
public function __construct(EntityManagerInterface $em, AuthorizationHelperInterface $authorizationHelper, CenterResolverDispatcher $centerResolverDispatcher, Security $security)
|
||||
@ -29,19 +38,15 @@ class PersonDocumentACLAwareRepository implements PersonDocumentACLAwareReposito
|
||||
$this->security = $security;
|
||||
}
|
||||
|
||||
public function findByPerson(Person $person, array $orderBy = [], int $limit = 20, int $offset = 0): array
|
||||
public function buildQueryByPerson(Person $person): QueryBuilder
|
||||
{
|
||||
$qb = $this->buildQueryByPerson($person)->select('d');
|
||||
$qb = $this->em->getRepository(PersonDocument::class)->createQueryBuilder('d');
|
||||
|
||||
$this->addACL($qb, $person);
|
||||
$qb
|
||||
->where($qb->expr()->eq('d.person', ':person'))
|
||||
->setParameter('person', $person);
|
||||
|
||||
foreach ($orderBy as list($field, $order)) {
|
||||
$qb->addOrderBy($field, $order);
|
||||
}
|
||||
|
||||
$qb->setFirstResult($offset)->setMaxResults($limit);
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
return $qb;
|
||||
}
|
||||
|
||||
public function countByPerson(Person $person): int
|
||||
@ -53,21 +58,23 @@ class PersonDocumentACLAwareRepository implements PersonDocumentACLAwareReposito
|
||||
return $qb->getQuery()->getSingleScalarResult();
|
||||
}
|
||||
|
||||
public function buildQueryByPerson(Person $person): QueryBuilder
|
||||
public function findByPerson(Person $person, array $orderBy = [], int $limit = 20, int $offset = 0): array
|
||||
{
|
||||
$qb = $this->em->getRepository(PersonDocument::class)->createQueryBuilder('d');
|
||||
$qb = $this->buildQueryByPerson($person)->select('d');
|
||||
|
||||
$qb
|
||||
->where($qb->expr()->eq('d.person', ':person'))
|
||||
->setParameter('person', $person)
|
||||
;
|
||||
$this->addACL($qb, $person);
|
||||
|
||||
return $qb;
|
||||
foreach ($orderBy as [$field, $order]) {
|
||||
$qb->addOrderBy($field, $order);
|
||||
}
|
||||
|
||||
$qb->setFirstResult($offset)->setMaxResults($limit);
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
|
||||
private function addACL(QueryBuilder $qb, Person $person): void
|
||||
{
|
||||
|
||||
$center = $this->centerResolverDispatcher->resolveCenter($person);
|
||||
|
||||
$reachableScopes = $this->authorizationHelper
|
||||
@ -78,8 +85,6 @@ class PersonDocumentACLAwareRepository implements PersonDocumentACLAwareReposito
|
||||
);
|
||||
|
||||
$qb->andWhere($qb->expr()->in('d.scope', ':scopes'))
|
||||
->setParameter('scopes', $reachableScopes)
|
||||
;
|
||||
->setParameter('scopes', $reachableScopes);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,21 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\DocStoreBundle\Repository;
|
||||
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
|
||||
interface PersonDocumentACLAwareRepositoryInterface
|
||||
{
|
||||
public function findByPerson(Person $person, array $orderBy = [], int $limit = 20, int $offset = 0): array;
|
||||
|
||||
public function countByPerson(Person $person): int;
|
||||
|
||||
public function findByPerson(Person $person, array $orderBy = [], int $limit = 20, int $offset = 0): array;
|
||||
}
|
||||
|
@ -1,5 +1,12 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\DocStore;
|
||||
@ -8,10 +15,30 @@ use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Implementations of create and update traits for Document entity + template property added
|
||||
* Implementations of create and update traits for Document entity + template property added.
|
||||
*/
|
||||
final class Version20220131093117 extends AbstractMigration
|
||||
{
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_doc.person_document DROP CONSTRAINT FK_41DA53C5DA0FB8');
|
||||
$this->addSql('ALTER TABLE chill_doc.person_document DROP CONSTRAINT FK_41DA53C3174800F');
|
||||
$this->addSql('ALTER TABLE chill_doc.person_document DROP CONSTRAINT FK_41DA53C65FF1AEC');
|
||||
$this->addSql('ALTER TABLE chill_doc.person_document DROP template_id');
|
||||
$this->addSql('ALTER TABLE chill_doc.person_document DROP createdAt');
|
||||
$this->addSql('ALTER TABLE chill_doc.person_document DROP updatedAt');
|
||||
$this->addSql('ALTER TABLE chill_doc.person_document DROP createdBy_id');
|
||||
$this->addSql('ALTER TABLE chill_doc.person_document DROP updatedBy_id');
|
||||
$this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document DROP CONSTRAINT FK_A45098F65DA0FB8');
|
||||
$this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document DROP CONSTRAINT FK_A45098F63174800F');
|
||||
$this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document DROP CONSTRAINT FK_A45098F665FF1AEC');
|
||||
$this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document DROP template_id');
|
||||
$this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document DROP createdAt');
|
||||
$this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document DROP updatedAt');
|
||||
$this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document DROP createdBy_id');
|
||||
$this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document DROP updatedBy_id');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Implementations of create and update traits for Document entity + template property added';
|
||||
@ -46,24 +73,4 @@ final class Version20220131093117 extends AbstractMigration
|
||||
$this->addSql('CREATE INDEX IDX_41DA53C3174800F ON chill_doc.person_document (createdBy_id)');
|
||||
$this->addSql('CREATE INDEX IDX_41DA53C65FF1AEC ON chill_doc.person_document (updatedBy_id)');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_doc.person_document DROP CONSTRAINT FK_41DA53C5DA0FB8');
|
||||
$this->addSql('ALTER TABLE chill_doc.person_document DROP CONSTRAINT FK_41DA53C3174800F');
|
||||
$this->addSql('ALTER TABLE chill_doc.person_document DROP CONSTRAINT FK_41DA53C65FF1AEC');
|
||||
$this->addSql('ALTER TABLE chill_doc.person_document DROP template_id');
|
||||
$this->addSql('ALTER TABLE chill_doc.person_document DROP createdAt');
|
||||
$this->addSql('ALTER TABLE chill_doc.person_document DROP updatedAt');
|
||||
$this->addSql('ALTER TABLE chill_doc.person_document DROP createdBy_id');
|
||||
$this->addSql('ALTER TABLE chill_doc.person_document DROP updatedBy_id');
|
||||
$this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document DROP CONSTRAINT FK_A45098F65DA0FB8');
|
||||
$this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document DROP CONSTRAINT FK_A45098F63174800F');
|
||||
$this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document DROP CONSTRAINT FK_A45098F665FF1AEC');
|
||||
$this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document DROP template_id');
|
||||
$this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document DROP createdAt');
|
||||
$this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document DROP updatedAt');
|
||||
$this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document DROP createdBy_id');
|
||||
$this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document DROP updatedBy_id');
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user