Fixing api-platform deprecations

pull/5329/head
Angel Fernando Quiroz Campos 8 months ago
parent 2d3419b20e
commit 1472523703
  1. 2
      src/CoreBundle/DataProvider/UserItemDataProvider.php
  2. 2
      src/CoreBundle/DataTransformer/CourseToolDataTranformer.php
  3. 14
      src/CoreBundle/Entity/GradebookCategory.php
  4. 6
      src/CoreBundle/Entity/Language.php
  5. 6
      src/CoreBundle/Entity/Legal.php
  6. 1
      src/CoreBundle/Entity/ResourceComment.php
  7. 5
      src/CoreBundle/Entity/Skill.php
  8. 2
      src/CoreBundle/Entity/SkillRelUser.php
  9. 18
      src/CoreBundle/EventSubscriber/AnonymousUserSubscriber.php

@ -19,7 +19,7 @@ class UserItemDataProvider implements ItemDataProviderInterface, RestrictedDataP
private readonly NameConvention $nameConvention private readonly NameConvention $nameConvention
) {} ) {}
public function getItem(string $resourceClass, $id, ?string $operationName = null, array $context = []) public function getItem(string $resourceClass, $id, ?string $operationName = null, array $context = []): ?object
{ {
$user = $this->repository->find($id); $user = $this->repository->find($id);

@ -26,7 +26,7 @@ class CourseToolDataTranformer implements DataTransformerInterface
protected readonly ToolChain $toolChain, protected readonly ToolChain $toolChain,
) {} ) {}
public function transform($object, string $to, array $context = []) public function transform($object, string $to, array $context = []): object
{ {
\assert($object instanceof CTool); \assert($object instanceof CTool);

@ -6,10 +6,10 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\Entity; namespace Chamilo\CoreBundle\Entity;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Annotation\ApiSubresource; use ApiPlatform\Core\Annotation\ApiSubresource;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter; use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiResource;
use Chamilo\CoreBundle\Traits\CourseTrait; use Chamilo\CoreBundle\Traits\CourseTrait;
use Chamilo\CoreBundle\Traits\UserTrait; use Chamilo\CoreBundle\Traits\UserTrait;
use Chamilo\CourseBundle\Entity\CDocument; use Chamilo\CourseBundle\Entity\CDocument;
@ -22,15 +22,13 @@ use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Table(name: 'gradebook_category')] #[ORM\Table(name: 'gradebook_category')]
#[ORM\Entity] #[ORM\Entity]
#[ApiResource( #[ApiResource(
attributes: [ normalizationContext: [
'security' => "is_granted('ROLE_USER')", 'groups' => ['gradebookCategory:read'],
], ],
denormalizationContext: [ denormalizationContext: [
'groups' => ['gradebookCategory:write'], 'groups' => ['gradebookCategory:write'],
], ],
normalizationContext: [ security: "is_granted('ROLE_USER')",
'groups' => ['gradebookCategory:read'],
],
)] )]
#[ApiFilter(SearchFilter::class, properties: [ #[ApiFilter(SearchFilter::class, properties: [
'course' => 'exact', 'course' => 'exact',

@ -6,10 +6,10 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\Entity; namespace Chamilo\CoreBundle\Entity;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter; use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
use ApiPlatform\Doctrine\Orm\Filter\BooleanFilter; use ApiPlatform\Doctrine\Orm\Filter\BooleanFilter;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiResource;
use Chamilo\CoreBundle\Repository\LanguageRepository; use Chamilo\CoreBundle\Repository\LanguageRepository;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
@ -20,7 +20,7 @@ use Symfony\Component\Validator\Constraints as Assert;
/** /**
* Platform languages. * Platform languages.
*/ */
#[ApiResource(attributes: ['pagination_enabled' => false])] #[ApiResource(paginationEnabled: false)]
#[ApiFilter(BooleanFilter::class, properties: ['available'])] #[ApiFilter(BooleanFilter::class, properties: ['available'])]
#[ApiFilter(OrderFilter::class, properties: ['english_name' => 'DESC'])] #[ApiFilter(OrderFilter::class, properties: ['english_name' => 'DESC'])]
#[ORM\Table(name: 'language', options: ['row_format' => 'DYNAMIC'])] #[ORM\Table(name: 'language', options: ['row_format' => 'DYNAMIC'])]

@ -6,10 +6,10 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\Entity; namespace Chamilo\CoreBundle\Entity;
use ApiPlatform\Core\Annotation\ApiFilter;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter; use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\OrderFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter; use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiResource;
use Chamilo\CoreBundle\Repository\LegalRepository; use Chamilo\CoreBundle\Repository\LegalRepository;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Serializer\Annotation\Groups;

@ -6,7 +6,6 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\Entity; namespace Chamilo\CoreBundle\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use Chamilo\CoreBundle\Traits\TimestampableAgoTrait; use Chamilo\CoreBundle\Traits\TimestampableAgoTrait;
use Chamilo\CoreBundle\Traits\TimestampableTypedEntity; use Chamilo\CoreBundle\Traits\TimestampableTypedEntity;
use DateTime; use DateTime;

@ -6,10 +6,9 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\Entity; namespace Chamilo\CoreBundle\Entity;
use ApiPlatform\Core\Annotation\ApiFilter; use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter; use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiResource; use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use Chamilo\CoreBundle\Repository\SkillRepository; use Chamilo\CoreBundle\Repository\SkillRepository;
use DateTime; use DateTime;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;

@ -6,7 +6,7 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\Entity; namespace Chamilo\CoreBundle\Entity;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter; use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Metadata\ApiFilter; use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiResource; use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Delete; use ApiPlatform\Metadata\Delete;

@ -20,18 +20,12 @@ use Symfony\Component\Security\Core\Security;
class AnonymousUserSubscriber implements EventSubscriberInterface class AnonymousUserSubscriber implements EventSubscriberInterface
{ {
private const MAX_ANONYMOUS_USERS = 5; private const MAX_ANONYMOUS_USERS = 5;
private Security $security;
private EntityManagerInterface $entityManager;
private SessionInterface $session;
private SettingsManager $settingsManager;
public function __construct(Security $security, EntityManagerInterface $entityManager, SessionInterface $session, SettingsManager $settingsManager) public function __construct(
{ private readonly Security $security,
$this->security = $security; private readonly EntityManagerInterface $entityManager,
$this->entityManager = $entityManager; private readonly SettingsManager $settingsManager
$this->session = $session; ) { }
$this->settingsManager = $settingsManager;
}
public function onKernelRequest(RequestEvent $event): void public function onKernelRequest(RequestEvent $event): void
{ {
@ -86,7 +80,7 @@ class AnonymousUserSubscriber implements EventSubscriberInterface
'is_anonymous' => true, 'is_anonymous' => true,
]; ];
$this->session->set('_user', $userInfo); $request->getSession()->set('_user', $userInfo);
} }
} }
} }

Loading…
Cancel
Save