diff --git a/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php
index 9f0c59784..4572520b3 100644
--- a/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php
+++ b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivity.php
@@ -67,7 +67,7 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface
->setPerson($person)
->setDate($this->faker->dateTimeThisYear())
->setDurationTime($this->faker->dateTime(36000))
- ->setType($this->getRandomActivityType())
+ ->setActivityType($this->getRandomActivityType())
->setScope($this->getRandomScope());
// ->setAttendee($this->faker->boolean())
diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php
index c697cdf9b..6f5cd30f1 100644
--- a/src/Bundle/ChillActivityBundle/Entity/Activity.php
+++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php
@@ -672,7 +672,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
}
/**
- * @deprecated
+ * @deprecated use @link{self::setActivityType} instead
*/
public function setType(ActivityType $activityType): self
{
diff --git a/src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php b/src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php
index c26c698c1..58b703eba 100644
--- a/src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php
+++ b/src/Bundle/ChillMainBundle/Command/LoadCountriesCommand.php
@@ -16,6 +16,7 @@ use Doctrine\ORM\EntityManager;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Intl\Countries;
use Symfony\Component\Intl\Intl;
class LoadCountriesCommand extends Command
@@ -32,11 +33,10 @@ class LoadCountriesCommand extends Command
public static function prepareCountryList($languages)
{
- $regionBundle = Intl::getRegionBundle();
$countries = [];
foreach ($languages as $language) {
- $countries[$language] = $regionBundle->getCountryNames($language);
+ $countries[$language] = Countries::getNames([$language]);
}
$countryEntities = [];
@@ -90,6 +90,7 @@ class LoadCountriesCommand extends Command
}
$em->flush();
+
return 0;
}
}
diff --git a/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php b/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php
index bdcaf861a..3eded3b8e 100644
--- a/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php
+++ b/src/Bundle/ChillMainBundle/Controller/PermissionsGroupController.php
@@ -529,7 +529,7 @@ class PermissionsGroupController extends AbstractController
static fn (Role $role) => $role->getRole(),
$this->roleHierarchy
->getReachableRoles(
- [new Role($roleScope->getRole())]
+ [$roleScope->getRole()]
)
);
}
diff --git a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadLanguages.php b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadLanguages.php
index 88a4869cc..34b7aaa25 100644
--- a/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadLanguages.php
+++ b/src/Bundle/ChillMainBundle/DataFixtures/ORM/LoadLanguages.php
@@ -19,6 +19,7 @@ use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Intl\Intl;
+use Symfony\Component\Intl\Languages;
use function in_array;
/**
@@ -46,9 +47,7 @@ class LoadLanguages extends AbstractFixture implements ContainerAwareInterface,
public function load(ObjectManager $manager)
{
- echo "loading languages... \n";
-
- foreach (Intl::getLanguageBundle()->getLanguageNames() as $code => $language) {
+ foreach (Languages::getLanguageCodes() as $code) {
if (
!in_array($code, $this->regionalVersionToInclude, true)
&& !in_array($code, $this->ancientToExclude, true)
@@ -78,7 +77,7 @@ class LoadLanguages extends AbstractFixture implements ContainerAwareInterface,
$names = [];
foreach ($this->container->getParameter('chill_main.available_languages') as $lang) {
- $names[$lang] = Intl::getLanguageBundle()->getLanguageName($languageCode);
+ $names[$lang] = Languages::getName($languageCode);
}
return $names;
diff --git a/src/Bundle/ChillMainBundle/Form/Event/CustomizeFormEvent.php b/src/Bundle/ChillMainBundle/Form/Event/CustomizeFormEvent.php
index a816e7371..4dc3fa5aa 100644
--- a/src/Bundle/ChillMainBundle/Form/Event/CustomizeFormEvent.php
+++ b/src/Bundle/ChillMainBundle/Form/Event/CustomizeFormEvent.php
@@ -12,8 +12,9 @@ declare(strict_types=1);
namespace Chill\MainBundle\Form\Event;
use Symfony\Component\Form\FormBuilderInterface;
+use Symfony\Contracts\EventDispatcher\Event;
-class CustomizeFormEvent extends \Symfony\Component\EventDispatcher\Event
+class CustomizeFormEvent extends Event
{
final public const NAME = 'chill_main.customize_form';
diff --git a/src/Bundle/ChillMainBundle/Form/Type/AppendScopeChoiceTypeTrait.php b/src/Bundle/ChillMainBundle/Form/Type/AppendScopeChoiceTypeTrait.php
index 8eda0d9d9..9bcf1cbf7 100644
--- a/src/Bundle/ChillMainBundle/Form/Type/AppendScopeChoiceTypeTrait.php
+++ b/src/Bundle/ChillMainBundle/Form/Type/AppendScopeChoiceTypeTrait.php
@@ -69,6 +69,8 @@ use Symfony\Component\Security\Core\Role\Role;
*
* }
* ```
+ *
+ * @deprecated use @link{\Chill\MainBundle\Form\Type\ScopePickerType:class} instead
*/
trait AppendScopeChoiceTypeTrait
{
@@ -97,7 +99,7 @@ trait AppendScopeChoiceTypeTrait
*/
protected function appendScopeChoices(
FormBuilderInterface $builder,
- Role $role,
+ string $role,
Center $center,
User $user,
AuthorizationHelper $authorizationHelper,
diff --git a/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php b/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php
index 8229d4074..41205df31 100644
--- a/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php
+++ b/src/Bundle/ChillMainBundle/Form/Type/ScopePickerType.php
@@ -52,7 +52,7 @@ class ScopePickerType extends AbstractType
array_filter(
$this->authorizationHelper->getReachableScopes(
$this->security->getUser(),
- $options['role'] instanceof Role ? $options['role']->getRole() : $options['role'],
+ $options['role'],
$options['center']
),
static fn (Scope $s) => $s->isActive()
@@ -92,6 +92,6 @@ class ScopePickerType extends AbstractType
->setAllowedTypes('center', [Center::class, 'array', 'null'])
// create ``role` option
->setRequired('role')
- ->setAllowedTypes('role', ['string', Role::class]);
+ ->setAllowedTypes('role', ['string']);
}
}
diff --git a/src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php b/src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php
index 791063f0a..d379c66fb 100644
--- a/src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php
+++ b/src/Bundle/ChillMainBundle/Form/Type/UserPickerType.php
@@ -63,7 +63,7 @@ class UserPickerType extends AbstractType
->setAllowedTypes('center', [\Chill\MainBundle\Entity\Center::class, 'null', 'array'])
// create ``role` option
->setRequired('role')
- ->setAllowedTypes('role', ['string', \Symfony\Component\Security\Core\Role\Role::class]);
+ ->setAllowedTypes('role', ['string']);
$resolver
->setDefault('having_permissions_group_flag', null)
diff --git a/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php b/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php
index 045610f54..9a40bf6e1 100644
--- a/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php
+++ b/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php
@@ -133,11 +133,11 @@ final class NotificationRepository implements ObjectRepository
{
$query = $this->queryByAddressee($addressee)->select('n');
- if ($limit) {
+ if (null !== $limit) {
$query = $query->setMaxResults($limit);
}
- if ($offset) {
+ if (null !== $offset) {
$query = $query->setFirstResult($offset);
}
diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php
index 50cbf3f8d..b4cef661b 100644
--- a/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php
+++ b/src/Bundle/ChillMainBundle/Security/Authorization/AuthorizationHelper.php
@@ -34,8 +34,13 @@ use function get_class;
*/
class AuthorizationHelper implements AuthorizationHelperInterface
{
- public function __construct(private readonly CenterResolverManagerInterface $centerResolverManager, private readonly LoggerInterface $logger, private readonly ScopeResolverDispatcher $scopeResolverDispatcher, private readonly UserACLAwareRepositoryInterface $userACLAwareRepository, private readonly ParentRoleHelper $parentRoleHelper)
- {
+ public function __construct(
+ private readonly CenterResolverManagerInterface $centerResolverManager,
+ private readonly LoggerInterface $logger,
+ private readonly ScopeResolverDispatcher $scopeResolverDispatcher,
+ private readonly UserACLAwareRepositoryInterface $userACLAwareRepository,
+ private readonly ParentRoleHelper $parentRoleHelper
+ ) {
}
/**
@@ -94,10 +99,6 @@ class AuthorizationHelper implements AuthorizationHelperInterface
*/
public function getReachableCenters(UserInterface $user, string $role, ?Scope $scope = null): array
{
- if ($role instanceof Role) {
- $role = $role->getRole();
- }
-
if (!$user instanceof User) {
return [];
}
@@ -132,10 +133,10 @@ class AuthorizationHelper implements AuthorizationHelperInterface
/**
* Return all reachable circle for a given user, center and role.
*
- * @param Center|Center[] $center
+ * @param Center|array
$center
* @return Scope[]
*/
- public function getReachableCircles(UserInterface $user, \Symfony\Component\Security\Core\Role\Role|string $role, \Chill\MainBundle\Entity\Center|array $center)
+ public function getReachableCircles(UserInterface $user, string $role, \Chill\MainBundle\Entity\Center|array $center): array
{
$scopes = [];
@@ -223,11 +224,8 @@ class AuthorizationHelper implements AuthorizationHelperInterface
* the scope is taken into account.
*
* @param mixed $entity the entity may also implement HasScopeInterface
- * @param Role|string $attribute
- *
- * @return bool true if the user has access
*/
- public function userHasAccess(User $user, mixed $entity, \Symfony\Component\Security\Core\Role\Role|string $attribute)
+ public function userHasAccess(User $user, mixed $entity, string $attribute): bool
{
$centers = $this->centerResolverManager->resolveCenters($entity);
@@ -248,7 +246,7 @@ class AuthorizationHelper implements AuthorizationHelperInterface
*
* @return bool true if the child role is granted by parent role
*/
- private function isRoleReached(string $childRole, string $parentRole)
+ private function isRoleReached(string $childRole, string $parentRole): bool
{
return $this->parentRoleHelper->isRoleReached($childRole, $parentRole);
}
diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelper.php b/src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelper.php
index a9c9f7445..9196ff46c 100644
--- a/src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelper.php
+++ b/src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelper.php
@@ -14,12 +14,16 @@ namespace Chill\MainBundle\Security\Authorization;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface;
+use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
use function in_array;
final readonly class DefaultVoterHelper implements VoterHelperInterface
{
- public function __construct(private AuthorizationHelper $authorizationHelper, private CenterResolverDispatcherInterface $centerResolverDispatcher, private array $configuration)
- {
+ public function __construct(
+ private AuthorizationHelper $authorizationHelper,
+ private CenterResolverManagerInterface $centerResolverDispatcher,
+ private array $configuration
+ ) {
}
public function supports($attribute, $subject): bool
diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelperFactory.php b/src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelperFactory.php
index d00fc6495..7966e5355 100644
--- a/src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelperFactory.php
+++ b/src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelperFactory.php
@@ -12,11 +12,14 @@ declare(strict_types=1);
namespace Chill\MainBundle\Security\Authorization;
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface;
+use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
class DefaultVoterHelperFactory implements VoterHelperFactoryInterface
{
- public function __construct(protected AuthorizationHelper $authorizationHelper, protected CenterResolverDispatcherInterface $centerResolverDispatcher)
- {
+ public function __construct(
+ protected AuthorizationHelper $authorizationHelper,
+ protected CenterResolverManagerInterface $centerResolverDispatcher
+ ) {
}
public function generate($context): VoterGeneratorInterface
diff --git a/src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelperGenerator.php b/src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelperGenerator.php
index cea60b931..ab0963e68 100644
--- a/src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelperGenerator.php
+++ b/src/Bundle/ChillMainBundle/Security/Authorization/DefaultVoterHelperGenerator.php
@@ -12,13 +12,16 @@ declare(strict_types=1);
namespace Chill\MainBundle\Security\Authorization;
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface;
+use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
final class DefaultVoterHelperGenerator implements VoterGeneratorInterface
{
private array $configuration = [];
- public function __construct(private readonly AuthorizationHelper $authorizationHelper, private readonly CenterResolverDispatcherInterface $centerResolverDispatcher)
- {
+ public function __construct(
+ private readonly AuthorizationHelper $authorizationHelper,
+ private readonly CenterResolverManagerInterface $centerResolverDispatcher
+ ) {
}
public function addCheckFor(?string $subject, array $attributes): self
diff --git a/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverEvent.php b/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverEvent.php
index 96ba1c74f..046cfbad9 100644
--- a/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverEvent.php
+++ b/src/Bundle/ChillMainBundle/Security/PasswordRecover/PasswordRecoverEvent.php
@@ -12,7 +12,7 @@ declare(strict_types=1);
namespace Chill\MainBundle\Security\PasswordRecover;
use Chill\MainBundle\Entity\User;
-use Symfony\Component\EventDispatcher\Event;
+use Symfony\Contracts\EventDispatcher\Event;
class PasswordRecoverEvent extends Event
{
diff --git a/src/Bundle/ChillMainBundle/Templating/ChillTwigRoutingHelper.php b/src/Bundle/ChillMainBundle/Templating/ChillTwigRoutingHelper.php
index 1e55a8d74..d61d60124 100644
--- a/src/Bundle/ChillMainBundle/Templating/ChillTwigRoutingHelper.php
+++ b/src/Bundle/ChillMainBundle/Templating/ChillTwigRoutingHelper.php
@@ -59,7 +59,7 @@ class ChillTwigRoutingHelper extends AbstractExtension
];
}
- public function getLabelReturnPath($default)
+ public function getLabelReturnPath(?string $default = null): string|null
{
$request = $this->requestStack->getCurrentRequest();
@@ -68,21 +68,14 @@ class ChillTwigRoutingHelper extends AbstractExtension
/**
* Build an url with a returnPath parameter to current page.
- *
- * @param string $name
- * @param array $parameters
- * @param bool $relative
- * @param mixed|null $label
- *
- * @return string
*/
- public function getPathAddReturnPath($name, $parameters = [], $relative = false, $label = null)
+ public function getPathAddReturnPath(string $name, array $parameters = [], bool $relative = false, ?string $label = null): string
{
$request = $this->requestStack->getCurrentRequest();
$parameters['returnPath'] = $request->getRequestUri();
- if ($label) {
+ if (null !== $label) {
$parameters['returnPathLabel'] = $label;
}
@@ -91,14 +84,8 @@ class ChillTwigRoutingHelper extends AbstractExtension
/**
* Build an url with a returnPath parameter to current page.
- *
- * @param string $name
- * @param array $parameters
- * @param bool $relative
- *
- * @return string
*/
- public function getPathForwardReturnPath($name, $parameters = [], $relative = false)
+ public function getPathForwardReturnPath(string $name, array $parameters = [], bool $relative = false): string
{
$request = $this->requestStack->getCurrentRequest();
@@ -116,14 +103,8 @@ class ChillTwigRoutingHelper extends AbstractExtension
/**
* Return the return path if it exists, or generate the path if not.
- *
- * @param string $name
- * @param array $parameters
- * @param bool $relative
- *
- * @return string
*/
- public function getReturnPathOr($name, $parameters = [], $relative = false)
+ public function getReturnPathOr(string $name, array $parameters = [], bool $relative = false): string
{
$request = $this->requestStack->getCurrentRequest();
@@ -134,7 +115,7 @@ class ChillTwigRoutingHelper extends AbstractExtension
return $this->originalExtension->getPath($name, $parameters, $relative);
}
- public function isUrlGenerationSafe(Node $argsNode)
+ public function isUrlGenerationSafe(Node $argsNode): array|string
{
return $this->originalExtension->isUrlGenerationSafe($argsNode);
}
diff --git a/src/Bundle/ChillMainBundle/Templating/Events/DelegatedBlockRenderingEvent.php b/src/Bundle/ChillMainBundle/Templating/Events/DelegatedBlockRenderingEvent.php
index c7a31b042..5a88f2115 100644
--- a/src/Bundle/ChillMainBundle/Templating/Events/DelegatedBlockRenderingEvent.php
+++ b/src/Bundle/ChillMainBundle/Templating/Events/DelegatedBlockRenderingEvent.php
@@ -13,7 +13,7 @@ namespace Chill\MainBundle\Templating\Events;
use ArrayAccess;
use RuntimeException;
-use Symfony\Component\EventDispatcher\Event;
+use Symfony\Contracts\EventDispatcher\Event;
/**
* This event is transmitted on event chill_block.*.
diff --git a/src/Bundle/ChillPersonBundle/Actions/ActionEvent.php b/src/Bundle/ChillPersonBundle/Actions/ActionEvent.php
index c0935b995..feba9219c 100644
--- a/src/Bundle/ChillPersonBundle/Actions/ActionEvent.php
+++ b/src/Bundle/ChillPersonBundle/Actions/ActionEvent.php
@@ -11,7 +11,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\Actions;
-use Symfony\Component\EventDispatcher\Event;
+use Symfony\Contracts\EventDispatcher\Event;
/**
* Event triggered when an entity attached to a person is removed.
diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php
index 344b52642..d9036f9fd 100644
--- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php
+++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php
@@ -19,7 +19,7 @@ use Chill\PersonBundle\Form\AccompanyingCourseType;
use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
-use Symfony\Bundle\FrameworkBundle\Controller\Controller;
+use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -39,7 +39,7 @@ use function is_array;
/**
* Class AccompanyingCourseController.
*/
-class AccompanyingCourseController extends Controller
+class AccompanyingCourseController extends AbstractController
{
public function __construct(protected SerializerInterface $serializer, protected EventDispatcherInterface $dispatcher, protected ValidatorInterface $validator, private readonly AccompanyingPeriodWorkRepository $workRepository, private readonly Registry $registry, private readonly TranslatorInterface $translator)
{
diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php b/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php
index aa7171639..d3a8889fc 100644
--- a/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php
+++ b/src/Bundle/ChillPersonBundle/Controller/PersonDuplicateController.php
@@ -25,6 +25,7 @@ use Chill\PersonBundle\Repository\PersonRepository;
use Chill\PersonBundle\Search\SimilarPersonMatcher;
use Chill\TaskBundle\Entity\SingleTask;
use http\Exception\InvalidArgumentException;
+use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\HttpFoundation\Request;
@@ -32,10 +33,15 @@ use Symfony\Contracts\Translation\TranslatorInterface;
use function count;
-class PersonDuplicateController extends Controller
+class PersonDuplicateController extends AbstractController
{
- public function __construct(private readonly SimilarPersonMatcher $similarPersonMatcher, private readonly TranslatorInterface $translator, private readonly PersonRepository $personRepository, private readonly PersonMove $personMove, private readonly EventDispatcherInterface $eventDispatcher)
- {
+ public function __construct(
+ private readonly SimilarPersonMatcher $similarPersonMatcher,
+ private readonly TranslatorInterface $translator,
+ private readonly PersonRepository $personRepository,
+ private readonly PersonMove $personMove,
+ private readonly EventDispatcherInterface $eventDispatcher
+ ) {
}
public function confirmAction($person1_id, $person2_id, Request $request)
diff --git a/src/Bundle/ChillPersonBundle/Form/AccompanyingPeriodType.php b/src/Bundle/ChillPersonBundle/Form/AccompanyingPeriodType.php
index 25d380562..fc0d12d34 100644
--- a/src/Bundle/ChillPersonBundle/Form/AccompanyingPeriodType.php
+++ b/src/Bundle/ChillPersonBundle/Form/AccompanyingPeriodType.php
@@ -26,6 +26,8 @@ use Symfony\Component\Security\Core\Role\Role;
/**
* Class AccompanyingPeriodType.
+ *
+ * @deprecated to be removed
*/
class AccompanyingPeriodType extends AbstractType
{
@@ -81,7 +83,7 @@ class AccompanyingPeriodType extends AbstractType
if ('visible' === $this->config['user']) {
$builder->add('user', UserPickerType::class, [
'center' => $options['center'],
- 'role' => new Role(PersonVoter::SEE),
+ 'role' => PersonVoter::SEE,
]);
}
diff --git a/src/Bundle/ChillPersonBundle/Form/PersonType.php b/src/Bundle/ChillPersonBundle/Form/PersonType.php
index 6ba4cafaf..c8b4fa2a3 100644
--- a/src/Bundle/ChillPersonBundle/Form/PersonType.php
+++ b/src/Bundle/ChillPersonBundle/Form/PersonType.php
@@ -213,7 +213,7 @@ class PersonType extends AbstractType
]);
}
- if ($options['cFGroup']) {
+ if (null !== $options['cFGroup']) {
$builder
->add(
'cFData',
diff --git a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php
index 026a24bb6..eb2d9effb 100644
--- a/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php
+++ b/src/Bundle/ChillPersonBundle/Form/Type/PickPersonType.php
@@ -44,6 +44,8 @@ use function is_array;
* `Chill\MainBundle\Entity\Center`. By default, all the reachable centers as selected.
* - with the `role` option, only the people belonging to the reachable center for the
* given role are displayed.
+ *
+ * @deprecated use @link{\Chill\PersonBundle\Form\Type\PickPersonDynamicType::class} instead
*/
class PickPersonType extends AbstractType
{
@@ -107,7 +109,7 @@ class PickPersonType extends AbstractType
->addAllowedTypes('centers', ['array', Center::class, 'null'])
->setDefault('centers', null)
->setDefined('role')
- ->addAllowedTypes('role', [Role::class, 'null'])
+ ->addAllowedTypes('role', ['string', 'null'])
->setDefault('role', null);
// add the default options
diff --git a/src/Bundle/ChillPersonBundle/Privacy/AccompanyingPeriodPrivacyEvent.php b/src/Bundle/ChillPersonBundle/Privacy/AccompanyingPeriodPrivacyEvent.php
index 1475c35ec..c32b61516 100644
--- a/src/Bundle/ChillPersonBundle/Privacy/AccompanyingPeriodPrivacyEvent.php
+++ b/src/Bundle/ChillPersonBundle/Privacy/AccompanyingPeriodPrivacyEvent.php
@@ -32,7 +32,7 @@ namespace Chill\PersonBundle\Privacy;
*/
use Chill\PersonBundle\Entity\AccompanyingPeriod;
-use Symfony\Component\EventDispatcher\Event;
+use Symfony\Contracts\EventDispatcher\Event;
class AccompanyingPeriodPrivacyEvent extends Event
{
diff --git a/src/Bundle/ChillPersonBundle/Privacy/PrivacyEvent.php b/src/Bundle/ChillPersonBundle/Privacy/PrivacyEvent.php
index c021a0b8f..864d3c055 100644
--- a/src/Bundle/ChillPersonBundle/Privacy/PrivacyEvent.php
+++ b/src/Bundle/ChillPersonBundle/Privacy/PrivacyEvent.php
@@ -32,8 +32,8 @@ namespace Chill\PersonBundle\Privacy;
*/
use Chill\PersonBundle\Entity\Person;
-use Symfony\Component\EventDispatcher\Event;
+use Symfony\Contracts\EventDispatcher\Event;
use function count;
/**
diff --git a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php
index 0c65a4e5a..9f2c1bac1 100644
--- a/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php
+++ b/src/Bundle/ChillPersonBundle/Repository/AccompanyingPeriodACLAwareRepository.php
@@ -18,7 +18,7 @@ use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Entity\UserJob;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
-use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface;
+use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
use Chill\PersonBundle\Entity\Household\PersonHouseholdAddress;
@@ -35,16 +35,18 @@ use function count;
final readonly class AccompanyingPeriodACLAwareRepository implements AccompanyingPeriodACLAwareRepositoryInterface
{
- public function __construct(private AccompanyingPeriodRepository $accompanyingPeriodRepository, private Security $security, private AuthorizationHelper $authorizationHelper, private CenterResolverDispatcherInterface $centerResolverDispatcher)
- {
+ public function __construct(
+ private AccompanyingPeriodRepository $accompanyingPeriodRepository,
+ private Security $security,
+ private AuthorizationHelper $authorizationHelper,
+ private CenterResolverManagerInterface $centerResolverDispatcher
+ ) {
}
/**
- * @param array|PostalCode[]
- *
- * @return QueryBuilder
+ * @param array $postalCodes
*/
- public function buildQueryOpenedAccompanyingCourseByUser(?User $user, array $postalCodes = [])
+ public function buildQueryOpenedAccompanyingCourseByUser(?User $user, array $postalCodes = []): QueryBuilder
{
$qb = $this->accompanyingPeriodRepository->createQueryBuilder('ap');
@@ -139,7 +141,7 @@ final readonly class AccompanyingPeriodACLAwareRepository implements Accompanyin
->getReachableCircles(
$this->security->getUser(),
$role,
- $this->centerResolverDispatcher->resolveCenter($person)
+ $this->centerResolverDispatcher->resolveCenters($person)
);
if (0 === count($scopes)) {
diff --git a/src/Bundle/ChillPersonBundle/Widget/PersonListWidget.php b/src/Bundle/ChillPersonBundle/Widget/PersonListWidget.php
index 0db3eb429..41b9d27be 100644
--- a/src/Bundle/ChillPersonBundle/Widget/PersonListWidget.php
+++ b/src/Bundle/ChillPersonBundle/Widget/PersonListWidget.php
@@ -58,7 +58,7 @@ class PersonListWidget implements WidgetInterface
// show only the person from the authorized centers
$and = $qb->expr()->andX();
$centers = $this->authorizationHelper
- ->getReachableCenters($this->getUser(), new Role(PersonVoter::SEE));
+ ->getReachableCenters($this->getUser(), PersonVoter::SEE);
$and->add($qb->expr()->in('person.center', ':centers'));
$qb->setParameter('centers', $centers);
diff --git a/src/Bundle/ChillReportBundle/Controller/ReportController.php b/src/Bundle/ChillReportBundle/Controller/ReportController.php
index 864ad8c62..ac00dc368 100644
--- a/src/Bundle/ChillReportBundle/Controller/ReportController.php
+++ b/src/Bundle/ChillReportBundle/Controller/ReportController.php
@@ -219,7 +219,7 @@ class ReportController extends AbstractController
$reachableScopes = $this->authorizationHelper
->getReachableScopes(
$this->getUser(),
- new Role('CHILL_REPORT_SEE'),
+ 'CHILL_REPORT_SEE',
$person->getCenter()
);
@@ -555,7 +555,7 @@ class ReportController extends AbstractController
),
'method' => 'POST',
'cFGroup' => $cFGroup,
- 'role' => new Role('CHILL_REPORT_CREATE'),
+ 'role' => 'CHILL_REPORT_CREATE',
'center' => $person->getCenter(),
]);
}
@@ -577,7 +577,7 @@ class ReportController extends AbstractController
),
'method' => 'PUT',
'cFGroup' => $entity->getCFGroup(),
- 'role' => new Role('CHILL_REPORT_UPDATE'),
+ 'role' => 'CHILL_REPORT_UPDATE',
'center' => $entity->getPerson()->getCenter(),
]);
}
diff --git a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php
index d8afbc65d..a26b87cce 100644
--- a/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php
+++ b/src/Bundle/ChillTaskBundle/Controller/SingleTaskController.php
@@ -12,7 +12,7 @@ declare(strict_types=1);
namespace Chill\TaskBundle\Controller;
use Chill\MainBundle\Pagination\PaginatorFactory;
-use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface;
+use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
use Chill\MainBundle\Serializer\Model\Collection;
use Chill\MainBundle\Serializer\Model\Counter;
use Chill\MainBundle\Templating\Listing\FilterOrderHelper;
@@ -39,7 +39,6 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Symfony\Component\Routing\Annotation\Route;
-use Symfony\Component\Security\Core\Role\Role;
use Symfony\Contracts\Translation\TranslatorInterface;
use function array_map;
@@ -47,8 +46,15 @@ use function array_merge;
final class SingleTaskController extends AbstractController
{
- public function __construct(private readonly CenterResolverDispatcherInterface $centerResolverDispatcher, private readonly PaginatorFactory $paginatorFactory, private readonly SingleTaskAclAwareRepositoryInterface $singleTaskAclAwareRepository, private readonly TranslatorInterface $translator, private readonly EventDispatcherInterface $eventDispatcher, private readonly TimelineBuilder $timelineBuilder, private readonly LoggerInterface $logger, private readonly FilterOrderHelperFactoryInterface $filterOrderHelperFactory)
- {
+ public function __construct(
+ private readonly PaginatorFactory $paginatorFactory,
+ private readonly SingleTaskAclAwareRepositoryInterface $singleTaskAclAwareRepository,
+ private readonly TranslatorInterface $translator,
+ private readonly EventDispatcherInterface $eventDispatcher,
+ private readonly TimelineBuilder $timelineBuilder,
+ private readonly LoggerInterface $logger,
+ private readonly FilterOrderHelperFactoryInterface $filterOrderHelperFactory
+ ) {
}
/**
@@ -259,9 +265,8 @@ final class SingleTaskController extends AbstractController
* name="chill_task_singletask_list"
* )
*/
- public function listAction(
- Request $request
- ) {
+ public function listAction()
+ {
$this->denyAccessUnlessGranted(TaskVoter::SHOW, null);
$filterOrder = $this->buildFilterOrder();
@@ -303,9 +308,7 @@ final class SingleTaskController extends AbstractController
* name="chill_task_singletask_by-course_list")
*/
public function listCourseTasks(
- AccompanyingPeriod $course,
- FormFactoryInterface $formFactory,
- Request $request
+ AccompanyingPeriod $course
): Response {
$this->denyAccessUnlessGranted(TaskVoter::SHOW, $course);
@@ -398,7 +401,6 @@ final class SingleTaskController extends AbstractController
}
/**
- * @return Response
* @Route(
* "/{_locale}/task/single-task/list/my",
* name="chill_task_singletask_my_tasks",
@@ -409,7 +411,7 @@ final class SingleTaskController extends AbstractController
* defaults={"_format": "json"}
* )
*/
- public function myTasksAction(string $_format, Request $request)
+ public function myTasksAction(string $_format, Request $request): Response
{
$this->denyAccessUnlessGranted('ROLE_USER');
diff --git a/src/Bundle/ChillTaskBundle/Event/TaskEvent.php b/src/Bundle/ChillTaskBundle/Event/TaskEvent.php
index 01cae799c..dbecd6c6a 100644
--- a/src/Bundle/ChillTaskBundle/Event/TaskEvent.php
+++ b/src/Bundle/ChillTaskBundle/Event/TaskEvent.php
@@ -12,7 +12,7 @@ declare(strict_types=1);
namespace Chill\TaskBundle\Event;
use Chill\TaskBundle\Entity\AbstractTask;
-use Symfony\Component\EventDispatcher\Event;
+use Symfony\Contracts\EventDispatcher\Event;
class TaskEvent extends Event
{
diff --git a/src/Bundle/ChillTaskBundle/Event/UI/UIEvent.php b/src/Bundle/ChillTaskBundle/Event/UI/UIEvent.php
index e0414948b..2cc2af17d 100644
--- a/src/Bundle/ChillTaskBundle/Event/UI/UIEvent.php
+++ b/src/Bundle/ChillTaskBundle/Event/UI/UIEvent.php
@@ -12,10 +12,10 @@ declare(strict_types=1);
namespace Chill\TaskBundle\Event\UI;
use Chill\TaskBundle\Entity\AbstractTask;
-use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Workflow\Transition;
+use Symfony\Contracts\EventDispatcher\Event;
class UIEvent extends Event
{
diff --git a/src/Bundle/ChillTaskBundle/Form/SingleTaskType.php b/src/Bundle/ChillTaskBundle/Form/SingleTaskType.php
index 65417f21e..815942936 100644
--- a/src/Bundle/ChillTaskBundle/Form/SingleTaskType.php
+++ b/src/Bundle/ChillTaskBundle/Form/SingleTaskType.php
@@ -17,6 +17,7 @@ use Chill\MainBundle\Form\Type\DateIntervalType;
use Chill\MainBundle\Form\Type\ScopePickerType;
use Chill\MainBundle\Form\Type\UserPickerType;
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcherInterface;
+use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface;
use Chill\MainBundle\Security\Resolver\ScopeResolverDispatcher;
use Chill\TaskBundle\Security\Authorization\TaskVoter;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
@@ -28,17 +29,17 @@ use Symfony\Component\Security\Core\Role\Role;
class SingleTaskType extends AbstractType
{
- public function __construct(private readonly ParameterBagInterface $parameterBag, private readonly CenterResolverDispatcherInterface $centerResolverDispatcher, private readonly ScopeResolverDispatcher $scopeResolverDispatcher)
+ public function __construct(private readonly ParameterBagInterface $parameterBag, private readonly CenterResolverManagerInterface $centerResolverDispatcher, private readonly ScopeResolverDispatcher $scopeResolverDispatcher)
{
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
- $center = null;
+ $centers = null;
$isScopeConcerned = false;
if (null !== $task = $options['data']) {
- $center = $this->centerResolverDispatcher->resolveCenter($task);
+ $centers = $this->centerResolverDispatcher->resolveCenters($task);
$isScopeConcerned = $this->scopeResolverDispatcher->isConcerned($task);
}
@@ -49,7 +50,7 @@ class SingleTaskType extends AbstractType
])
->add('assignee', UserPickerType::class, [
'required' => false,
- 'center' => $center,
+ 'center' => $centers,
'role' => TaskVoter::SHOW,
'placeholder' => 'Not assigned',
'attr' => ['class' => ' select2 '],
@@ -67,7 +68,7 @@ class SingleTaskType extends AbstractType
if ($isScopeConcerned && $this->parameterBag->get('chill_main')['acl']['form_show_scopes']) {
$builder
->add('circle', ScopePickerType::class, [
- 'center' => $center,
+ 'center' => $centers,
'role' => $options['role'],
'required' => true,
]);
@@ -78,6 +79,6 @@ class SingleTaskType extends AbstractType
{
$resolver
->setRequired('role')
- ->setAllowedTypes('role', [Role::class, 'string']);
+ ->setAllowedTypes('role', ['string']);
}
}
diff --git a/src/Bundle/ChillTaskBundle/Repository/SingleTaskRepository.php b/src/Bundle/ChillTaskBundle/Repository/SingleTaskRepository.php
index 0a95e3b25..636203a9e 100644
--- a/src/Bundle/ChillTaskBundle/Repository/SingleTaskRepository.php
+++ b/src/Bundle/ChillTaskBundle/Repository/SingleTaskRepository.php
@@ -159,7 +159,7 @@ class SingleTaskRepository extends EntityRepository
. '`setAuthorizationHelper`');
}
- $role = new Role(TaskVoter::SHOW);
+ $role = TaskVoter::SHOW;
$qb->join('st.person', 'p');
$centers = $this->authorizationHelper
diff --git a/src/Bundle/ChillTaskBundle/Security/Authorization/AuthorizationEvent.php b/src/Bundle/ChillTaskBundle/Security/Authorization/AuthorizationEvent.php
index 60c7f3d5a..5c72c8e9a 100644
--- a/src/Bundle/ChillTaskBundle/Security/Authorization/AuthorizationEvent.php
+++ b/src/Bundle/ChillTaskBundle/Security/Authorization/AuthorizationEvent.php
@@ -14,8 +14,8 @@ namespace Chill\TaskBundle\Security\Authorization;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\Person;
use Chill\TaskBundle\Entity\AbstractTask;
-use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
+use Symfony\Contracts\EventDispatcher\Event;
class AuthorizationEvent extends Event
{
diff --git a/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php b/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php
index 1fa818f41..c7ea9d734 100644
--- a/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php
+++ b/src/Bundle/ChillTaskBundle/Timeline/TaskLifeCycleEventTimelineProvider.php
@@ -168,7 +168,7 @@ class TaskLifeCycleEventTimelineProvider implements TimelineProviderInterface
foreach (
$this->authorizationHelper->getReachableCenters(
$this->security->getUser(),
- new Role(ActivityVoter::SEE_DETAILS)
+ ActivityVoter::SEE_DETAILS
) as $center
) {
if (false === in_array($center, $centers, true)) {
@@ -181,7 +181,7 @@ class TaskLifeCycleEventTimelineProvider implements TimelineProviderInterface
// we loop over circles
$circles = $this->authorizationHelper->getReachableCircles(
$this->security->getUser(),
- new Role(ActivityVoter::SEE_DETAILS),
+ ActivityVoter::SEE_DETAILS,
$center
);
$circleIds = [];
@@ -234,7 +234,7 @@ class TaskLifeCycleEventTimelineProvider implements TimelineProviderInterface
// we loop over circles
$circles = $this->authorizationHelper->getReachableCircles(
$this->security->getUser(),
- new Role(ActivityVoter::SEE_DETAILS),
+ ActivityVoter::SEE_DETAILS,
$personArg->getCenter()
);