mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge branch 'chill-main-update-repositores-and-entities' into 'master'
Chill main update repositores and entities See merge request Chill-Projet/chill-bundles!82
This commit is contained in:
commit
ce88fe158f
@ -115,7 +115,6 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface,
|
||||
$loader->load('services.yaml');
|
||||
$loader->load('services/doctrine.yaml');
|
||||
$loader->load('services/logger.yaml');
|
||||
$loader->load('services/repositories.yaml');
|
||||
$loader->load('services/pagination.yaml');
|
||||
$loader->load('services/export.yaml');
|
||||
$loader->load('services/form.yaml');
|
||||
|
@ -11,7 +11,7 @@ use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
/**
|
||||
* Address
|
||||
*
|
||||
* @ORM\Entity()
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="chill_main_address")
|
||||
* @ORM\HasLifecycleCallbacks()
|
||||
*/
|
||||
|
@ -7,7 +7,7 @@ use Chill\MainBundle\Doctrine\Model\Point;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
|
||||
/**
|
||||
* @ORM\Entity()
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="chill_main_address_reference")
|
||||
* @ORM\HasLifecycleCallbacks()
|
||||
*/
|
||||
|
@ -25,7 +25,7 @@ use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
||||
/**
|
||||
* @ORM\Entity(repositoryClass="Chill\MainBundle\Repository\CenterRepository")
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="centers")
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
|
@ -8,7 +8,7 @@ use Symfony\Component\Serializer\Annotation\Groups;
|
||||
/**
|
||||
* Country
|
||||
*
|
||||
* @ORM\Entity()
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="country")
|
||||
* @ORM\Cache(usage="READ_ONLY", region="country_cache_region")
|
||||
* @ORM\HasLifecycleCallbacks()
|
||||
|
@ -27,7 +27,7 @@ use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
/**
|
||||
* @ORM\Entity()
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="group_centers")
|
||||
* @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="acl_cache_region")
|
||||
*
|
||||
|
@ -25,7 +25,7 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
/**
|
||||
* Language
|
||||
*
|
||||
* @ORM\Entity()
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="language")
|
||||
* @ORM\Cache(usage="READ_ONLY", region="language_cache_region")
|
||||
* @ORM\HasLifecycleCallbacks()
|
||||
|
@ -27,7 +27,7 @@ use Chill\MainBundle\Entity\RoleScope;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
|
||||
/**
|
||||
* @ORM\Entity()
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="permission_groups")
|
||||
* @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="acl_cache_region")
|
||||
*
|
||||
|
@ -8,7 +8,7 @@ use Symfony\Component\Serializer\Annotation\Groups;
|
||||
/**
|
||||
* PostalCode
|
||||
*
|
||||
* @ORM\Entity(repositoryClass="Chill\MainBundle\Repository\PostalCodeRepository")
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(
|
||||
* name="chill_main_postal_code",
|
||||
* indexes={@ORM\Index(
|
||||
|
@ -25,7 +25,7 @@ use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
/**
|
||||
* @ORM\Entity()
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="role_scopes")
|
||||
* @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="acl_cache_region")
|
||||
*
|
||||
|
@ -28,7 +28,7 @@ use Symfony\Component\Serializer\Annotation\Groups;
|
||||
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||
|
||||
/**
|
||||
* @ORM\Entity()
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="scopes")
|
||||
* @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="acl_cache_region")
|
||||
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||
|
@ -12,7 +12,7 @@ use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||
/**
|
||||
* User
|
||||
*
|
||||
* @ORM\Entity(repositoryClass="Chill\MainBundle\Repository\UserRepository")
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="users")
|
||||
* @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="acl_cache_region")
|
||||
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||
|
@ -19,26 +19,18 @@
|
||||
|
||||
namespace Chill\MainBundle\Form\Type\DataTransformer;
|
||||
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Form\DataTransformerInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||
|
||||
/**
|
||||
* Transform a center object to his id, and vice-versa
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
class CenterTransformer implements DataTransformerInterface
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var ObjectManager
|
||||
*/
|
||||
private $om;
|
||||
|
||||
public function __construct(ObjectManager $om)
|
||||
private EntityManagerInterface $em;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
{
|
||||
$this->om = $om;
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
public function reverseTransform($id)
|
||||
@ -46,15 +38,17 @@ class CenterTransformer implements DataTransformerInterface
|
||||
if ($id === NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
$center = $this->om->getRepository('ChillMainBundle:Center')
|
||||
->find($id);
|
||||
|
||||
|
||||
$center = $this
|
||||
->em
|
||||
->getRepository(Center::class)
|
||||
->find($id);
|
||||
|
||||
if ($center === NULL) {
|
||||
throw new TransformationFailedException(sprintf(
|
||||
'No center found with id %d', $id));
|
||||
}
|
||||
|
||||
|
||||
return $center;
|
||||
}
|
||||
|
||||
@ -63,7 +57,7 @@ class CenterTransformer implements DataTransformerInterface
|
||||
if ($center === NULL) {
|
||||
return '';
|
||||
}
|
||||
|
||||
|
||||
return $center->getId();
|
||||
}
|
||||
|
||||
|
@ -24,28 +24,20 @@ use Symfony\Component\Form\DataTransformerInterface;
|
||||
use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
class MultipleObjectsToIdTransformer implements DataTransformerInterface
|
||||
{
|
||||
/**
|
||||
* @var ObjectManager
|
||||
*/
|
||||
private $em;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $class;
|
||||
|
||||
/**
|
||||
* @param ObjectManager $em
|
||||
*/
|
||||
public function __construct(ObjectManager $em, $class)
|
||||
private EntityManagerInterface $em;
|
||||
|
||||
private ?string $class;
|
||||
|
||||
public function __construct(EntityManagerInterface $em, ?string $class = null)
|
||||
{
|
||||
$this->em = $em;
|
||||
$this->class = $class;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Transforms an object (use) to a string (id).
|
||||
*
|
||||
|
@ -20,28 +20,20 @@
|
||||
|
||||
namespace Chill\MainBundle\Form\Type\DataTransformer;
|
||||
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Form\DataTransformerInterface;
|
||||
use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
|
||||
class ObjectToIdTransformer implements DataTransformerInterface
|
||||
{
|
||||
/**
|
||||
* @var ObjectManager
|
||||
*/
|
||||
private $om;
|
||||
private EntityManagerInterface $em;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $class;
|
||||
private ?string $class;
|
||||
|
||||
/**
|
||||
* @param ObjectManager $om
|
||||
*/
|
||||
public function __construct(ObjectManager $om, $class)
|
||||
public function __construct(EntityManagerInterface $em, ?string $class = null)
|
||||
{
|
||||
$this->om = $om;
|
||||
$this->em = $em;
|
||||
$this->class = $class;
|
||||
}
|
||||
|
||||
@ -73,7 +65,7 @@ class ObjectToIdTransformer implements DataTransformerInterface
|
||||
return null;
|
||||
}
|
||||
|
||||
$object = $this->om
|
||||
$object = $this->em
|
||||
->getRepository($this->class)
|
||||
->find($id)
|
||||
;
|
||||
|
@ -19,41 +19,28 @@
|
||||
|
||||
namespace Chill\MainBundle\Form\Type\DataTransformer;
|
||||
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Symfony\Component\Form\DataTransformerInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Symfony\Component\Form\Exception\TransformationFailedException;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
class ScopeTransformer implements DataTransformerInterface
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var ObjectManager
|
||||
*/
|
||||
protected $om;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var TranslatableStringHelper
|
||||
*/
|
||||
protected $helper;
|
||||
|
||||
public function __construct(ObjectManager $om)
|
||||
private EntityManagerInterface $em;
|
||||
|
||||
public function __construct(EntityManagerInterface $em)
|
||||
{
|
||||
$this->om = $om;
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
|
||||
public function transform($scope)
|
||||
{
|
||||
if ($scope === NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
return $scope->getId();
|
||||
}
|
||||
|
||||
@ -62,15 +49,17 @@ class ScopeTransformer implements DataTransformerInterface
|
||||
if ($id == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
$scope = $this->om->getRepository('ChillMainBundle:Scope')
|
||||
->find($id);
|
||||
|
||||
|
||||
$scope = $this
|
||||
->em
|
||||
->getRepository(Scope::class)
|
||||
->find($id);
|
||||
|
||||
if ($scope === NULL) {
|
||||
throw new TransformationFailedException(sprintf("The scope with id "
|
||||
. "'%d' were not found", $id));
|
||||
}
|
||||
|
||||
|
||||
return $scope;
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ use Chill\MainBundle\Entity\Center;
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Form\DataMapper\ScopePickerDataMapper;
|
||||
use Chill\MainBundle\Repository\ScopeRepository;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
@ -60,7 +61,7 @@ class ScopePickerType extends AbstractType
|
||||
protected $tokenStorage;
|
||||
|
||||
/**
|
||||
* @var EntityRepository
|
||||
* @var ScopeRepository
|
||||
*/
|
||||
protected $scopeRepository;
|
||||
|
||||
@ -72,7 +73,7 @@ class ScopePickerType extends AbstractType
|
||||
public function __construct(
|
||||
AuthorizationHelper $authorizationHelper,
|
||||
TokenStorageInterface $tokenStorage,
|
||||
EntityRepository $scopeRepository,
|
||||
ScopeRepository $scopeRepository,
|
||||
TranslatableStringHelper $translatableStringHelper
|
||||
) {
|
||||
$this->authorizationHelper = $authorizationHelper;
|
||||
|
@ -25,6 +25,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
|
||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Repository\UserRepository;
|
||||
use Symfony\Component\Security\Core\Role\RoleHierarchyInterface;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
|
||||
@ -53,16 +54,12 @@ class UserPickerType extends AbstractType
|
||||
*/
|
||||
protected $tokenStorage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var \Chill\MainBundle\Repository\UserRepository
|
||||
*/
|
||||
protected $userRepository;
|
||||
protected UserRepository $userRepository;
|
||||
|
||||
public function __construct(
|
||||
AuthorizationHelper $authorizationHelper,
|
||||
TokenStorageInterface $tokenStorage,
|
||||
EntityRepository $userRepository
|
||||
UserRepository $userRepository
|
||||
) {
|
||||
$this->authorizationHelper = $authorizationHelper;
|
||||
$this->tokenStorage = $tokenStorage;
|
||||
|
@ -1,50 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Repository;
|
||||
|
||||
use Chill\MainBundle\Entity\AddressReference;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
|
||||
/**
|
||||
* @method AddressReference|null find($id, $lockMode = null, $lockVersion = null)
|
||||
* @method AddressReference|null findOneBy(array $criteria, array $orderBy = null)
|
||||
* @method AddressReference[] findAll()
|
||||
* @method AddressReference[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
|
||||
*/
|
||||
class AddressReferenceRepository extends ServiceEntityRepository
|
||||
final class AddressReferenceRepository implements ObjectRepository
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
private EntityRepository $repository;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
{
|
||||
parent::__construct($registry, AddressReference::class);
|
||||
$this->repository = $entityManager->getRepository(AddressReference::class);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return AddressReference[] Returns an array of AddressReference objects
|
||||
// */
|
||||
/*
|
||||
public function findByExampleField($value)
|
||||
public function find($id, $lockMode = null, $lockVersion = null): ?AddressReference
|
||||
{
|
||||
return $this->createQueryBuilder('a')
|
||||
->andWhere('a.exampleField = :val')
|
||||
->setParameter('val', $value)
|
||||
->orderBy('a.id', 'ASC')
|
||||
->setMaxResults(10)
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
return $this->repository->find($id, $lockMode, $lockVersion);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
public function findOneBySomeField($value): ?AddressReference
|
||||
public function findOneBy(array $criteria, array $orderBy = null): ?AddressReference
|
||||
{
|
||||
return $this->createQueryBuilder('a')
|
||||
->andWhere('a.exampleField = :val')
|
||||
->setParameter('val', $value)
|
||||
->getQuery()
|
||||
->getOneOrNullResult()
|
||||
;
|
||||
return $this->repository->findOneBy($criteria, $orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AddressReference[]
|
||||
*/
|
||||
public function findAll(): array
|
||||
{
|
||||
return $this->repository->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AddressReference[]
|
||||
*/
|
||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
||||
public function getClassName() {
|
||||
return AddressReference::class;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
50
src/Bundle/ChillMainBundle/Repository/AddressRepository.php
Normal file
50
src/Bundle/ChillMainBundle/Repository/AddressRepository.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Repository;
|
||||
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
|
||||
final class AddressRepository implements ObjectRepository
|
||||
{
|
||||
private EntityRepository $repository;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
{
|
||||
$this->repository = $entityManager->getRepository(Address::class);
|
||||
}
|
||||
|
||||
public function find($id, $lockMode = null, $lockVersion = null): ?Address
|
||||
{
|
||||
return $this->repository->find($id, $lockMode, $lockVersion);
|
||||
}
|
||||
|
||||
public function findOneBy(array $criteria, array $orderBy = null): ?Address
|
||||
{
|
||||
return $this->repository->findOneBy($criteria, $orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Address[]
|
||||
*/
|
||||
public function findAll(): array
|
||||
{
|
||||
return $this->repository->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Address[]
|
||||
*/
|
||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
||||
public function getClassName() {
|
||||
return Address::class;
|
||||
}
|
||||
}
|
@ -1,27 +1,50 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2018 Champs-Libres <info@champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Repository;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
class CenterRepository extends \Doctrine\ORM\EntityRepository
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
|
||||
final class CenterRepository implements ObjectRepository
|
||||
{
|
||||
|
||||
private EntityRepository $repository;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
{
|
||||
$this->repository = $entityManager->getRepository(Center::class);
|
||||
}
|
||||
|
||||
public function find($id, $lockMode = null, $lockVersion = null): ?Center
|
||||
{
|
||||
return $this->repository->find($id, $lockMode, $lockVersion);
|
||||
}
|
||||
|
||||
public function findOneBy(array $criteria, array $orderBy = null): ?Center
|
||||
{
|
||||
return $this->repository->findOneBy($criteria, $orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Center[]
|
||||
*/
|
||||
public function findAll(): array
|
||||
{
|
||||
return $this->repository->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Center[]
|
||||
*/
|
||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
||||
public function getClassName() {
|
||||
return Center::class;
|
||||
}
|
||||
}
|
||||
|
50
src/Bundle/ChillMainBundle/Repository/CountryRepository.php
Normal file
50
src/Bundle/ChillMainBundle/Repository/CountryRepository.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Repository;
|
||||
|
||||
use Chill\MainBundle\Entity\Country;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
|
||||
final class CountryRepository implements ObjectRepository
|
||||
{
|
||||
private EntityRepository $repository;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
{
|
||||
$this->repository = $entityManager->getRepository(Country::class);
|
||||
}
|
||||
|
||||
public function find($id, $lockMode = null, $lockVersion = null): ?Country
|
||||
{
|
||||
return $this->repository->find($id, $lockMode, $lockVersion);
|
||||
}
|
||||
|
||||
public function findOneBy(array $criteria, array $orderBy = null): ?Country
|
||||
{
|
||||
return $this->repository->findOneBy($criteria, $orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Country[]
|
||||
*/
|
||||
public function findAll(): array
|
||||
{
|
||||
return $this->repository->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Country[]
|
||||
*/
|
||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
||||
public function getClassName() {
|
||||
return Country::class;
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Repository;
|
||||
|
||||
use Chill\MainBundle\Entity\GroupCenter;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
|
||||
final class GroupCenterRepository implements ObjectRepository
|
||||
{
|
||||
private EntityRepository $repository;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
{
|
||||
$this->repository = $entityManager->getRepository(GroupCenter::class);
|
||||
}
|
||||
|
||||
public function find($id, $lockMode = null, $lockVersion = null): ?GroupCenter
|
||||
{
|
||||
return $this->repository->find($id, $lockMode, $lockVersion);
|
||||
}
|
||||
|
||||
public function findOneBy(array $criteria, array $orderBy = null): ?GroupCenter
|
||||
{
|
||||
return $this->repository->findOneBy($criteria, $orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return GroupCenter[]
|
||||
*/
|
||||
public function findAll(): array
|
||||
{
|
||||
return $this->repository->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return GroupCenter[]
|
||||
*/
|
||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
||||
public function getClassName() {
|
||||
return GroupCenter::class;
|
||||
}
|
||||
}
|
50
src/Bundle/ChillMainBundle/Repository/LanguageRepository.php
Normal file
50
src/Bundle/ChillMainBundle/Repository/LanguageRepository.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Repository;
|
||||
|
||||
use Chill\MainBundle\Entity\Language;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
|
||||
final class LanguageRepository implements ObjectRepository
|
||||
{
|
||||
private EntityRepository $repository;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
{
|
||||
$this->repository = $entityManager->getRepository(Language::class);
|
||||
}
|
||||
|
||||
public function find($id, $lockMode = null, $lockVersion = null): ?Language
|
||||
{
|
||||
return $this->repository->find($id, $lockMode, $lockVersion);
|
||||
}
|
||||
|
||||
public function findOneBy(array $criteria, array $orderBy = null): ?Language
|
||||
{
|
||||
return $this->repository->findOneBy($criteria, $orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Language[]
|
||||
*/
|
||||
public function findAll(): array
|
||||
{
|
||||
return $this->repository->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Language[]
|
||||
*/
|
||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
||||
public function getClassName() {
|
||||
return Language::class;
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Repository;
|
||||
|
||||
use Chill\MainBundle\Entity\PermissionsGroup;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
|
||||
final class PermissionsGroupRepository implements ObjectRepository
|
||||
{
|
||||
private EntityRepository $repository;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
{
|
||||
$this->repository = $entityManager->getRepository(PermissionsGroup::class);
|
||||
}
|
||||
|
||||
public function find($id, $lockMode = null, $lockVersion = null): ?PermissionsGroup
|
||||
{
|
||||
return $this->repository->find($id, $lockMode, $lockVersion);
|
||||
}
|
||||
|
||||
public function findOneBy(array $criteria, array $orderBy = null): ?PermissionsGroup
|
||||
{
|
||||
return $this->repository->findOneBy($criteria, $orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PermissionsGroup[]
|
||||
*/
|
||||
public function findAll(): array
|
||||
{
|
||||
return $this->repository->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PermissionsGroup[]
|
||||
*/
|
||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
||||
public function getClassName() {
|
||||
return PermissionsGroup::class;
|
||||
}
|
||||
}
|
@ -1,28 +1,50 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2018 Champs-Libres <info@champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Repository;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
class PostalCodeRepository extends \Doctrine\ORM\EntityRepository
|
||||
use Chill\MainBundle\Entity\PostalCode;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
|
||||
final class PostalCodeRepository implements ObjectRepository
|
||||
{
|
||||
|
||||
private EntityRepository $repository;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
{
|
||||
$this->repository = $entityManager->getRepository(PostalCode::class);
|
||||
}
|
||||
|
||||
public function find($id, $lockMode = null, $lockVersion = null): ?PostalCode
|
||||
{
|
||||
return $this->repository->find($id, $lockMode, $lockVersion);
|
||||
}
|
||||
|
||||
public function findOneBy(array $criteria, array $orderBy = null): ?PostalCode
|
||||
{
|
||||
return $this->repository->findOneBy($criteria, $orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PostalCode[]
|
||||
*/
|
||||
public function findAll(): array
|
||||
{
|
||||
return $this->repository->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PostalCode[]
|
||||
*/
|
||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
||||
public function getClassName() {
|
||||
return PostalCode::class;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Repository;
|
||||
|
||||
use Chill\MainBundle\Entity\RoleScope;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
|
||||
final class RoleScopeRepository implements ObjectRepository
|
||||
{
|
||||
private EntityRepository $repository;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
{
|
||||
$this->repository = $entityManager->getRepository(RoleScope::class);
|
||||
}
|
||||
|
||||
public function find($id, $lockMode = null, $lockVersion = null): ?RoleScope
|
||||
{
|
||||
return $this->repository->find($id, $lockMode, $lockVersion);
|
||||
}
|
||||
|
||||
public function findOneBy(array $criteria, array $orderBy = null): ?RoleScope
|
||||
{
|
||||
return $this->repository->findOneBy($criteria, $orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return RoleScope[]
|
||||
*/
|
||||
public function findAll(): array
|
||||
{
|
||||
return $this->repository->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return RoleScope[]
|
||||
*/
|
||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
||||
public function getClassName() {
|
||||
return RoleScope::class;
|
||||
}
|
||||
}
|
50
src/Bundle/ChillMainBundle/Repository/ScopeRepository.php
Normal file
50
src/Bundle/ChillMainBundle/Repository/ScopeRepository.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Repository;
|
||||
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
|
||||
final class ScopeRepository implements ObjectRepository
|
||||
{
|
||||
private EntityRepository $repository;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
{
|
||||
$this->repository = $entityManager->getRepository(Scope::class);
|
||||
}
|
||||
|
||||
public function find($id, $lockMode = null, $lockVersion = null): ?Scope
|
||||
{
|
||||
return $this->repository->find($id, $lockMode, $lockVersion);
|
||||
}
|
||||
|
||||
public function findOneBy(array $criteria, array $orderBy = null): ?Scope
|
||||
{
|
||||
return $this->repository->findOneBy($criteria, $orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Scope[]
|
||||
*/
|
||||
public function findAll(): array
|
||||
{
|
||||
return $this->repository->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Scope[]
|
||||
*/
|
||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
||||
public function getClassName() {
|
||||
return Scope::class;
|
||||
}
|
||||
}
|
@ -1,121 +1,148 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (C) 2018 Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Repository;
|
||||
|
||||
use Chill\MainBundle\Entity\GroupCenter;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
class UserRepository extends \Doctrine\ORM\EntityRepository
|
||||
final class UserRepository implements ObjectRepository
|
||||
{
|
||||
public function countByUsernameOrEmail($pattern)
|
||||
private EntityRepository $repository;
|
||||
|
||||
private EntityManagerInterface $entityManager;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
{
|
||||
$this->entityManager = $entityManager;
|
||||
$this->repository = $entityManager->getRepository(User::class);
|
||||
}
|
||||
|
||||
public function find($id, $lockMode = null, $lockVersion = null): ?User
|
||||
{
|
||||
return $this->repository->find($id, $lockMode, $lockVersion);
|
||||
}
|
||||
|
||||
public function findOneBy(array $criteria, array $orderBy = null): ?User
|
||||
{
|
||||
return $this->repository->findOneBy($criteria, $orderBy);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User[]
|
||||
*/
|
||||
public function findAll(): array
|
||||
{
|
||||
return $this->repository->findAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return User[]
|
||||
*/
|
||||
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
||||
public function getClassName() {
|
||||
return User::class;
|
||||
}
|
||||
|
||||
public function countByUsernameOrEmail(string $pattern): int
|
||||
{
|
||||
$qb = $this->queryByUsernameOrEmail($pattern);
|
||||
|
||||
|
||||
$qb->select('COUNT(u)');
|
||||
|
||||
|
||||
return (int) $qb->getQuery()->getSingleScalarResult();
|
||||
}
|
||||
|
||||
public function findByUsernameOrEmail($pattern)
|
||||
|
||||
public function findByUsernameOrEmail(string $pattern)
|
||||
{
|
||||
$qb = $this->queryByUsernameOrEmail($pattern);
|
||||
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
|
||||
public function findOneByUsernameOrEmail($pattern)
|
||||
|
||||
public function findOneByUsernameOrEmail(string $pattern)
|
||||
{
|
||||
$qb = $this->queryByUsernameOrEmail($pattern);
|
||||
|
||||
|
||||
return $qb->getQuery()->getSingleResult();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the users having a specific flags
|
||||
*
|
||||
* If provided, only the users amongst "filtered users" are searched. This
|
||||
* allows to make a first search amongst users based on role and center
|
||||
*
|
||||
* If provided, only the users amongst "filtered users" are searched. This
|
||||
* allows to make a first search amongst users based on role and center
|
||||
* and, then filter those users having some flags.
|
||||
*
|
||||
*
|
||||
* @param \Chill\MainBundle\Entity\User[] $amongstUsers
|
||||
*/
|
||||
public function findUsersHavingFlags($flag, $amongstUsers = [])
|
||||
public function findUsersHavingFlags($flag, array $amongstUsers = []): array
|
||||
{
|
||||
$gcs = $this->_em->createQuery("SELECT DISTINCT gc "
|
||||
. "FROM ".GroupCenter::class." gc "
|
||||
. "JOIN gc.permissionsGroup pg "
|
||||
. "WHERE "
|
||||
. "JSONB_EXISTS_IN_ARRAY(pg.flags, :flag) = :true ")
|
||||
$gcs = $this
|
||||
->entityManager
|
||||
->createQuery(
|
||||
"SELECT DISTINCT gc " .
|
||||
"FROM ".GroupCenter::class." gc " .
|
||||
"JOIN gc.permissionsGroup pg " .
|
||||
"WHERE " .
|
||||
"JSONB_EXISTS_IN_ARRAY(pg.flags, :flag) = :true "
|
||||
)
|
||||
->setParameters([
|
||||
'true' => true,
|
||||
'flag' => $flag
|
||||
])
|
||||
->getResult();
|
||||
|
||||
|
||||
if (count($gcs) === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$qb = $this->_em->createQueryBuilder();
|
||||
|
||||
$qb = $this->entityManager->createQueryBuilder();
|
||||
$qb
|
||||
->select('DISTINCT u')
|
||||
->from(User::class, 'u')
|
||||
->where("u.enabled = 'TRUE'")
|
||||
;
|
||||
|
||||
->where("u.enabled = 'TRUE'");
|
||||
|
||||
$orx = $qb->expr()->orX();
|
||||
|
||||
foreach($gcs as $i => $gc) {
|
||||
$orx->add(':gc_'.$i.' MEMBER OF u.groupCenters');
|
||||
$qb->setParameter('gc_'.$i, $gc);
|
||||
$orx->add(':gc_' . $i . ' MEMBER OF u.groupCenters');
|
||||
$qb->setParameter('gc_' . $i, $gc);
|
||||
}
|
||||
|
||||
|
||||
$qb->andWhere($orx);
|
||||
|
||||
if (count($amongstUsers) > 0) {
|
||||
|
||||
if ($amongstUsers !== []) {
|
||||
$qb
|
||||
->andWhere($qb->expr()->in('u', ':amongstUsers'))
|
||||
->setParameter('amongstUsers', $amongstUsers)
|
||||
;
|
||||
->setParameter('amongstUsers', $amongstUsers);
|
||||
}
|
||||
|
||||
|
||||
return $qb->getQuery()->getResult();
|
||||
}
|
||||
|
||||
protected function queryByUsernameOrEmail($pattern)
|
||||
|
||||
protected function queryByUsernameOrEmail(string $pattern): QueryBuilder
|
||||
{
|
||||
$qb = $this->createQueryBuilder('u');
|
||||
|
||||
$qb = $this->entityManager->createQueryBuilder('u');
|
||||
|
||||
$searchByPattern = $qb->expr()->orX();
|
||||
|
||||
|
||||
$searchByPattern
|
||||
->add($qb->expr()->eq('u.usernameCanonical', 'LOWER(UNACCENT(:pattern))'))
|
||||
->add($qb->expr()->eq('u.emailCanonical', 'LOWER(UNACCENT(:pattern))'))
|
||||
;
|
||||
|
||||
->add($qb->expr()->eq('u.emailCanonical', 'LOWER(UNACCENT(:pattern))'));
|
||||
|
||||
$qb
|
||||
->where($searchByPattern)
|
||||
->setParameter('pattern', $pattern)
|
||||
;
|
||||
|
||||
->setParameter('pattern', $pattern);
|
||||
|
||||
return $qb;
|
||||
}
|
||||
}
|
||||
|
@ -2,17 +2,33 @@ parameters:
|
||||
# cl_chill_main.example.class: Chill\MainBundle\Example
|
||||
|
||||
services:
|
||||
_defaults:
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
|
||||
Chill\MainBundle\Repository\:
|
||||
resource: '../Repository/'
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
|
||||
Chill\MainBundle\Serializer\Normalizer\:
|
||||
resource: '../Serializer/Normalizer'
|
||||
autoconfigure: true
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: 'serializer.normalizer', priority: 64 }
|
||||
|
||||
Chill\MainBundle\Form\Type\:
|
||||
resource: '../Form/Type'
|
||||
autoconfigure: true
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: form.type }
|
||||
|
||||
Chill\MainBundle\Doctrine\Event\:
|
||||
resource: '../Doctrine/Event/'
|
||||
autowire: true
|
||||
tags:
|
||||
tags:
|
||||
- { name: 'doctrine.event_subscriber' }
|
||||
|
||||
chill.main.helper.translatable_string:
|
||||
|
@ -65,8 +65,6 @@ services:
|
||||
|
||||
chill.main.form.choice_loader.postal_code:
|
||||
class: Chill\MainBundle\Form\ChoiceLoader\PostalCodeChoiceLoader
|
||||
arguments:
|
||||
- '@Chill\MainBundle\Repository\PostalCodeRepository'
|
||||
|
||||
chill.main.form.type.export:
|
||||
class: Chill\MainBundle\Form\Type\Export\ExportType
|
||||
@ -98,32 +96,10 @@ services:
|
||||
arguments:
|
||||
- '@Chill\MainBundle\Export\ExportManager'
|
||||
|
||||
chill.main.form.date_type:
|
||||
class: Chill\MainBundle\Form\Type\ChillDateType
|
||||
tags:
|
||||
- { name: form.type }
|
||||
|
||||
chill.main.form.pick_user_type:
|
||||
class: Chill\MainBundle\Form\Type\UserPickerType
|
||||
arguments:
|
||||
- "@chill.main.security.authorization.helper"
|
||||
- "@security.token_storage"
|
||||
- "@chill.main.user_repository"
|
||||
tags:
|
||||
- { name: form.type }
|
||||
|
||||
chill.main.form.pick_scope_type:
|
||||
class: Chill\MainBundle\Form\Type\ScopePickerType
|
||||
arguments:
|
||||
- "@chill.main.security.authorization.helper"
|
||||
- "@security.token_storage"
|
||||
- "@chill.main.scope_repository"
|
||||
- "@chill.main.helper.translatable_string"
|
||||
tags:
|
||||
- { name: form.type }
|
||||
|
||||
chill.main.form.advanced_search_type:
|
||||
class: Chill\MainBundle\Form\AdvancedSearchType
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
arguments:
|
||||
- "@chill_main.search_provider"
|
||||
tags:
|
||||
|
@ -1,35 +0,0 @@
|
||||
services:
|
||||
chill.main.countries_repository:
|
||||
class: Doctrine\ORM\EntityRepository
|
||||
factory: ["@doctrine.orm.entity_manager", getRepository]
|
||||
arguments:
|
||||
- "Chill\\MainBundle\\Entity\\Country"
|
||||
|
||||
chill.main.user_repository:
|
||||
class: Doctrine\ORM\EntityRepository
|
||||
factory: ["@doctrine.orm.entity_manager", getRepository]
|
||||
arguments:
|
||||
- "Chill\\MainBundle\\Entity\\User"
|
||||
|
||||
chill.main.scope_repository:
|
||||
class: Doctrine\ORM\EntityRepository
|
||||
factory: ["@doctrine.orm.entity_manager", getRepository]
|
||||
arguments:
|
||||
- "Chill\\MainBundle\\Entity\\Scope"
|
||||
|
||||
chill.main.postalcode_repository:
|
||||
class: Doctrine\ORM\EntityRepository
|
||||
factory: ["@doctrine.orm.entity_manager", getRepository]
|
||||
arguments:
|
||||
- "Chill\\MainBundle\\Entity\\PostalCode"
|
||||
|
||||
Chill\MainBundle\Repository\PostalCodeRepository: '@chill.main.postalcode_repository'
|
||||
|
||||
chill.main.center_repository:
|
||||
class: Doctrine\ORM\EntityRepository
|
||||
factory: ["@doctrine.orm.entity_manager", getRepository]
|
||||
arguments:
|
||||
- "Chill\\MainBundle\\Entity\\Center"
|
||||
|
||||
Chill\MainBundle\Repository\CenterRepository: '@chill.main.center_repository'
|
||||
|
@ -32,9 +32,8 @@ services:
|
||||
- { name: twig.extension }
|
||||
|
||||
Chill\MainBundle\Templating\Entity\CommentRender:
|
||||
arguments:
|
||||
- '@chill.main.user_repository'
|
||||
- '@Symfony\Component\Templating\EngineInterface'
|
||||
autoconfigure: true
|
||||
autowire: true
|
||||
tags:
|
||||
- { name: 'chill.render_entity' }
|
||||
|
||||
|
@ -24,28 +24,17 @@ use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
||||
use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
use Symfony\Component\Translation\TranslatorInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
class AgeAggregator implements AggregatorInterface,
|
||||
ExportElementValidatedInterface
|
||||
final class AgeAggregator implements AggregatorInterface, ExportElementValidatedInterface
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var
|
||||
*/
|
||||
protected $translator;
|
||||
|
||||
public function __construct($translator)
|
||||
private TranslatorInterface $translator;
|
||||
|
||||
public function __construct(TranslatorInterface $translator)
|
||||
{
|
||||
$this->translator = $translator;
|
||||
}
|
||||
|
||||
|
||||
public function addRole()
|
||||
{
|
||||
return null;
|
||||
|
@ -29,40 +29,23 @@ use Chill\MainBundle\Util\CountriesInfo;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||
use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
||||
use Chill\MainBundle\Repository\CountryRepository;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
class CountryOfBirthAggregator implements AggregatorInterface,
|
||||
ExportElementValidatedInterface
|
||||
final class CountryOfBirthAggregator implements AggregatorInterface, ExportElementValidatedInterface
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var EntityRepository
|
||||
*/
|
||||
protected $countriesRepository;
|
||||
private CountryRepository $countriesRepository;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var TranslatableStringHelper
|
||||
*/
|
||||
protected $translatableStringHelper;
|
||||
private TranslatableStringHelper $translatableStringHelper;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var TranslatorInterface
|
||||
*/
|
||||
protected $translator;
|
||||
private TranslatorInterface $translator;
|
||||
|
||||
public function __construct(EntityRepository $countriesRepository,
|
||||
TranslatableStringHelper $translatableStringHelper,
|
||||
TranslatorInterface $translator)
|
||||
{
|
||||
public function __construct(
|
||||
CountryRepository $countriesRepository,
|
||||
TranslatableStringHelper $translatableStringHelper,
|
||||
TranslatorInterface $translator
|
||||
) {
|
||||
$this->countriesRepository = $countriesRepository;
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
$this->translator = $translator;
|
||||
@ -73,7 +56,6 @@ class CountryOfBirthAggregator implements AggregatorInterface,
|
||||
return 'person';
|
||||
}
|
||||
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
$builder->add('group_by_level', ChoiceType::class, array(
|
||||
|
@ -26,31 +26,20 @@ use Symfony\Component\Translation\TranslatorInterface;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
class GenderAggregator implements AggregatorInterface
|
||||
final class GenderAggregator implements AggregatorInterface
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var TranslatorInterface
|
||||
*/
|
||||
protected $translator;
|
||||
|
||||
private TranslatorInterface $translator;
|
||||
|
||||
public function __construct(TranslatorInterface $translator)
|
||||
{
|
||||
$this->translator = $translator;
|
||||
}
|
||||
|
||||
|
||||
public function applyOn()
|
||||
{
|
||||
return Declarations::PERSON_TYPE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder)
|
||||
{
|
||||
|
||||
|
@ -29,39 +29,23 @@ use Chill\MainBundle\Util\CountriesInfo;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||
use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
||||
use Chill\MainBundle\Repository\CountryRepository;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
class NationalityAggregator implements AggregatorInterface,
|
||||
ExportElementValidatedInterface
|
||||
final class NationalityAggregator implements AggregatorInterface, ExportElementValidatedInterface
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var EntityRepository
|
||||
*/
|
||||
protected $countriesRepository;
|
||||
private CountryRepository $countriesRepository;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var TranslatableStringHelper
|
||||
*/
|
||||
protected $translatableStringHelper;
|
||||
private TranslatableStringHelper $translatableStringHelper;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var TranslatorInterface
|
||||
*/
|
||||
protected $translator;
|
||||
private TranslatorInterface $translator;
|
||||
|
||||
public function __construct(EntityRepository $countriesRepository,
|
||||
TranslatableStringHelper $translatableStringHelper,
|
||||
TranslatorInterface $translator)
|
||||
{
|
||||
public function __construct(
|
||||
CountryRepository $countriesRepository,
|
||||
TranslatableStringHelper $translatableStringHelper,
|
||||
TranslatorInterface $translator
|
||||
) {
|
||||
$this->countriesRepository = $countriesRepository;
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
$this->translator = $translator;
|
||||
|
@ -68,6 +68,11 @@ services:
|
||||
resource: '../Controller/'
|
||||
tags: ['controller.service_arguments']
|
||||
|
||||
Chill\PersonBundle\Export\:
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
resource: '../Export/'
|
||||
|
||||
Chill\PersonBundle\Templating\Entity\:
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
|
@ -36,43 +36,39 @@ services:
|
||||
chill.person.export.filter_birthdate:
|
||||
class: Chill\PersonBundle\Export\Filter\BirthdateFilter
|
||||
tags:
|
||||
- { name: chill.export_filter, alias: person_birthdate_filter }
|
||||
|
||||
- { name: chill.export_filter, alias: person_birthdate_filter }
|
||||
|
||||
chill.person.export.filter_nationality:
|
||||
class: Chill\PersonBundle\Export\Filter\NationalityFilter
|
||||
arguments:
|
||||
- "@chill.main.helper.translatable_string"
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_filter, alias: person_nationality_filter }
|
||||
|
||||
chill.person.export.aggregator_nationality:
|
||||
class: Chill\PersonBundle\Export\Aggregator\NationalityAggregator
|
||||
arguments:
|
||||
- "@chill.main.countries_repository"
|
||||
- "@chill.main.helper.translatable_string"
|
||||
- "@translator"
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_aggregator, alias: person_nationality_aggregator }
|
||||
|
||||
chill.person.export.aggregator_country_of_birth:
|
||||
class: Chill\PersonBundle\Export\Aggregator\CountryOfBirthAggregator
|
||||
arguments:
|
||||
- "@chill.main.countries_repository"
|
||||
- "@chill.main.helper.translatable_string"
|
||||
- "@translator"
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_aggregator, alias: person_country_of_birth_aggregator }
|
||||
|
||||
chill.person.export.aggregator_gender:
|
||||
class: Chill\PersonBundle\Export\Aggregator\GenderAggregator
|
||||
arguments:
|
||||
- "@translator"
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_aggregator, alias: person_gender_aggregator }
|
||||
|
||||
chill.person.export.aggregator_age:
|
||||
class: Chill\PersonBundle\Export\Aggregator\AgeAggregator
|
||||
arguments:
|
||||
- "@translator"
|
||||
autowire: true
|
||||
autoconfigure: true
|
||||
tags:
|
||||
- { name: chill.export_aggregator, alias: person_age_aggregator }
|
||||
|
Loading…
x
Reference in New Issue
Block a user