Skip to content

Commit

Permalink
[Api] #1245170 - Replace deprecated exception
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreGauthier committed Sep 19, 2024
1 parent 2bd2f27 commit 092cc71
Show file tree
Hide file tree
Showing 23 changed files with 33 additions and 24 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ jobs:
run: |
docker compose -f compose.yml -f compose.ci.yml exec -T php bin/console gally:index:clear --no-interaction
docker compose -f compose.yml -f compose.ci.yml exec -T php bin/console hautelook:fixtures:load --no-interaction -vv
docker compose -f compose.yml -f compose.ci.yml exec -T php bin/console doctrine:fixtures:load --append --no-interaction
- name: Coverage
working-directory: ${{ env.gally-directory }}
Expand Down
2 changes: 1 addition & 1 deletion src/Catalog/Repository/LocalizedCatalogRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Gally\Catalog\Repository;

use ApiPlatform\Exception\InvalidArgumentException;
use ApiPlatform\Metadata\Exception\InvalidArgumentException;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
use Gally\Catalog\Entity\LocalizedCatalog;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Gally\Category\Decoration;

use ApiPlatform\Exception\InvalidArgumentException;
use ApiPlatform\Metadata\Exception\InvalidArgumentException;
use ApiPlatform\Metadata\Operation;
use ApiPlatform\State\ProcessorInterface;
use Gally\Category\Exception\SyncCategoryException;
Expand Down
2 changes: 1 addition & 1 deletion src/Category/Service/CategoryProductPositionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Gally\Category\Service;

use ApiPlatform\Exception\InvalidArgumentException;
use ApiPlatform\Metadata\Exception\InvalidArgumentException;
use Doctrine\ORM\EntityManagerInterface;
use Gally\Catalog\Entity\Catalog;
use Gally\Catalog\Entity\LocalizedCatalog;
Expand Down
10 changes: 10 additions & 0 deletions src/Configuration/Resources/config/api_platform.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ api_platform:
JWT:
name: Authorization
type: header
exception_to_status:
# The 4 following handlers are registered by default, keep those lines to prevent unexpected side effects
Symfony\Component\Serializer\Exception\ExceptionInterface: 400 # Use a raw status code (recommended)
# ApiPlatform\Core\Exception\InvalidArgumentException: !php/const Symfony\Component\HttpFoundation\Response::HTTP_BAD_REQUEST
ApiPlatform\Metadata\Exception\InvalidArgumentException: !php/const Symfony\Component\HttpFoundation\Response::HTTP_BAD_REQUEST
ApiPlatform\ParameterValidator\Exception\ValidationException: 400
Doctrine\ORM\OptimisticLockException: 409
# Validation exception

ApiPlatform\Validator\Exception\ValidationException: !php/const Symfony\Component\HttpFoundation\Response::HTTP_UNPROCESSABLE_ENTITY
# Good defaults for REST APIs
defaults:
stateless: true
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Filter/SearchFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;

/**
* Class copied from ApiPlatform\Doctrine\Odm\Filter\SearchFilter as it is a final class we can't extend it.
* Class copied from ApiPlatform\Doctrine\Orm\Filter\SearchFilter as it is a final class we can't extend it.
* To avoid to have to many duplicate code on Gally we prefer to copy this class and remove the final "tag".
* On unit tests, we added a test to detect changes in the in future versions of api-platform.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Filter/SearchFilterWithDefault.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
use ApiPlatform\Api\IriConverterInterface;
use ApiPlatform\Doctrine\Common\Filter\SearchFilterTrait;
use ApiPlatform\Doctrine\Orm\Util\QueryNameGeneratorInterface;
use ApiPlatform\Exception\InvalidArgumentException;
use ApiPlatform\Metadata\Exception\InvalidArgumentException;
use Doctrine\ORM\QueryBuilder;
use Doctrine\Persistence\ManagerRegistry;
use Gally\Doctrine\Filter\SearchFilter as GallySearchFilter;
Expand Down
6 changes: 3 additions & 3 deletions src/Doctrine/Tests/Unit/SearchFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class SearchFilterTest extends AbstractTestCase
public function testOriginalFileHasChanged(): void
{
$this->assertEquals(
'82d4d86b6bec37d045f2cd602af9f3d4dfff325d',
sha1_file('vendor/api-platform/core/src/Doctrine/Odm/Filter/SearchFilter.php'),
'The original \ApiPlatform\Doctrine\Odm\Filter\SearchFilter file has been updated, please backport this changes in \Gally\Doctrine\Filter\SearchFilter'
'd59474c1ebd88634a8e77781c32ea30271094675',
sha1_file('vendor/api-platform/core/src/Doctrine/Orm/Filter/SearchFilter.php'),
'The original \ApiPlatform\Doctrine\Orm\Filter\SearchFilter file has been updated, please backport this changes in \Gally\Doctrine\Filter\SearchFilter'
);
}
}
2 changes: 1 addition & 1 deletion src/Index/MutationResolver/BulkIndexMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

namespace Gally\Index\MutationResolver;

use ApiPlatform\Exception\InvalidArgumentException;
use ApiPlatform\GraphQl\Resolver\MutationResolverInterface;
use ApiPlatform\Metadata\Exception\InvalidArgumentException;
use Gally\Index\Dto\Bulk;
use Gally\Index\Entity\Index;
use Gally\Index\Repository\Index\IndexRepositoryInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/Index/MutationResolver/CreateIndexMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

namespace Gally\Index\MutationResolver;

use ApiPlatform\Exception\InvalidArgumentException;
use ApiPlatform\GraphQl\Resolver\MutationResolverInterface;
use ApiPlatform\Metadata\Exception\InvalidArgumentException;
use Gally\Catalog\Repository\LocalizedCatalogRepository;
use Gally\Exception\LogicException;
use Gally\Index\Service\IndexOperation;
Expand Down
2 changes: 1 addition & 1 deletion src/Index/MutationResolver/InstallIndexMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

namespace Gally\Index\MutationResolver;

use ApiPlatform\Exception\InvalidArgumentException;
use ApiPlatform\GraphQl\Resolver\MutationResolverInterface;
use ApiPlatform\Metadata\Exception\InvalidArgumentException;
use Gally\Index\Entity\Index;
use Gally\Index\Repository\Index\IndexRepositoryInterface;
use Gally\Index\Service\IndexOperation;
Expand Down
2 changes: 1 addition & 1 deletion src/Index/MutationResolver/RefreshIndexMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

namespace Gally\Index\MutationResolver;

use ApiPlatform\Exception\InvalidArgumentException;
use ApiPlatform\GraphQl\Resolver\MutationResolverInterface;
use ApiPlatform\Metadata\Exception\InvalidArgumentException;
use Gally\Index\Entity\Index;
use Gally\Index\Repository\Index\IndexRepositoryInterface;

Expand Down
2 changes: 1 addition & 1 deletion src/Index/Repository/Document/DocumentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Gally\Index\Repository\Document;

use ApiPlatform\Exception\InvalidArgumentException;
use ApiPlatform\Metadata\Exception\InvalidArgumentException;
use Gally\Index\Dto\Bulk;
use Gally\Index\Repository\Index\IndexRepository;

Expand Down
2 changes: 1 addition & 1 deletion src/Index/Service/SelfReindexOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Gally\Index\Service;

use ApiPlatform\Exception\InvalidArgumentException;
use ApiPlatform\Metadata\Exception\InvalidArgumentException;
use Gally\Catalog\Repository\LocalizedCatalogRepository;
use Gally\Index\Entity\Index;
use Gally\Index\Entity\Index\SelfReindex;
Expand Down
2 changes: 1 addition & 1 deletion src/Index/State/CreateIndexProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Gally\Index\State;

use ApiPlatform\Exception\InvalidArgumentException;
use ApiPlatform\Metadata\Exception\InvalidArgumentException;
use ApiPlatform\Metadata\Operation;
use ApiPlatform\State\ProcessorInterface;
use Gally\Catalog\Repository\LocalizedCatalogRepository;
Expand Down
2 changes: 1 addition & 1 deletion src/Index/State/InstallIndexProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Gally\Index\State;

use ApiPlatform\Exception\InvalidArgumentException;
use ApiPlatform\Metadata\Exception\InvalidArgumentException;
use ApiPlatform\Metadata\Operation;
use ApiPlatform\State\ProcessorInterface;
use Gally\Index\Dto\InstallIndexDto;
Expand Down
2 changes: 1 addition & 1 deletion src/Index/State/RefreshIndexProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Gally\Index\State;

use ApiPlatform\Exception\InvalidArgumentException;
use ApiPlatform\Metadata\Exception\InvalidArgumentException;
use ApiPlatform\Metadata\Operation;
use ApiPlatform\State\ProcessorInterface;
use Gally\Index\Dto\RefreshIndexDto;
Expand Down
2 changes: 1 addition & 1 deletion src/Menu/Service/MenuBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Gally\Menu\Service;

use ApiPlatform\Exception\InvalidArgumentException;
use ApiPlatform\Metadata\Exception\InvalidArgumentException;
use Gally\Menu\Entity\Menu;
use Gally\Menu\Entity\MenuItem;
use Symfony\Contracts\Translation\TranslatorInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/Metadata/Repository/MetadataRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

namespace Gally\Metadata\Repository;

use ApiPlatform\Exception\InvalidArgumentException;
use ApiPlatform\Exception\ResourceClassNotFoundException;
use ApiPlatform\Metadata\Exception\InvalidArgumentException;
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
use Doctrine\Persistence\ManagerRegistry;
Expand Down
2 changes: 1 addition & 1 deletion src/Metadata/State/SourceFieldOptionProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

namespace Gally\Metadata\State;

use ApiPlatform\Exception\InvalidArgumentException;
use ApiPlatform\Metadata\DeleteOperationInterface;
use ApiPlatform\Metadata\Exception\InvalidArgumentException;
use ApiPlatform\Metadata\Operation;
use ApiPlatform\State\ProcessorInterface;
use Doctrine\Common\Collections\ArrayCollection;
Expand Down
2 changes: 1 addition & 1 deletion src/Metadata/State/SourceFieldProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

namespace Gally\Metadata\State;

use ApiPlatform\Exception\InvalidArgumentException;
use ApiPlatform\Metadata\DeleteOperationInterface;
use ApiPlatform\Metadata\Exception\InvalidArgumentException;
use ApiPlatform\Metadata\Operation;
use ApiPlatform\State\ProcessorInterface;
use Doctrine\Common\Collections\ArrayCollection;
Expand Down
2 changes: 1 addition & 1 deletion src/Metadata/Validator/SourceFieldDataValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Gally\Metadata\Validator;

use ApiPlatform\Exception\InvalidArgumentException;
use ApiPlatform\Metadata\Exception\InvalidArgumentException;
use Doctrine\ORM\EntityManagerInterface;
use Gally\Catalog\Repository\LocalizedCatalogRepository;
use Gally\Metadata\Entity\SourceField;
Expand Down
2 changes: 1 addition & 1 deletion src/Metadata/Validator/SourceFieldOptionDataValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Gally\Metadata\Validator;

use ApiPlatform\Exception\InvalidArgumentException;
use ApiPlatform\Metadata\Exception\InvalidArgumentException;
use Gally\Catalog\Repository\LocalizedCatalogRepository;
use Gally\Metadata\Entity\SourceField;

Expand Down

0 comments on commit 092cc71

Please sign in to comment.