Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\Action;
namespace ApiPlatform\Action;

use ApiPlatform\Core\Api\Entrypoint;
use ApiPlatform\Core\Metadata\Resource\Factory\ResourceNameCollectionFactoryInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\Action;
namespace ApiPlatform\Action;

use ApiPlatform\Core\Metadata\Resource\Factory\ResourceMetadataFactoryInterface;
use ApiPlatform\Core\Util\ErrorFormatGuesser;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\Action;
namespace ApiPlatform\Action;

use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\Action;
namespace ApiPlatform\Action;

/**
* Placeholder returning the data passed in parameter.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
use ApiPlatform\Core\DataProvider\CollectionDataProviderInterface;
use ApiPlatform\Core\DataProvider\ItemDataProviderInterface;
use ApiPlatform\Core\DataProvider\SubresourceDataProviderInterface;
use ApiPlatform\Core\DataTransformer\DataTransformerInitializerInterface;
use ApiPlatform\Core\DataTransformer\DataTransformerInterface;
use ApiPlatform\DataTransformer\DataTransformerInitializerInterface;
use ApiPlatform\DataTransformer\DataTransformerInterface;
use ApiPlatform\Core\Metadata\Extractor\XmlExtractor;
use ApiPlatform\Core\Metadata\Extractor\YamlExtractor;
use ApiPlatform\GraphQl\Error\ErrorHandlerInterface;
Expand Down Expand Up @@ -96,6 +96,21 @@ public function load(array $configs, ContainerBuilder $container): void
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));

$deprecatedInterfaces = include __DIR__.'/../../../../../deprecated_interfaces.php';
foreach ($deprecatedInterfaces as $oldInterface => $newInterface) {
if ($container->hasAlias($oldInterface)) {
throw new \LogicException(sprintf('Alias already exist for interface %s. Update xml first to use the new interface.', $oldInterface));
}

if ($container->hasAlias($newInterface)) {
$container->setAlias($oldInterface, $newInterface);
$container
->getDefinition($oldInterface)
->setDeprecated('api-platform/core', '2.7', sprintf('The interface %s is deprecated, use %s instead.', $oldInterface, $newInterface))
;
}
}

$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<argument type="service" id="validator" />
<argument type="service" id="service_container" />
</service>
<service id="ApiPlatform\Core\Validator\ValidatorInterface" alias="api_platform.validator" />
<service id="ApiPlatform\Validator\ValidatorInterface" alias="api_platform.validator" />

<service id="api_platform.metadata.property.metadata_factory.validator" class="ApiPlatform\Core\Bridge\Symfony\Validator\Metadata\Property\ValidatorPropertyMetadataFactory" decorates="api_platform.metadata.property.metadata_factory" decoration-priority="20" public="false">
<argument type="service" id="validator" />
Expand Down
2 changes: 1 addition & 1 deletion src/Core/Bridge/Symfony/Messenger/DataTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace ApiPlatform\Core\Bridge\Symfony\Messenger;

use ApiPlatform\Core\DataTransformer\DataTransformerInterface;
use ApiPlatform\DataTransformer\DataTransformerInterface;
use ApiPlatform\Core\Metadata\Resource\Factory\ResourceMetadataFactoryInterface;
use ApiPlatform\Core\Util\ClassInfoTrait;
use ApiPlatform\Exception\OperationNotFoundException;
Expand Down
4 changes: 2 additions & 2 deletions src/Core/Serializer/AbstractItemNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
use ApiPlatform\Api\UrlGeneratorInterface;
use ApiPlatform\Core\Api\IriConverterInterface as LegacyIriConverterInterface;
use ApiPlatform\Core\DataProvider\ItemDataProviderInterface;
use ApiPlatform\Core\DataTransformer\DataTransformerInitializerInterface;
use ApiPlatform\Core\DataTransformer\DataTransformerInterface;
use ApiPlatform\DataTransformer\DataTransformerInitializerInterface;
use ApiPlatform\DataTransformer\DataTransformerInterface;
use ApiPlatform\Core\Metadata\Property\Factory\PropertyMetadataFactoryInterface as LegacyPropertyMetadataFactoryInterface;
use ApiPlatform\Core\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface as LegacyPropertyNameCollectionFactoryInterface;
use ApiPlatform\Core\Metadata\Property\PropertyMetadata;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\DataTransformer;
namespace ApiPlatform\DataTransformer;

interface DataTransformerInitializerInterface extends DataTransformerInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\DataTransformer;
namespace ApiPlatform\DataTransformer;

/**
* Transforms a DTO or an Anonymous class to a Resource object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

declare(strict_types=1);

namespace ApiPlatform\Core\Validator\EventListener;
namespace ApiPlatform\Symfony\EventListener;

use ApiPlatform\Core\Metadata\Resource\Factory\ResourceMetadataFactoryInterface;
use ApiPlatform\Core\Metadata\Resource\ToggleableOperationAttributeTrait;
Expand Down
33 changes: 33 additions & 0 deletions src/Symfony/EventListener/ValidatorInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

/*
* This file is part of the API Platform project.
*
* (c) Kévin Dunglas <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace ApiPlatform\Symfony\EventListener;

use ApiPlatform\Core\Validator\Exception\ValidationException;

/**
* Validates an item.
*
* @author Kévin Dunglas <[email protected]>
*/
interface ValidatorInterface
{
/**
* Validates an item.
*
* @param object $data
*
* @throws ValidationException
*/
public function validate($data, array $context = []);
}
18 changes: 18 additions & 0 deletions src/deprecated_interfaces.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

/*
* This file is part of the API Platform project.
*
* (c) Kévin Dunglas <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

return [
ApiPlatform\Core\DataTransformer\DataTransformerInitializerInterface::class => ApiPlatform\DataTransformer\DataTransformerInitializerInterface::class,
ApiPlatform\Core\DataTransformer\DataTransformerInterface::class => ApiPlatform\DataTransformer\DataTransformerInterface::class,
ApiPlatform\Core\Validator\ValidatorInterface::class => ApiPlatform\Symfony\EventListener\ValidatorInterface::class,
];
15 changes: 15 additions & 0 deletions src/deprecation.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,16 @@
ApiPlatform\Core\GraphQl\Type\Definition\UploadType::class => ApiPlatform\GraphQl\Type\Definition\UploadType::class,
ApiPlatform\Core\GraphQl\Type\Definition\IterableType::class => ApiPlatform\GraphQl\Type\Definition\IterableType::class,
ApiPlatform\Core\GraphQl\Type\TypesContainer::class => ApiPlatform\GraphQl\Type\TypesContainer::class,

// Action
ApiPlatform\Core\Action\EntrypointAction::class => ApiPlatform\Action\EntrypointAction::class,
ApiPlatform\Core\Action\ExceptionAction::class => ApiPlatform\Action\ExceptionAction::class,
ApiPlatform\Core\Action\NotfoundAction::class => ApiPlatform\Action\NotfoundAction::class,
ApiPlatform\Core\Action\PlaceholderAction::class => ApiPlatform\Action\PlaceholderAction::class,
];

$deprecatedInterfaces = include 'deprecated_interfaces.php';

if (ApiPlatform\Core\Metadata\Property\PropertyMetadata::class === $className) {
trigger_deprecation('api-platform/core', '2.7', sprintf('The class %s is deprecated, use %s instead.', $className, ApiPlatform\Metadata\ApiProperty::class));
}
Expand All @@ -126,4 +134,11 @@ class_alias($deprecatedClasses[$className], $className);

return;
}

if (isset($deprecatedInterfaces[$className])) {
class_alias($deprecatedInterfaces[$className], $className);
trigger_deprecation('api-platform/core', '2.7', sprintf('The interface %s is deprecated, use %s instead.', $className, $deprecatedClasses[$className]));

return;
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

declare(strict_types=1);

namespace ApiPlatform\Core\Tests\Action;
namespace ApiPlatform\Tests\Action;

use ApiPlatform\Core\Action\EntrypointAction;
use ApiPlatform\Action\EntrypointAction;
use ApiPlatform\Core\Api\Entrypoint;
use ApiPlatform\Core\Metadata\Resource\Factory\ResourceNameCollectionFactoryInterface;
use ApiPlatform\Core\Metadata\Resource\ResourceNameCollection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

declare(strict_types=1);

namespace ApiPlatform\Core\Tests\Action;
namespace ApiPlatform\Tests\Action;

use ApiPlatform\Core\Action\ExceptionAction;
use ApiPlatform\Action\ExceptionAction;
use ApiPlatform\Core\Metadata\Resource\Factory\ResourceMetadataFactoryInterface;
use ApiPlatform\Core\Metadata\Resource\ResourceMetadata;
use ApiPlatform\Core\Tests\ProphecyTrait;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

declare(strict_types=1);

namespace ApiPlatform\Core\Tests\Action;
namespace ApiPlatform\Tests\Action;

use ApiPlatform\Core\Action\PlaceholderAction;
use ApiPlatform\Action\PlaceholderAction;
use PHPUnit\Framework\TestCase;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace ApiPlatform\Tests\Bridge\Rector\Rules\ApiResourceAnnotationToApiResourceAttributeRector\Fixture;

use ApiPlatform\Core\Action\NotFoundAction;
use ApiPlatform\Action\NotFoundAction;
use ApiPlatform\Core\Annotation\ApiResource;

/**
Expand Down Expand Up @@ -31,7 +31,7 @@ namespace ApiPlatform\Tests\Bridge\Rector\Rules\ApiResourceAnnotationToApiResour

use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Core\Action\NotFoundAction;
use ApiPlatform\Action\NotFoundAction;
use ApiPlatform\Metadata\ApiResource;

#[ApiResource]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace ApiPlatform\Tests\Bridge\Rector\Rules\LegacyApiResourceAttributeToApiResourceAttributeRector\Fixture;

use ApiPlatform\Core\Action\NotFoundAction;
use ApiPlatform\Action\NotFoundAction;
use ApiPlatform\Core\Annotation\ApiResource;

#[ApiResource(collectionOperations: ['get'], itemOperations: ['get' => ['controller' => NotFoundAction::class, 'read' => false, 'output' => false]])]
Expand All @@ -18,7 +18,7 @@ namespace ApiPlatform\Tests\Bridge\Rector\Rules\LegacyApiResourceAttributeToApiR

use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Core\Action\NotFoundAction;
use ApiPlatform\Action\NotFoundAction;
use ApiPlatform\Metadata\ApiResource;

#[ApiResource]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use ApiPlatform\Api\IdentifiersExtractorInterface;
use ApiPlatform\Api\IriConverterInterface;
use ApiPlatform\Api\UrlGeneratorInterface;
use ApiPlatform\Core\Action\NotFoundAction;
use ApiPlatform\Action\NotFoundAction;
use ApiPlatform\Core\Api\FilterInterface;
use ApiPlatform\Core\Api\IdentifiersExtractorInterface as LegacyIdentifiersExtractorInterface;
use ApiPlatform\Core\Api\IriConverterInterface as LegacyIriConverterInterface;
Expand Down Expand Up @@ -65,8 +65,8 @@
use ApiPlatform\Core\DataProvider\Pagination;
use ApiPlatform\Core\DataProvider\PaginationOptions;
use ApiPlatform\Core\DataProvider\SubresourceDataProviderInterface;
use ApiPlatform\Core\DataTransformer\DataTransformerInitializerInterface;
use ApiPlatform\Core\DataTransformer\DataTransformerInterface;
use ApiPlatform\DataTransformer\DataTransformerInitializerInterface;
use ApiPlatform\DataTransformer\DataTransformerInterface;
use ApiPlatform\Core\JsonSchema\SchemaFactoryInterface;
use ApiPlatform\Core\JsonSchema\TypeFactoryInterface;
use ApiPlatform\Core\Metadata\Property\Factory\PropertyMetadataFactoryInterface as LegacyPropertyMetadataFactoryInterface;
Expand Down
4 changes: 2 additions & 2 deletions tests/Core/Serializer/AbstractItemNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Core\Api\ResourceClassResolverInterface;
use ApiPlatform\Core\DataProvider\ItemDataProviderInterface;
use ApiPlatform\Core\DataTransformer\DataTransformerInitializerInterface;
use ApiPlatform\Core\DataTransformer\DataTransformerInterface;
use ApiPlatform\DataTransformer\DataTransformerInitializerInterface;
use ApiPlatform\DataTransformer\DataTransformerInterface;
use ApiPlatform\Core\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
use ApiPlatform\Core\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface;
use ApiPlatform\Core\Metadata\Property\PropertyMetadata;
Expand Down
2 changes: 1 addition & 1 deletion tests/Core/Serializer/ItemNormalizerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use ApiPlatform\Core\Api\IriConverterInterface;
use ApiPlatform\Core\Api\ResourceClassResolverInterface;
use ApiPlatform\Core\DataTransformer\DataTransformerInterface;
use ApiPlatform\DataTransformer\DataTransformerInterface;
use ApiPlatform\Core\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
use ApiPlatform\Core\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface;
use ApiPlatform\Core\Metadata\Property\PropertyNameCollection;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use ApiPlatform\Core\Tests\ProphecyTrait;
use ApiPlatform\Core\Validator\EventListener\ValidateListener;
use ApiPlatform\Core\Validator\Exception\ValidationException;
use ApiPlatform\Core\Validator\ValidatorInterface;
use ApiPlatform\Validator\ValidatorInterface;
use ApiPlatform\Tests\Fixtures\DummyEntity;
use PHPUnit\Framework\TestCase;
use Prophecy\Argument;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace ApiPlatform\Tests\Fixtures\TestBundle\DataTransformer;

use ApiPlatform\Core\DataTransformer\DataTransformerInterface;
use ApiPlatform\DataTransformer\DataTransformerInterface;
use ApiPlatform\Core\Serializer\AbstractItemNormalizer;
use ApiPlatform\Tests\Fixtures\TestBundle\Document\DummyDtoCustom as DummyDtoCustomDocument;
use ApiPlatform\Tests\Fixtures\TestBundle\Dto\CustomInputDto;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace ApiPlatform\Tests\Fixtures\TestBundle\DataTransformer;

use ApiPlatform\Core\DataTransformer\DataTransformerInterface;
use ApiPlatform\DataTransformer\DataTransformerInterface;
use ApiPlatform\Tests\Fixtures\TestBundle\Document\DummyDtoCustom as DummyDtoCustomDocument;
use ApiPlatform\Tests\Fixtures\TestBundle\Dto\CustomOutputDto;
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\DummyDtoCustom;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace ApiPlatform\Tests\Fixtures\TestBundle\DataTransformer;

use ApiPlatform\Core\DataTransformer\DataTransformerInterface;
use ApiPlatform\DataTransformer\DataTransformerInterface;
use ApiPlatform\Tests\Fixtures\TestBundle\Document\DummyDtoNoInput as DummyDtoNoInputDocument;
use ApiPlatform\Tests\Fixtures\TestBundle\Dto\Document\OutputDto as OutputDtoDocument;
use ApiPlatform\Tests\Fixtures\TestBundle\Dto\OutputDto;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace ApiPlatform\Tests\Fixtures\TestBundle\DataTransformer;

use ApiPlatform\Core\DataTransformer\DataTransformerInitializerInterface;
use ApiPlatform\DataTransformer\DataTransformerInitializerInterface;
use ApiPlatform\Core\Serializer\AbstractItemNormalizer;
use ApiPlatform\Tests\Fixtures\TestBundle\Document\InitializeInput as InitializeInputDocument;
use ApiPlatform\Tests\Fixtures\TestBundle\Dto\InitializeInputDto;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace ApiPlatform\Tests\Fixtures\TestBundle\DataTransformer;

use ApiPlatform\Core\DataTransformer\DataTransformerInterface;
use ApiPlatform\DataTransformer\DataTransformerInterface;
use ApiPlatform\Core\Serializer\AbstractItemNormalizer;
use ApiPlatform\Tests\Fixtures\TestBundle\Document\DummyDtoInputOutput as DummyDtoInputOutputDocument;
use ApiPlatform\Tests\Fixtures\TestBundle\Dto\Document\InputDto as InputDtoDocument;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
namespace ApiPlatform\Tests\Fixtures\TestBundle\DataTransformer;

use ApiPlatform\Core\DataProvider\ArrayPaginator;
use ApiPlatform\Core\DataTransformer\DataTransformerInterface;
use ApiPlatform\DataTransformer\DataTransformerInterface;
use ApiPlatform\Tests\Fixtures\TestBundle\Document\DummyDtoInputOutput as DummyDtoInputOutputDocument;
use ApiPlatform\Tests\Fixtures\TestBundle\Dto\Document\OutputDto as OutputDtoDocument;
use ApiPlatform\Tests\Fixtures\TestBundle\Dto\OutputDto;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace ApiPlatform\Tests\Fixtures\TestBundle\DataTransformer;

use ApiPlatform\Core\DataTransformer\DataTransformerInterface;
use ApiPlatform\DataTransformer\DataTransformerInterface;
use ApiPlatform\Tests\Fixtures\TestBundle\Document\DummyDtoOutputFallbackToSameClass as DummyDtoOutputFallbackToSameClassDocument;
use ApiPlatform\Tests\Fixtures\TestBundle\Document\DummyDtoOutputSameClass as DummyDtoOutputSameClassDocument;
use ApiPlatform\Tests\Fixtures\TestBundle\Dto\OutputDtoDummy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace ApiPlatform\Tests\Fixtures\TestBundle\DataTransformer;

use ApiPlatform\Core\DataTransformer\DataTransformerInterface;
use ApiPlatform\DataTransformer\DataTransformerInterface;
use ApiPlatform\Tests\Fixtures\TestBundle\Document\RPC as RPCDocument;
use ApiPlatform\Tests\Fixtures\TestBundle\Dto\RPCOutput;
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\RPC;
Expand Down
Loading