mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-07-03 15:36:14 +00:00
WIP: remove deprecations
This commit is contained in:
parent
958e2b5cf2
commit
13bc9683fb
@ -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())
|
||||
|
@ -672,7 +672,7 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @deprecated use @link{self::setActivityType} instead
|
||||
*/
|
||||
public function setType(ActivityType $activityType): self
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -529,7 +529,7 @@ class PermissionsGroupController extends AbstractController
|
||||
static fn (Role $role) => $role->getRole(),
|
||||
$this->roleHierarchy
|
||||
->getReachableRoles(
|
||||
[new Role($roleScope->getRole())]
|
||||
[$roleScope->getRole()]
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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';
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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']);
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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> $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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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.*.
|
||||
|
@ -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.
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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)
|
||||
|
@ -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,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -213,7 +213,7 @@ class PersonType extends AbstractType
|
||||
]);
|
||||
}
|
||||
|
||||
if ($options['cFGroup']) {
|
||||
if (null !== $options['cFGroup']) {
|
||||
$builder
|
||||
->add(
|
||||
'cFData',
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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;
|
||||
|
||||
/**
|
||||
|
@ -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<PostalCode> $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)) {
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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(),
|
||||
]);
|
||||
}
|
||||
|
@ -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');
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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']);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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()
|
||||
);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user