mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-05 14:25:00 +00:00
Resolve merge with master
This commit is contained in:
@@ -25,12 +25,12 @@ class LoadEventTypes extends AbstractFixture implements OrderedFixtureInterface
|
||||
{
|
||||
public static $refs = [];
|
||||
|
||||
public function getOrder()
|
||||
public function getOrder(): int
|
||||
{
|
||||
return 30000;
|
||||
}
|
||||
|
||||
public function load(ObjectManager $manager)
|
||||
public function load(ObjectManager $manager): void
|
||||
{
|
||||
/*
|
||||
* Echange de savoirs
|
||||
|
@@ -12,9 +12,11 @@ declare(strict_types=1);
|
||||
namespace Chill\EventBundle\DataFixtures\ORM;
|
||||
|
||||
use Chill\EventBundle\Entity\Event;
|
||||
use Chill\EventBundle\Entity\EventType;
|
||||
use Chill\EventBundle\Entity\Participation;
|
||||
use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
|
||||
use Chill\MainBundle\Entity\Center;
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||
@@ -44,11 +46,12 @@ class LoadParticipation extends AbstractFixture implements OrderedFixtureInterfa
|
||||
$event = (new Event())
|
||||
->setDate($this->faker->dateTimeBetween('-2 years', '+6 months'))
|
||||
->setName($this->faker->words(random_int(2, 4), true))
|
||||
->setType($this->getReference(LoadEventTypes::$refs[array_rand(LoadEventTypes::$refs)]))
|
||||
->setType($this->getReference(LoadEventTypes::$refs[array_rand(LoadEventTypes::$refs)], EventType::class))
|
||||
->setCenter($center)
|
||||
->setCircle(
|
||||
$this->getReference(
|
||||
LoadScopes::$references[array_rand(LoadScopes::$references)]
|
||||
LoadScopes::$references[array_rand(LoadScopes::$references)],
|
||||
Scope::class
|
||||
)
|
||||
);
|
||||
$manager->persist($event);
|
||||
@@ -58,12 +61,12 @@ class LoadParticipation extends AbstractFixture implements OrderedFixtureInterfa
|
||||
return $events;
|
||||
}
|
||||
|
||||
public function getOrder()
|
||||
public function getOrder(): int
|
||||
{
|
||||
return 30010;
|
||||
}
|
||||
|
||||
public function load(ObjectManager $manager)
|
||||
public function load(ObjectManager $manager): void
|
||||
{
|
||||
$centers = $manager->getRepository(Center::class)
|
||||
->findAll();
|
||||
|
@@ -13,7 +13,9 @@ namespace Chill\EventBundle\DataFixtures\ORM;
|
||||
|
||||
use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup;
|
||||
use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
|
||||
use Chill\MainBundle\Entity\PermissionsGroup;
|
||||
use Chill\MainBundle\Entity\RoleScope;
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
@@ -23,18 +25,18 @@ use Doctrine\Persistence\ObjectManager;
|
||||
*/
|
||||
class LoadRolesACL extends AbstractFixture implements OrderedFixtureInterface
|
||||
{
|
||||
public function getOrder()
|
||||
public function getOrder(): int
|
||||
{
|
||||
return 30011;
|
||||
}
|
||||
|
||||
public function load(ObjectManager $manager)
|
||||
public function load(ObjectManager $manager): void
|
||||
{
|
||||
foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) {
|
||||
$permissionsGroup = $this->getReference($permissionsGroupRef);
|
||||
$permissionsGroup = $this->getReference($permissionsGroupRef, PermissionsGroup::class);
|
||||
|
||||
foreach (LoadScopes::$references as $scopeRef) {
|
||||
$scope = $this->getReference($scopeRef);
|
||||
$scope = $this->getReference($scopeRef, Scope::class);
|
||||
// create permission group
|
||||
switch ($permissionsGroup->getName()) {
|
||||
case 'social':
|
||||
|
@@ -31,7 +31,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
||||
/**
|
||||
* Class Event.
|
||||
*/
|
||||
#[ORM\Entity(repositoryClass: \Chill\EventBundle\Repository\EventRepository::class)]
|
||||
#[ORM\Entity]
|
||||
#[ORM\HasLifecycleCallbacks]
|
||||
#[ORM\Table(name: 'chill_event_event')]
|
||||
class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInterface, TrackUpdateInterface
|
||||
@@ -85,7 +85,7 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter
|
||||
#[ORM\JoinTable('chill_event_event_documents')]
|
||||
private Collection $documents;
|
||||
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DECIMAL, precision: 10, scale: 4, nullable: true, options: ['default' => null])]
|
||||
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::DECIMAL, precision: 10, scale: 4, nullable: true, options: ['default' => '0.0'])]
|
||||
private string $organizationCost = '0.0';
|
||||
|
||||
/**
|
||||
|
@@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
namespace Chill\EventBundle\Entity;
|
||||
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use Symfony\Component\Validator\Constraints as Assert;
|
||||
|
||||
/**
|
||||
* Class Status.
|
||||
@@ -36,6 +37,7 @@ class Status
|
||||
private $name;
|
||||
|
||||
#[ORM\ManyToOne(targetEntity: EventType::class, inversedBy: 'statuses')]
|
||||
#[Assert\NotNull(message: 'An event status must be linked to an event type.')]
|
||||
private ?EventType $type = null;
|
||||
|
||||
/**
|
||||
|
@@ -12,7 +12,7 @@ declare(strict_types=1);
|
||||
namespace Chill\EventBundle\Form\ChoiceLoader;
|
||||
|
||||
use Chill\EventBundle\Entity\Event;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Chill\EventBundle\Repository\EventRepository;
|
||||
use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
|
||||
use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
|
||||
|
||||
@@ -26,9 +26,6 @@ class EventChoiceLoader implements ChoiceLoaderInterface
|
||||
*/
|
||||
protected $centers = [];
|
||||
|
||||
/**
|
||||
* @var EntityRepository
|
||||
*/
|
||||
protected $eventRepository;
|
||||
|
||||
/**
|
||||
@@ -40,7 +37,7 @@ class EventChoiceLoader implements ChoiceLoaderInterface
|
||||
* EventChoiceLoader constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
EntityRepository $eventRepository,
|
||||
EventRepository $eventRepository,
|
||||
?array $centers = null,
|
||||
) {
|
||||
$this->eventRepository = $eventRepository;
|
||||
|
@@ -11,17 +11,65 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\EventBundle\Repository;
|
||||
|
||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
use Chill\DocStoreBundle\Repository\AssociatedEntityToStoredObjectInterface;
|
||||
use Chill\EventBundle\Entity\Event;
|
||||
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
||||
use Doctrine\Persistence\ManagerRegistry;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Doctrine\Persistence\ObjectRepository;
|
||||
|
||||
/**
|
||||
* Class EventRepository.
|
||||
*/
|
||||
class EventRepository extends ServiceEntityRepository
|
||||
class EventRepository implements ObjectRepository, AssociatedEntityToStoredObjectInterface
|
||||
{
|
||||
public function __construct(ManagerRegistry $registry)
|
||||
private readonly EntityRepository $repository;
|
||||
|
||||
public function __construct(EntityManagerInterface $entityManager)
|
||||
{
|
||||
parent::__construct($registry, Event::class);
|
||||
$this->repository = $entityManager->getRepository(Event::class);
|
||||
}
|
||||
|
||||
public function createQueryBuilder(string $alias, ?string $indexBy = null): QueryBuilder
|
||||
{
|
||||
return $this->repository->createQueryBuilder($alias, $indexBy);
|
||||
}
|
||||
|
||||
public function findAssociatedEntityToStoredObject(StoredObject $storedObject): ?object
|
||||
{
|
||||
$qb = $this->createQueryBuilder('e');
|
||||
$query = $qb
|
||||
->join('e.documents', 'ed')
|
||||
->where('ed.id = :storedObjectId')
|
||||
->setParameter('storedObjectId', $storedObject->getId())
|
||||
->getQuery();
|
||||
|
||||
return $query->getOneOrNullResult();
|
||||
}
|
||||
|
||||
public function find($id)
|
||||
{
|
||||
return $this->repository->find($id);
|
||||
}
|
||||
|
||||
public function findAll(): array
|
||||
{
|
||||
return $this->repository->findAll();
|
||||
}
|
||||
|
||||
public function findBy(array $criteria, ?array $orderBy = null, ?int $limit = null, ?int $offset = null): array
|
||||
{
|
||||
return $this->repository->findBy($criteria, $orderBy, $limit, $offset);
|
||||
}
|
||||
|
||||
public function findOneBy(array $criteria)
|
||||
{
|
||||
return $this->repository->findOneBy($criteria);
|
||||
}
|
||||
|
||||
public function getClassName(): string
|
||||
{
|
||||
return Event::class;
|
||||
}
|
||||
}
|
||||
|
@@ -1,10 +1,10 @@
|
||||
{% extends "@ChillEvent/Admin/index.html.twig" %}
|
||||
{% extends '@ChillMain/Admin/layoutWithVerticalMenu.html.twig' %}
|
||||
|
||||
{% block admin_content -%}
|
||||
|
||||
<h1>{{ 'EventType list'|trans }}</h1>
|
||||
|
||||
<table class="records_list">
|
||||
<table class="table table-bordered border-dark align-middle">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ 'Id'|trans }}</th>
|
||||
|
@@ -1,10 +1,10 @@
|
||||
{% extends "@ChillEvent/Admin/index.html.twig" %}
|
||||
{% extends '@ChillMain/Admin/layoutWithVerticalMenu.html.twig' %}
|
||||
|
||||
{% block admin_content -%}
|
||||
|
||||
<h1>{{ 'Role list'|trans }}</h1>
|
||||
|
||||
<table class="records_list">
|
||||
<table class="table table-bordered border-dark align-middle">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ 'Id'|trans }}</th>
|
||||
|
@@ -1,10 +1,10 @@
|
||||
{% extends "@ChillEvent/Admin/index.html.twig" %}
|
||||
{% extends '@ChillMain/Admin/layoutWithVerticalMenu.html.twig' %}
|
||||
|
||||
{% block admin_content -%}
|
||||
|
||||
<h1>{{ 'Status list'|trans }}</h1>
|
||||
|
||||
<table class="records_list">
|
||||
<table class="table table-bordered border-dark align-middle">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ 'Id'|trans }}</th>
|
||||
|
@@ -45,7 +45,7 @@ class EventSearch extends AbstractSearch
|
||||
private readonly PaginatorFactory $paginatorFactory,
|
||||
) {}
|
||||
|
||||
public function getOrder()
|
||||
public function getOrder(): int
|
||||
{
|
||||
return 3000;
|
||||
}
|
||||
|
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
namespace Chill\EventBundle\Security\Authorization;
|
||||
|
||||
use Chill\DocStoreBundle\Repository\AssociatedEntityToStoredObjectInterface;
|
||||
use Chill\DocStoreBundle\Security\Authorization\StoredObjectRoleEnum;
|
||||
use Chill\DocStoreBundle\Security\Authorization\StoredObjectVoter\AbstractStoredObjectVoter;
|
||||
use Chill\MainBundle\Workflow\Helper\WorkflowRelatedEntityPermissionHelper;
|
||||
use Chill\EventBundle\Entity\Event;
|
||||
use Chill\EventBundle\Repository\EventRepository;
|
||||
use Chill\EventBundle\Security\EventVoter;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
class EventStoredObjectVoter extends AbstractStoredObjectVoter
|
||||
{
|
||||
public function __construct(
|
||||
private readonly EventRepository $repository,
|
||||
Security $security,
|
||||
WorkflowRelatedEntityPermissionHelper $workflowDocumentService,
|
||||
) {
|
||||
parent::__construct($security, $workflowDocumentService);
|
||||
}
|
||||
|
||||
protected function getRepository(): AssociatedEntityToStoredObjectInterface
|
||||
{
|
||||
return $this->repository;
|
||||
}
|
||||
|
||||
protected function getClass(): string
|
||||
{
|
||||
return Event::class;
|
||||
}
|
||||
|
||||
protected function attributeToRole(StoredObjectRoleEnum $attribute): string
|
||||
{
|
||||
return match ($attribute) {
|
||||
StoredObjectRoleEnum::EDIT => EventVoter::UPDATE,
|
||||
StoredObjectRoleEnum::SEE => EventVoter::SEE_DETAILS,
|
||||
};
|
||||
}
|
||||
|
||||
protected function canBeAssociatedWithWorkflow(): bool
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
namespace Chill\Migrations\Event;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20241104135957 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'Define default values for entity properties';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_event_event ALTER organizationcost DROP DEFAULT');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_user_history ALTER startdate SET DEFAULT \'now()\'');
|
||||
$this->addSql('ALTER TABLE chill_event_event ALTER organizationcost SET DEFAULT \'0.0\'');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_event_event ALTER organizationCost SET DEFAULT \'0.0\'');
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user