diff --git a/docs/configure_your_operations.md b/docs/configure_your_operations.md index f3079a92b..a54923037 100644 --- a/docs/configure_your_operations.md +++ b/docs/configure_your_operations.md @@ -33,10 +33,10 @@ There are some basic CRUD operations and more. namespace App\Entity; use Sylius\Component\Resource\Metadata\Index; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Model\ResourceInterface; -#[Resource] +#[ResourceMetadata] #[Index] class Book implements ResourceInterface { @@ -68,10 +68,10 @@ namespace App\Entity; use App\Grid\BookGrid; use Sylius\Component\Resource\Metadata\Index; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Model\ResourceInterface; -#[Resource] +#[ResourceMetadata] // You can use either the FQCN of your grid #[Index(grid: BookGrid::class)] // Or you can use the grid name @@ -101,10 +101,10 @@ The iterator for your books will be available as `books.data` or `resources.data namespace App\Entity; use Sylius\Component\Resource\Metadata\Create; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Model\ResourceInterface; -#[Resource] +#[ResourceMetadata] #[Create] class Book implements ResourceInterface { @@ -137,10 +137,10 @@ The iterator for your books will be available as `books.data` or `resources.data namespace App\Entity; use Sylius\Component\Resource\Metadata\Update; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Model\ResourceInterface; -#[Resource] +#[ResourceMetadata] #[Update] class Book implements ResourceInterface { @@ -171,10 +171,10 @@ On your Twig template, these variables are available namespace App\Entity; use Sylius\Component\Resource\Metadata\Delete; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Model\ResourceInterface; -#[Resource] +#[ResourceMetadata] #[Delete] class Book implements ResourceInterface { @@ -196,10 +196,10 @@ It will configure this route for your `delete` operation. namespace App\Entity; use Sylius\Component\Resource\Metadata\BulkDelete; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Model\ResourceInterface; -#[Resource] +#[ResourceMetadata] #[BulkDelete] class Book implements ResourceInterface { @@ -220,11 +220,11 @@ It will configure this route for your `bulk_delete` operation. ```php namespace App\Entity; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Show; use Sylius\Component\Resource\Model\ResourceInterface; -#[Resource] +#[ResourceMetadata] #[Show] class Book implements ResourceInterface { @@ -258,11 +258,11 @@ As an example, we add a `publish` operation to our book resource. namespace App\Entity; use Sylius\Component\Resource\Metadata\ApplyStateMachineTransition; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Show; use Sylius\Component\Resource\Model\ResourceInterface; -#[Resource] +#[ResourceMetadata] #[ApplyStateMachineTransition(stateMachineTransition: 'publish')] class Book implements ResourceInterface { @@ -286,10 +286,10 @@ It customizes the path for your operations. namespace App\Entity; use Sylius\Component\Resource\Metadata\Create; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Model\ResourceInterface; -#[Resource] +#[ResourceMetadata] #[Create(path: 'register')] class Customer implements ResourceInterface { @@ -309,10 +309,10 @@ It customizes the path for your operations. namespace App\Entity; use Sylius\Component\Resource\Metadata\Create; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Model\ResourceInterface; -#[Resource] +#[ResourceMetadata] #[Create(shortName: 'register')] class Customer implements ResourceInterface { @@ -337,12 +337,12 @@ namespace App\Entity; use Sylius\Component\Resource\Metadata\Create; use Sylius\Component\Resource\Metadata\Index; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Show; use Sylius\Component\Resource\Metadata\Update; use Sylius\Component\Resource\Model\ResourceInterface; -#[Resource(templatesDir: 'book')] +#[ResourceMetadata(templatesDir: 'book')] #[Index] #[Create] #[Update] @@ -371,12 +371,12 @@ use Sylius\Component\Resource\Metadata\BulkDelete; use Sylius\Component\Resource\Metadata\Create; use Sylius\Component\Resource\Metadata\Delete; use Sylius\Component\Resource\Metadata\Index; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Show; use Sylius\Component\Resource\Metadata\Update; use Sylius\Component\Resource\Model\ResourceInterface; -#[Resource(routePrefix: 'admin')] +#[ResourceMetadata(routePrefix: 'admin')] #[Index] #[Create] #[Update] @@ -409,19 +409,19 @@ use Sylius\Component\Resource\Metadata\BulkDelete; use Sylius\Component\Resource\Metadata\Create; use Sylius\Component\Resource\Metadata\Delete; use Sylius\Component\Resource\Metadata\Index; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Show; use Sylius\Component\Resource\Metadata\Update; use Sylius\Component\Resource\Model\ResourceInterface; -#[Resource(section: 'admin', routePrefix: 'admin')] +#[ResourceMetadata(section: 'admin', routePrefix: 'admin')] #[Index] #[Create] #[Update] #[Delete] #[BulkDelete] -#[Resource(section: 'shop')] +#[ResourceMetadata(section: 'shop')] #[Index] #[Show] class Book implements ResourceInterface @@ -451,12 +451,12 @@ use Sylius\Component\Resource\Metadata\BulkDelete; use Sylius\Component\Resource\Metadata\Create; use Sylius\Component\Resource\Metadata\Delete; use Sylius\Component\Resource\Metadata\Index; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Show; use Sylius\Component\Resource\Metadata\Update; use Sylius\Component\Resource\Model\ResourceInterface; -#[Resource(identifier: 'code')] +#[ResourceMetadata(identifier: 'code')] #[Index] #[Create] #[Update] @@ -484,10 +484,10 @@ It defines the simple vars that you can use on your templates. namespace App\Entity; use Sylius\Component\Resource\Metadata\Create; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Model\ResourceInterface; -#[Resource(vars: ['header' => 'Library', 'subheader' => 'Managing your library'])] +#[ResourceMetadata(vars: ['header' => 'Library', 'subheader' => 'Managing your library'])] #[Create(vars: ['subheader' => 'Adding a book'])] class Book implements ResourceInterface { diff --git a/docs/configure_your_resource.md b/docs/configure_your_resource.md index d1a963982..880e2624b 100644 --- a/docs/configure_your_resource.md +++ b/docs/configure_your_resource.md @@ -38,10 +38,10 @@ It will configure your entity as a Sylius resource. ```php namespace App\Entity; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Model\ResourceInterface; -#[Resource] +#[ResourceMetadata] class Book implements ResourceInterface { } @@ -75,10 +75,10 @@ It defines the resource name. ```php namespace App\Entity; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Model\ResourceInterface; -#[Resource(name: 'cart')] +#[ResourceMetadata(name: 'cart')] class Order implements ResourceInterface { } @@ -103,10 +103,10 @@ It defines the resource plural name. ```php namespace App\Entity; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Model\ResourceInterface; -#[Resource(pluralName: 'library')] +#[ResourceMetadata(pluralName: 'library')] class Book implements ResourceInterface { } @@ -131,10 +131,10 @@ It defines the simple vars that you can use on your templates. ```php namespace App\Entity; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Model\ResourceInterface; -#[Resource(vars: ['header' => 'Library', 'subheader' => 'Managing your library'])] +#[ResourceMetadata(vars: ['header' => 'Library', 'subheader' => 'Managing your library'])] class Book implements ResourceInterface { } diff --git a/docs/redirect.md b/docs/redirect.md index 19ad7bbf0..9fdd98075 100644 --- a/docs/redirect.md +++ b/docs/redirect.md @@ -31,11 +31,11 @@ declare(strict_types=1); namespace App\Entity; use Sylius\Component\Resource\Metadata\Create; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Update; use Sylius\Component\Resource\Model\ResourceInterface; -#[Resource] +#[ResourceMetadata] #[Create(redirectToRoute: 'app_book_update')] #[Update(redirectToRoute: 'app_book_update')] class Book implements ResourceInterface @@ -66,7 +66,7 @@ declare(strict_types=1); namespace App\Entity; use Sylius\Component\Resource\Metadata\Create; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Update; use Sylius\Component\Resource\Model\ResourceInterface; diff --git a/docs/resource_factories.md b/docs/resource_factories.md index 714796097..d51b1880a 100644 --- a/docs/resource_factories.md +++ b/docs/resource_factories.md @@ -97,10 +97,10 @@ declare(strict_types=1); namespace App\Entity\Book; use Sylius\Component\Resource\Metadata\Create; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Model\ResourceInterface; -#[Resource] +#[ResourceMetadata] #[Create( path: 'authors/{authorId}/books', factoryMethod: 'createWithCreator', @@ -167,10 +167,10 @@ declare(strict_types=1); namespace App\Entity\Book; use Sylius\Component\Resource\Metadata\Create; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Model\ResourceInterface; -#[Resource] +#[ResourceMetadata] #[Create( path: 'authors/{authorId}/books', factoryMethod: 'createForAuthor', @@ -193,10 +193,10 @@ declare(strict_types=1); namespace App\Entity\Book; use App\Factory\BookFactory;use Sylius\Component\Resource\Metadata\Create; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Model\ResourceInterface; -#[Resource] +#[ResourceMetadata] #[Create( path: 'authors/{authorId}/books', # Here we declared the factory to use with its fully classified class name @@ -240,10 +240,10 @@ namespace App\Entity\Book; use App\Entity\Book; use App\Factory\BookFactory; use Sylius\Component\Resource\Metadata\Create; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Model\ResourceInterface; -#[Resource] +#[ResourceMetadata] #[Create( factory: [BookFactory::class, 'create'], )] diff --git a/docs/responders.md b/docs/responders.md index 2c2e35f1d..8665e83e1 100644 --- a/docs/responders.md +++ b/docs/responders.md @@ -66,11 +66,11 @@ Use it on your operation. namespace App\Entity; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Show; use Sylius\Component\Resource\Model\ResourceInterface; -#[Resource] +#[ResourceMetadata] #[Show( template: 'subscription/show.html.twig', twigContextFactory: ShowSubscriptionContextFactory::class, diff --git a/src/Bundle/Command/DebugResourceCommand.php b/src/Bundle/Command/DebugResourceCommand.php index 0fb386f0f..35249175d 100644 --- a/src/Bundle/Command/DebugResourceCommand.php +++ b/src/Bundle/Command/DebugResourceCommand.php @@ -17,7 +17,7 @@ use Sylius\Component\Resource\Metadata\Operation; use Sylius\Component\Resource\Metadata\Operations; use Sylius\Component\Resource\Metadata\RegistryInterface; -use Sylius\Component\Resource\Metadata\Resource as ResourceMetadata; +use Sylius\Component\Resource\Metadata\ResourceMetadata as ResourceMetadata; use Sylius\Component\Resource\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Helper\Dumper; diff --git a/src/Bundle/DependencyInjection/SyliusResourceExtension.php b/src/Bundle/DependencyInjection/SyliusResourceExtension.php index de29699c6..a20f61a90 100644 --- a/src/Bundle/DependencyInjection/SyliusResourceExtension.php +++ b/src/Bundle/DependencyInjection/SyliusResourceExtension.php @@ -23,8 +23,7 @@ use Sylius\Component\Resource\Factory\Factory; use Sylius\Component\Resource\Factory\FactoryInterface; use Sylius\Component\Resource\Metadata\Metadata; -use Sylius\Component\Resource\Metadata\Resource; -use Sylius\Component\Resource\Metadata\Resource as ResourceMetadata; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Reflection\ClassReflection; use Sylius\Component\Resource\State\ProcessorInterface; use Sylius\Component\Resource\State\ProviderInterface; @@ -150,7 +149,7 @@ private function autoRegisterResources(array &$config, ContainerBuilder $contain } /** @param class-string $className */ - private function getResourceAlias(Resource $resource, string $className): string + private function getResourceAlias(ResourceMetadata $resource, string $className): string { $alias = $resource->getAlias(); diff --git a/src/Component/Doctrine/Common/Metadata/Resource/Factory/DoctrineResourceMetadataCollectionFactory.php b/src/Component/Doctrine/Common/Metadata/Resource/Factory/DoctrineResourceMetadataCollectionFactory.php index d127d587a..94de5c7af 100644 --- a/src/Component/Doctrine/Common/Metadata/Resource/Factory/DoctrineResourceMetadataCollectionFactory.php +++ b/src/Component/Doctrine/Common/Metadata/Resource/Factory/DoctrineResourceMetadataCollectionFactory.php @@ -19,7 +19,7 @@ use Sylius\Component\Resource\Metadata\Operation; use Sylius\Component\Resource\Metadata\Operations; use Sylius\Component\Resource\Metadata\RegistryInterface; -use Sylius\Component\Resource\Metadata\Resource as ResourceMetadata; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; use Sylius\Component\Resource\Metadata\Resource\ResourceMetadataCollection; diff --git a/src/Component/Metadata/AsResource.php b/src/Component/Metadata/AsResource.php new file mode 100644 index 000000000..b06a13db0 --- /dev/null +++ b/src/Component/Metadata/AsResource.php @@ -0,0 +1,56 @@ +repository = $repository; } - public function getResource(): ?Resource + public function getResource(): ?ResourceMetadata { return $this->resource; } - public function withResource(Resource $resource): self + public function withResource(ResourceMetadata $resource): self { $self = clone $this; $self->resource = $resource; diff --git a/src/Component/Metadata/Resource/Factory/AttributesResourceMetadataCollectionFactory.php b/src/Component/Metadata/Resource/Factory/AttributesResourceMetadataCollectionFactory.php index e34ee646a..1f46491bc 100644 --- a/src/Component/Metadata/Resource/Factory/AttributesResourceMetadataCollectionFactory.php +++ b/src/Component/Metadata/Resource/Factory/AttributesResourceMetadataCollectionFactory.php @@ -18,7 +18,7 @@ use Sylius\Component\Resource\Metadata\Operation; use Sylius\Component\Resource\Metadata\Operations; use Sylius\Component\Resource\Metadata\RegistryInterface; -use Sylius\Component\Resource\Metadata\Resource as ResourceMetadata; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Resource\ResourceMetadataCollection; use Sylius\Component\Resource\Reflection\ClassReflection; use Sylius\Component\Resource\Symfony\Request\State\Responder; diff --git a/src/Component/Metadata/Resource/Factory/EventShortNameResourceMetadataCollectionFactory.php b/src/Component/Metadata/Resource/Factory/EventShortNameResourceMetadataCollectionFactory.php index 90d35dbc1..12f992233 100644 --- a/src/Component/Metadata/Resource/Factory/EventShortNameResourceMetadataCollectionFactory.php +++ b/src/Component/Metadata/Resource/Factory/EventShortNameResourceMetadataCollectionFactory.php @@ -16,7 +16,7 @@ use Sylius\Component\Resource\Metadata\ApplyStateMachineTransition; use Sylius\Component\Resource\Metadata\Operation; use Sylius\Component\Resource\Metadata\Operations; -use Sylius\Component\Resource\Metadata\Resource as ResourceMetadata; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Resource\ResourceMetadataCollection; use Sylius\Component\Resource\ResourceActions; diff --git a/src/Component/Metadata/Resource/Factory/FactoryResourceMetadataCollectionFactory.php b/src/Component/Metadata/Resource/Factory/FactoryResourceMetadataCollectionFactory.php index eba12cc2c..ca9c7ed16 100644 --- a/src/Component/Metadata/Resource/Factory/FactoryResourceMetadataCollectionFactory.php +++ b/src/Component/Metadata/Resource/Factory/FactoryResourceMetadataCollectionFactory.php @@ -18,7 +18,7 @@ use Sylius\Component\Resource\Metadata\Operation; use Sylius\Component\Resource\Metadata\Operations; use Sylius\Component\Resource\Metadata\RegistryInterface; -use Sylius\Component\Resource\Metadata\Resource as ResourceMetadata; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Resource\ResourceMetadataCollection; final class FactoryResourceMetadataCollectionFactory implements ResourceMetadataCollectionFactoryInterface diff --git a/src/Component/Metadata/Resource/Factory/ProviderResourceMetadataCollectionFactory.php b/src/Component/Metadata/Resource/Factory/ProviderResourceMetadataCollectionFactory.php index cfb7a63dd..3ab1345cb 100644 --- a/src/Component/Metadata/Resource/Factory/ProviderResourceMetadataCollectionFactory.php +++ b/src/Component/Metadata/Resource/Factory/ProviderResourceMetadataCollectionFactory.php @@ -17,7 +17,7 @@ use Sylius\Component\Resource\Metadata\GridAwareOperationInterface; use Sylius\Component\Resource\Metadata\Operation; use Sylius\Component\Resource\Metadata\Operations; -use Sylius\Component\Resource\Metadata\Resource as ResourceMetadata; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Resource\ResourceMetadataCollection; use Sylius\Component\Resource\Symfony\Request\State\Provider; diff --git a/src/Component/Metadata/Resource/Factory/RedirectResourceMetadataCollectionFactory.php b/src/Component/Metadata/Resource/Factory/RedirectResourceMetadataCollectionFactory.php index b0a7d7a71..0e2d3870f 100644 --- a/src/Component/Metadata/Resource/Factory/RedirectResourceMetadataCollectionFactory.php +++ b/src/Component/Metadata/Resource/Factory/RedirectResourceMetadataCollectionFactory.php @@ -19,7 +19,7 @@ use Sylius\Component\Resource\Metadata\HttpOperation; use Sylius\Component\Resource\Metadata\Operation; use Sylius\Component\Resource\Metadata\Operations; -use Sylius\Component\Resource\Metadata\Resource as ResourceMetadata; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Resource\ResourceMetadataCollection; use Sylius\Component\Resource\Metadata\UpdateOperationInterface; use Sylius\Component\Resource\Symfony\Routing\Factory\OperationRouteNameFactory; diff --git a/src/Component/Metadata/Resource/Factory/StateMachineResourceMetadataCollectionFactory.php b/src/Component/Metadata/Resource/Factory/StateMachineResourceMetadataCollectionFactory.php index 4bcd436a1..e67a7b3de 100644 --- a/src/Component/Metadata/Resource/Factory/StateMachineResourceMetadataCollectionFactory.php +++ b/src/Component/Metadata/Resource/Factory/StateMachineResourceMetadataCollectionFactory.php @@ -17,7 +17,7 @@ use Sylius\Component\Resource\Metadata\Operation; use Sylius\Component\Resource\Metadata\Operations; use Sylius\Component\Resource\Metadata\RegistryInterface; -use Sylius\Component\Resource\Metadata\Resource as ResourceMetadata; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Resource\ResourceMetadataCollection; use Sylius\Component\Resource\Metadata\StateMachineAwareOperationInterface; use Sylius\Component\Resource\StateMachine\State\ApplyStateMachineTransitionProcessor; diff --git a/src/Component/Metadata/Resource/Factory/TemplatesDirResourceMetadataCollectionFactory.php b/src/Component/Metadata/Resource/Factory/TemplatesDirResourceMetadataCollectionFactory.php index c4c462027..776cffafe 100644 --- a/src/Component/Metadata/Resource/Factory/TemplatesDirResourceMetadataCollectionFactory.php +++ b/src/Component/Metadata/Resource/Factory/TemplatesDirResourceMetadataCollectionFactory.php @@ -15,7 +15,7 @@ use Sylius\Component\Resource\Metadata\Operation; use Sylius\Component\Resource\Metadata\Operations; -use Sylius\Component\Resource\Metadata\Resource as ResourceMetadata; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Resource\ResourceMetadataCollection; final class TemplatesDirResourceMetadataCollectionFactory implements ResourceMetadataCollectionFactoryInterface diff --git a/src/Component/Metadata/Resource/Factory/VarsResourceMetadataCollectionFactory.php b/src/Component/Metadata/Resource/Factory/VarsResourceMetadataCollectionFactory.php index 8086072a3..ee46cbe2c 100644 --- a/src/Component/Metadata/Resource/Factory/VarsResourceMetadataCollectionFactory.php +++ b/src/Component/Metadata/Resource/Factory/VarsResourceMetadataCollectionFactory.php @@ -16,7 +16,7 @@ use Sylius\Component\Resource\Metadata\HttpOperation; use Sylius\Component\Resource\Metadata\Operation; use Sylius\Component\Resource\Metadata\Operations; -use Sylius\Component\Resource\Metadata\Resource as ResourceMetadata; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Resource\ResourceMetadataCollection; final class VarsResourceMetadataCollectionFactory implements ResourceMetadataCollectionFactoryInterface diff --git a/src/Component/Metadata/Resource/ResourceMetadataCollection.php b/src/Component/Metadata/Resource/ResourceMetadataCollection.php index 54fe19500..b8b3074d3 100644 --- a/src/Component/Metadata/Resource/ResourceMetadataCollection.php +++ b/src/Component/Metadata/Resource/ResourceMetadataCollection.php @@ -14,7 +14,7 @@ namespace Sylius\Component\Resource\Metadata\Resource; use Sylius\Component\Resource\Metadata\Operation; -use Sylius\Component\Resource\Metadata\Resource as ResourceMetadata; +use Sylius\Component\Resource\Metadata\ResourceMetadata; final class ResourceMetadataCollection extends \ArrayObject { diff --git a/src/Component/Metadata/Resource.php b/src/Component/Metadata/ResourceMetadata.php similarity index 98% rename from src/Component/Metadata/Resource.php rename to src/Component/Metadata/ResourceMetadata.php index efe43f07a..b72de73e0 100644 --- a/src/Component/Metadata/Resource.php +++ b/src/Component/Metadata/ResourceMetadata.php @@ -13,8 +13,7 @@ namespace Sylius\Component\Resource\Metadata; -#[\Attribute(\Attribute::TARGET_CLASS | \Attribute::IS_REPEATABLE)] -final class Resource +final class ResourceMetadata { private ?Operations $operations; diff --git a/src/Component/Symfony/Routing/Factory/AttributesOperationRouteFactory.php b/src/Component/Symfony/Routing/Factory/AttributesOperationRouteFactory.php index 7cdbea6d4..273ef9ea2 100644 --- a/src/Component/Symfony/Routing/Factory/AttributesOperationRouteFactory.php +++ b/src/Component/Symfony/Routing/Factory/AttributesOperationRouteFactory.php @@ -17,7 +17,7 @@ use Sylius\Component\Resource\Metadata\MetadataInterface; use Sylius\Component\Resource\Metadata\Operations; use Sylius\Component\Resource\Metadata\RegistryInterface; -use Sylius\Component\Resource\Metadata\Resource as ResourceMetadata; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; use Symfony\Component\Routing\Route; use Symfony\Component\Routing\RouteCollection; diff --git a/src/Component/Symfony/Routing/Factory/OperationRouteFactory.php b/src/Component/Symfony/Routing/Factory/OperationRouteFactory.php index cee888255..74e290362 100644 --- a/src/Component/Symfony/Routing/Factory/OperationRouteFactory.php +++ b/src/Component/Symfony/Routing/Factory/OperationRouteFactory.php @@ -17,7 +17,7 @@ use Sylius\Component\Resource\Action\PlaceHolderAction; use Sylius\Component\Resource\Metadata\HttpOperation; use Sylius\Component\Resource\Metadata\MetadataInterface; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Symfony\Component\Routing\Route; final class OperationRouteFactory implements OperationRouteFactoryInterface @@ -27,7 +27,7 @@ public function __construct( ) { } - public function create(MetadataInterface $metadata, Resource $resource, HttpOperation $operation): Route + public function create(MetadataInterface $metadata, ResourceMetadata $resource, HttpOperation $operation): Route { $routePath = $operation->getPath() ?? $this->getDefaultRoutePath($metadata, $operation); @@ -61,7 +61,7 @@ private function getDefaultRoutePathForOperation(MetadataInterface $metadata, Ht return $this->routePathFactory->createRoutePath($operation, $rootPath); } - private function getSyliusOptions(Resource $resource, HttpOperation $operation): array + private function getSyliusOptions(ResourceMetadata $resource, HttpOperation $operation): array { $options = ['resource' => $resource->getAlias()]; diff --git a/src/Component/Symfony/Routing/Factory/OperationRouteFactoryInterface.php b/src/Component/Symfony/Routing/Factory/OperationRouteFactoryInterface.php index 13f67e771..bcd32c12d 100644 --- a/src/Component/Symfony/Routing/Factory/OperationRouteFactoryInterface.php +++ b/src/Component/Symfony/Routing/Factory/OperationRouteFactoryInterface.php @@ -15,10 +15,10 @@ use Sylius\Component\Resource\Metadata\HttpOperation; use Sylius\Component\Resource\Metadata\MetadataInterface; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Symfony\Component\Routing\Route; interface OperationRouteFactoryInterface { - public function create(MetadataInterface $metadata, Resource $resource, HttpOperation $operation): Route; + public function create(MetadataInterface $metadata, ResourceMetadata $resource, HttpOperation $operation): Route; } diff --git a/src/Component/Symfony/Routing/RedirectHandler.php b/src/Component/Symfony/Routing/RedirectHandler.php index 1186d9379..7da1f20ef 100644 --- a/src/Component/Symfony/Routing/RedirectHandler.php +++ b/src/Component/Symfony/Routing/RedirectHandler.php @@ -16,7 +16,7 @@ use Sylius\Component\Resource\Metadata\BulkOperationInterface; use Sylius\Component\Resource\Metadata\DeleteOperationInterface; use Sylius\Component\Resource\Metadata\HttpOperation; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Symfony\ExpressionLanguage\ArgumentParserInterface; use Sylius\Component\Resource\Symfony\Routing\Factory\OperationRouteNameFactoryInterface; use Symfony\Component\HttpFoundation\RedirectResponse; @@ -83,7 +83,7 @@ private function getRouteArguments(mixed $data, HttpOperation $operation, Reques return $this->parseResourceValues($resource, $redirectArguments, $data); } - private function parseResourceValues(Resource $resource, array $parameters, mixed $data): array + private function parseResourceValues(ResourceMetadata $resource, array $parameters, mixed $data): array { $accessor = PropertyAccess::createPropertyAccessor(); diff --git a/src/Component/Tests/Dummy/DummyMultiResourcesWithOperations.php b/src/Component/Tests/Dummy/DummyMultiResourcesWithOperations.php index a0a93a018..4753a50a4 100644 --- a/src/Component/Tests/Dummy/DummyMultiResourcesWithOperations.php +++ b/src/Component/Tests/Dummy/DummyMultiResourcesWithOperations.php @@ -15,13 +15,13 @@ use Sylius\Component\Resource\Metadata\Create; use Sylius\Component\Resource\Metadata\Index; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Show; -#[Resource(alias: 'app.order')] +#[ResourceMetadata(alias: 'app.order')] #[Index] #[Create] -#[Resource(alias: 'app.cart')] +#[ResourceMetadata(alias: 'app.cart')] #[Index] #[Show] final class DummyMultiResourcesWithOperations diff --git a/src/Component/Tests/Dummy/DummyResource.php b/src/Component/Tests/Dummy/DummyResource.php index aa3f008c8..a9beac3c9 100644 --- a/src/Component/Tests/Dummy/DummyResource.php +++ b/src/Component/Tests/Dummy/DummyResource.php @@ -13,9 +13,9 @@ namespace Sylius\Component\Resource\Tests\Dummy; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; -#[Resource] +#[ResourceMetadata] final class DummyResource { } diff --git a/src/Component/Tests/Dummy/DummyResourceWithAlias.php b/src/Component/Tests/Dummy/DummyResourceWithAlias.php index 52310c7c3..24e43c03e 100644 --- a/src/Component/Tests/Dummy/DummyResourceWithAlias.php +++ b/src/Component/Tests/Dummy/DummyResourceWithAlias.php @@ -13,9 +13,9 @@ namespace Sylius\Component\Resource\Tests\Dummy; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; -#[Resource(alias: 'app.dummy')] +#[ResourceMetadata(alias: 'app.dummy')] final class DummyResourceWithAlias { } diff --git a/src/Component/Tests/Dummy/DummyResourceWithDenormalizationContext.php b/src/Component/Tests/Dummy/DummyResourceWithDenormalizationContext.php index 302cf434b..72cac9e05 100644 --- a/src/Component/Tests/Dummy/DummyResourceWithDenormalizationContext.php +++ b/src/Component/Tests/Dummy/DummyResourceWithDenormalizationContext.php @@ -15,11 +15,11 @@ use Sylius\Component\Resource\Metadata\Create; use Sylius\Component\Resource\Metadata\Index; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Show; use Sylius\Component\Resource\Metadata\Update; -#[Resource(alias: 'app.dummy', denormalizationContext: ['groups' => ['dummy:write']])] +#[ResourceMetadata(alias: 'app.dummy', denormalizationContext: ['groups' => ['dummy:write']])] #[Create] #[Update] #[Index] diff --git a/src/Component/Tests/Dummy/DummyResourceWithFormOptions.php b/src/Component/Tests/Dummy/DummyResourceWithFormOptions.php index 4ea1eaf46..4f685b563 100644 --- a/src/Component/Tests/Dummy/DummyResourceWithFormOptions.php +++ b/src/Component/Tests/Dummy/DummyResourceWithFormOptions.php @@ -14,10 +14,10 @@ namespace Sylius\Component\Resource\Tests\Dummy; use Sylius\Component\Resource\Metadata\Create; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Update; -#[Resource(alias: 'app.dummy')] +#[ResourceMetadata(alias: 'app.dummy')] #[Create(formOptions: ['html5' => false])] #[Update(formOptions: ['html5' => true])] final class DummyResourceWithFormOptions diff --git a/src/Component/Tests/Dummy/DummyResourceWithFormType.php b/src/Component/Tests/Dummy/DummyResourceWithFormType.php index a19b5184b..851b673b2 100644 --- a/src/Component/Tests/Dummy/DummyResourceWithFormType.php +++ b/src/Component/Tests/Dummy/DummyResourceWithFormType.php @@ -14,10 +14,10 @@ namespace Sylius\Component\Resource\Tests\Dummy; use Sylius\Component\Resource\Metadata\Create; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Update; -#[Resource(alias: 'app.dummy', formType: 'App\Form\DummyType')] +#[ResourceMetadata(alias: 'app.dummy', formType: 'App\Form\DummyType')] #[Create] #[Update] final class DummyResourceWithFormType diff --git a/src/Component/Tests/Dummy/DummyResourceWithGrid.php b/src/Component/Tests/Dummy/DummyResourceWithGrid.php index fd37bca32..91863718a 100644 --- a/src/Component/Tests/Dummy/DummyResourceWithGrid.php +++ b/src/Component/Tests/Dummy/DummyResourceWithGrid.php @@ -15,11 +15,11 @@ use Sylius\Component\Resource\Metadata\Create; use Sylius\Component\Resource\Metadata\Index; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Show; use Sylius\Component\Resource\Metadata\Update; -#[Resource(alias: 'app.dummy')] +#[ResourceMetadata(alias: 'app.dummy')] #[Create] #[Update] #[Index(grid: 'app_dummy')] diff --git a/src/Component/Tests/Dummy/DummyResourceWithName.php b/src/Component/Tests/Dummy/DummyResourceWithName.php index ee49276e4..657bb56b6 100644 --- a/src/Component/Tests/Dummy/DummyResourceWithName.php +++ b/src/Component/Tests/Dummy/DummyResourceWithName.php @@ -15,11 +15,11 @@ use Sylius\Component\Resource\Metadata\Create; use Sylius\Component\Resource\Metadata\Index; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Show; use Sylius\Component\Resource\Metadata\Update; -#[Resource(alias: 'app.dummy', name: 'book')] +#[ResourceMetadata(alias: 'app.dummy', name: 'book')] #[Create] #[Update] #[Index] diff --git a/src/Component/Tests/Dummy/DummyResourceWithNormalizationContext.php b/src/Component/Tests/Dummy/DummyResourceWithNormalizationContext.php index abe98212a..9c7b439e1 100644 --- a/src/Component/Tests/Dummy/DummyResourceWithNormalizationContext.php +++ b/src/Component/Tests/Dummy/DummyResourceWithNormalizationContext.php @@ -15,11 +15,11 @@ use Sylius\Component\Resource\Metadata\Create; use Sylius\Component\Resource\Metadata\Index; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Show; use Sylius\Component\Resource\Metadata\Update; -#[Resource(alias: 'app.dummy', normalizationContext: ['groups' => ['dummy:read']])] +#[ResourceMetadata(alias: 'app.dummy', normalizationContext: ['groups' => ['dummy:read']])] #[Create] #[Update] #[Index] diff --git a/src/Component/Tests/Dummy/DummyResourceWithOperations.php b/src/Component/Tests/Dummy/DummyResourceWithOperations.php index 711bffe6c..5e82efe5f 100644 --- a/src/Component/Tests/Dummy/DummyResourceWithOperations.php +++ b/src/Component/Tests/Dummy/DummyResourceWithOperations.php @@ -15,11 +15,11 @@ use Sylius\Component\Resource\Metadata\Create; use Sylius\Component\Resource\Metadata\Index; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Show; use Sylius\Component\Resource\Metadata\Update; -#[Resource(alias: 'app.dummy')] +#[ResourceMetadata(alias: 'app.dummy')] #[Index] #[Create] #[Update] diff --git a/src/Component/Tests/Dummy/DummyResourceWithPluralName.php b/src/Component/Tests/Dummy/DummyResourceWithPluralName.php index c980cc352..9150ebf38 100644 --- a/src/Component/Tests/Dummy/DummyResourceWithPluralName.php +++ b/src/Component/Tests/Dummy/DummyResourceWithPluralName.php @@ -15,11 +15,11 @@ use Sylius\Component\Resource\Metadata\Create; use Sylius\Component\Resource\Metadata\Index; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Show; use Sylius\Component\Resource\Metadata\Update; -#[Resource(alias: 'app.dummy', pluralName: 'books')] +#[ResourceMetadata(alias: 'app.dummy', pluralName: 'books')] #[Create] #[Update] #[Index] diff --git a/src/Component/Tests/Dummy/DummyResourceWithRoutePrefix.php b/src/Component/Tests/Dummy/DummyResourceWithRoutePrefix.php index 693fd78ca..04bd30732 100644 --- a/src/Component/Tests/Dummy/DummyResourceWithRoutePrefix.php +++ b/src/Component/Tests/Dummy/DummyResourceWithRoutePrefix.php @@ -15,11 +15,11 @@ use Sylius\Component\Resource\Metadata\Create; use Sylius\Component\Resource\Metadata\Index; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Show; use Sylius\Component\Resource\Metadata\Update; -#[Resource(alias: 'app.dummy', routePrefix: '/admin')] +#[ResourceMetadata(alias: 'app.dummy', routePrefix: '/admin')] #[Create] #[Update] #[Index] diff --git a/src/Component/Tests/Dummy/DummyResourceWithSections.php b/src/Component/Tests/Dummy/DummyResourceWithSections.php index e006a9a3f..131ac62d3 100644 --- a/src/Component/Tests/Dummy/DummyResourceWithSections.php +++ b/src/Component/Tests/Dummy/DummyResourceWithSections.php @@ -15,13 +15,13 @@ use Sylius\Component\Resource\Metadata\Create; use Sylius\Component\Resource\Metadata\Index; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Show; -#[Resource(alias: 'app.dummy', section: 'admin')] +#[ResourceMetadata(alias: 'app.dummy', section: 'admin')] #[Index] #[Create] -#[Resource(alias: 'app.dummy', section: 'shop')] +#[ResourceMetadata(alias: 'app.dummy', section: 'shop')] #[Index] #[Show] final class DummyResourceWithSections diff --git a/src/Component/Tests/Dummy/DummyResourceWithSectionsAndNestedOperations.php b/src/Component/Tests/Dummy/DummyResourceWithSectionsAndNestedOperations.php index fb6f37af8..3939a878b 100644 --- a/src/Component/Tests/Dummy/DummyResourceWithSectionsAndNestedOperations.php +++ b/src/Component/Tests/Dummy/DummyResourceWithSectionsAndNestedOperations.php @@ -15,10 +15,10 @@ use Sylius\Component\Resource\Metadata\Create; use Sylius\Component\Resource\Metadata\Index; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Show; -#[Resource( +#[ResourceMetadata( alias: 'app.dummy', section: 'admin', operations: [ @@ -26,7 +26,7 @@ new Create(), ], )] -#[Resource( +#[ResourceMetadata( alias: 'app.dummy', section: 'shop', operations: [ diff --git a/src/Component/Tests/Dummy/DummyResourceWithValidationContext.php b/src/Component/Tests/Dummy/DummyResourceWithValidationContext.php index d90fcaf47..ee1458682 100644 --- a/src/Component/Tests/Dummy/DummyResourceWithValidationContext.php +++ b/src/Component/Tests/Dummy/DummyResourceWithValidationContext.php @@ -14,10 +14,10 @@ namespace Sylius\Component\Resource\Tests\Dummy; use Sylius\Component\Resource\Metadata\Create; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Update; -#[Resource(alias: 'app.dummy', validationContext: ['groups' => ['sylius']])] +#[ResourceMetadata(alias: 'app.dummy', validationContext: ['groups' => ['sylius']])] #[Create] #[Update] final class DummyResourceWithValidationContext diff --git a/src/Component/spec/Doctrine/Common/Metadata/Resource/Factory/DoctrineResourceMetadataCollectionFactorySpec.php b/src/Component/spec/Doctrine/Common/Metadata/Resource/Factory/DoctrineResourceMetadataCollectionFactorySpec.php index aae199cf6..2b4b766f6 100644 --- a/src/Component/spec/Doctrine/Common/Metadata/Resource/Factory/DoctrineResourceMetadataCollectionFactorySpec.php +++ b/src/Component/spec/Doctrine/Common/Metadata/Resource/Factory/DoctrineResourceMetadataCollectionFactorySpec.php @@ -22,7 +22,7 @@ use Sylius\Component\Resource\Metadata\MetadataInterface; use Sylius\Component\Resource\Metadata\Operations; use Sylius\Component\Resource\Metadata\RegistryInterface; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; use Sylius\Component\Resource\Metadata\Resource\ResourceMetadataCollection; @@ -45,7 +45,7 @@ function it_adds_persist_processor_to_operations_for_resource_with_doctrine_orm_ RegistryInterface $resourceRegistry, MetadataInterface $metadata, ): void { - $resource = new Resource(alias: 'app.dummy'); + $resource = new ResourceMetadata(alias: 'app.dummy'); $operation = new Create(name: 'app_dummy_create'); $resource = $resource->withOperations(new Operations([$operation])); @@ -70,7 +70,7 @@ function it_adds_persist_processor_to_operations_for_resource_with_doctrine_dbal RegistryInterface $resourceRegistry, MetadataInterface $metadata, ): void { - $resource = new Resource(alias: 'app.dummy'); + $resource = new ResourceMetadata(alias: 'app.dummy'); $operation = new Create(name: 'app_dummy_create'); $resource = $resource->withOperations(new Operations([$operation])); @@ -95,7 +95,7 @@ function it_adds_remove_processor_to_delete_operations_for_resource_with_doctrin RegistryInterface $resourceRegistry, MetadataInterface $metadata, ): void { - $resource = new Resource(alias: 'app.dummy'); + $resource = new ResourceMetadata(alias: 'app.dummy'); $operation = new Delete(name: 'app_dummy_delete'); $resource = $resource->withOperations(new Operations([$operation])); diff --git a/src/Component/spec/Metadata/ApplyStateMachineTransitionSpec.php b/src/Component/spec/Metadata/ApplyStateMachineTransitionSpec.php index d35f08931..f10d20fae 100644 --- a/src/Component/spec/Metadata/ApplyStateMachineTransitionSpec.php +++ b/src/Component/spec/Metadata/ApplyStateMachineTransitionSpec.php @@ -16,7 +16,7 @@ use PhpSpec\ObjectBehavior; use Sylius\Component\Resource\Metadata\ApplyStateMachineTransition; use Sylius\Component\Resource\Metadata\Operation; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\StateMachineAwareOperationInterface; use Sylius\Component\Resource\Metadata\UpdateOperationInterface; @@ -49,7 +49,7 @@ function it_has_no_resource_by_default(): void function it_could_have_a_resource(): void { - $resource = new Resource(alias: 'app.book'); + $resource = new ResourceMetadata(alias: 'app.book'); $this->withResource($resource) ->getResource() diff --git a/src/Component/spec/Metadata/BulkDeleteSpec.php b/src/Component/spec/Metadata/BulkDeleteSpec.php index 57cd4f8f2..623823d61 100644 --- a/src/Component/spec/Metadata/BulkDeleteSpec.php +++ b/src/Component/spec/Metadata/BulkDeleteSpec.php @@ -18,7 +18,7 @@ use Sylius\Component\Resource\Metadata\BulkOperationInterface; use Sylius\Component\Resource\Metadata\DeleteOperationInterface; use Sylius\Component\Resource\Metadata\Operation; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; final class BulkDeleteSpec extends ObjectBehavior { @@ -49,7 +49,7 @@ function it_has_no_resource_by_default(): void function it_could_have_a_resource(): void { - $resource = new Resource(alias: 'app.book'); + $resource = new ResourceMetadata(alias: 'app.book'); $this->withResource($resource) ->getResource() diff --git a/src/Component/spec/Metadata/CreateSpec.php b/src/Component/spec/Metadata/CreateSpec.php index 30c9c41b1..067a46bc0 100644 --- a/src/Component/spec/Metadata/CreateSpec.php +++ b/src/Component/spec/Metadata/CreateSpec.php @@ -17,7 +17,7 @@ use Sylius\Component\Resource\Metadata\Create; use Sylius\Component\Resource\Metadata\CreateOperationInterface; use Sylius\Component\Resource\Metadata\Operation; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; final class CreateSpec extends ObjectBehavior { @@ -43,7 +43,7 @@ function it_has_no_resource_by_default(): void function it_could_have_a_resource(): void { - $resource = new Resource(alias: 'app.book'); + $resource = new ResourceMetadata(alias: 'app.book'); $this->withResource($resource) ->getResource() diff --git a/src/Component/spec/Metadata/DeleteSpec.php b/src/Component/spec/Metadata/DeleteSpec.php index dbbe4851f..1788a9fc8 100644 --- a/src/Component/spec/Metadata/DeleteSpec.php +++ b/src/Component/spec/Metadata/DeleteSpec.php @@ -17,7 +17,7 @@ use Sylius\Component\Resource\Metadata\Delete; use Sylius\Component\Resource\Metadata\DeleteOperationInterface; use Sylius\Component\Resource\Metadata\Operation; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; final class DeleteSpec extends ObjectBehavior { @@ -43,7 +43,7 @@ function it_has_no_resource_by_default(): void function it_could_have_a_resource(): void { - $resource = new Resource(alias: 'app.book'); + $resource = new ResourceMetadata(alias: 'app.book'); $this->withResource($resource) ->getResource() diff --git a/src/Component/spec/Metadata/IndexSpec.php b/src/Component/spec/Metadata/IndexSpec.php index 4c9a03d15..5054e30f3 100644 --- a/src/Component/spec/Metadata/IndexSpec.php +++ b/src/Component/spec/Metadata/IndexSpec.php @@ -17,7 +17,7 @@ use Sylius\Component\Resource\Metadata\CollectionOperationInterface; use Sylius\Component\Resource\Metadata\Index; use Sylius\Component\Resource\Metadata\Operation; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; final class IndexSpec extends ObjectBehavior { @@ -43,7 +43,7 @@ function it_has_no_resource_by_default(): void function it_could_have_a_resource(): void { - $resource = new Resource(alias: 'app.book'); + $resource = new ResourceMetadata(alias: 'app.book'); $this->withResource($resource) ->getResource() diff --git a/src/Component/spec/Metadata/Operation/HttpOperationInitiatorSpec.php b/src/Component/spec/Metadata/Operation/HttpOperationInitiatorSpec.php index f9ea4578b..44112335a 100644 --- a/src/Component/spec/Metadata/Operation/HttpOperationInitiatorSpec.php +++ b/src/Component/spec/Metadata/Operation/HttpOperationInitiatorSpec.php @@ -19,7 +19,7 @@ use Sylius\Component\Resource\Metadata\Operation\HttpOperationInitiator; use Sylius\Component\Resource\Metadata\Operations; use Sylius\Component\Resource\Metadata\RegistryInterface; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; use Sylius\Component\Resource\Metadata\Resource\ResourceMetadataCollection; use Symfony\Component\HttpFoundation\ParameterBag; @@ -67,7 +67,7 @@ function it_initializes_http_operations_from_request( $operations->add('app_dummy_index', $operation->getWrappedObject()); $resourceMetadataCollection = new ResourceMetadataCollection(); - $resourceMetadataCollection[] = (new Resource(alias: 'app.dummy'))->withOperations($operations); + $resourceMetadataCollection[] = (new ResourceMetadata(alias: 'app.dummy'))->withOperations($operations); $resourceMetadataCollectionFactory->create('App\DummyResource')->willReturn($resourceMetadataCollection); diff --git a/src/Component/spec/Metadata/Resource/Factory/AttributesResourceMetadataCollectionFactorySpec.php b/src/Component/spec/Metadata/Resource/Factory/AttributesResourceMetadataCollectionFactorySpec.php index 4e9ccc193..dbf632825 100644 --- a/src/Component/spec/Metadata/Resource/Factory/AttributesResourceMetadataCollectionFactorySpec.php +++ b/src/Component/spec/Metadata/Resource/Factory/AttributesResourceMetadataCollectionFactorySpec.php @@ -20,7 +20,7 @@ use Sylius\Component\Resource\Metadata\Metadata; use Sylius\Component\Resource\Metadata\Operations; use Sylius\Component\Resource\Metadata\RegistryInterface; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Resource\Factory\AttributesResourceMetadataCollectionFactory; use Sylius\Component\Resource\Metadata\Resource\ResourceMetadataCollection; use Sylius\Component\Resource\Metadata\Show; @@ -65,7 +65,7 @@ function it_creates_resource_metadata(RegistryInterface $resourceRegistry): void $metadataCollection->count()->shouldReturn(1); $resource = $metadataCollection->getIterator()->current(); - $resource->shouldHaveType(Resource::class); + $resource->shouldHaveType(ResourceMetadata::class); $resource->getAlias()->shouldReturn('app.dummy'); } @@ -79,7 +79,7 @@ function it_creates_resource_metadata_without_resource_alias(RegistryInterface $ $metadataCollection->count()->shouldReturn(1); $resource = $metadataCollection->getIterator()->current(); - $resource->shouldHaveType(Resource::class); + $resource->shouldHaveType(ResourceMetadata::class); $resource->getAlias()->shouldReturn('app.dummy'); $resource->getClass()->shouldReturn(DummyResource::class); } @@ -98,7 +98,7 @@ function it_creates_resource_metadata_with_operations(RegistryInterface $resourc $metadataCollection->shouldHaveType(ResourceMetadataCollection::class); $resource = $metadataCollection->getIterator()->current(); - $resource->shouldHaveType(Resource::class); + $resource->shouldHaveType(ResourceMetadata::class); $resource->getAlias()->shouldReturn('app.dummy'); $operations = $resource->getOperations(); @@ -134,7 +134,7 @@ function it_creates_multi_resources_metadata_with_operations(RegistryInterface $ $metadataCollection->count()->shouldReturn(2); $resource = $metadataCollection->getIterator()->current(); - $resource->shouldHaveType(Resource::class); + $resource->shouldHaveType(ResourceMetadata::class); $resource->getAlias()->shouldReturn('app.order'); $operations = $resource->getOperations(); @@ -182,7 +182,7 @@ function it_creates_multi_resources_metadata_with_sections(RegistryInterface $re $metadataCollection->count()->shouldReturn(2); $resource = $metadataCollection->getIterator()->current(); - $resource->shouldHaveType(Resource::class); + $resource->shouldHaveType(ResourceMetadata::class); $resource->getAlias()->shouldReturn('app.dummy'); $operations = $resource->getOperations(); @@ -229,7 +229,7 @@ function it_creates_multi_resources_metadata_with_sections_and_nested_operations $metadataCollection->count()->shouldReturn(2); $resource = $metadataCollection->getIterator()->current(); - $resource->shouldHaveType(Resource::class); + $resource->shouldHaveType(ResourceMetadata::class); $resource->getAlias()->shouldReturn('app.dummy'); $operations = $resource->getOperations(); @@ -273,7 +273,7 @@ function it_creates_operations_even_if_there_is_no_resource_attribute(RegistryIn $metadataCollection->count()->shouldReturn(1); $resource = $metadataCollection->getIterator()->current(); - $resource->shouldHaveType(Resource::class); + $resource->shouldHaveType(ResourceMetadata::class); $resource->getAlias()->shouldReturn('app.dummy'); $operations = $resource->getOperations(); @@ -305,7 +305,7 @@ function it_creates_resource_metadata_with_form_type(RegistryInterface $resource $metadataCollection->shouldHaveType(ResourceMetadataCollection::class); $resource = $metadataCollection->getIterator()->current(); - $resource->shouldHaveType(Resource::class); + $resource->shouldHaveType(ResourceMetadata::class); $resource->getAlias()->shouldReturn('app.dummy'); $operations = $resource->getOperations(); @@ -336,7 +336,7 @@ function it_creates_resource_metadata_with_form_options(RegistryInterface $resou $metadataCollection->shouldHaveType(ResourceMetadataCollection::class); $resource = $metadataCollection->getIterator()->current(); - $resource->shouldHaveType(Resource::class); + $resource->shouldHaveType(ResourceMetadata::class); $resource->getAlias()->shouldReturn('app.dummy'); $operations = $resource->getOperations(); @@ -375,7 +375,7 @@ function it_creates_resource_metadata_with_validation_context(RegistryInterface $metadataCollection->shouldHaveType(ResourceMetadataCollection::class); $resource = $metadataCollection->getIterator()->current(); - $resource->shouldHaveType(Resource::class); + $resource->shouldHaveType(ResourceMetadata::class); $resource->getAlias()->shouldReturn('app.dummy'); $operations = $resource->getOperations(); @@ -416,7 +416,7 @@ function it_creates_resource_metadata_with_resource_name(RegistryInterface $reso $metadataCollection->shouldHaveType(ResourceMetadataCollection::class); $resource = $metadataCollection->getIterator()->current(); - $resource->shouldHaveType(Resource::class); + $resource->shouldHaveType(ResourceMetadata::class); $resource->getAlias()->shouldReturn('app.dummy'); $operations = $resource->getOperations(); @@ -455,7 +455,7 @@ function it_creates_resource_metadata_with_resource_plural_name(RegistryInterfac $metadataCollection->shouldHaveType(ResourceMetadataCollection::class); $resource = $metadataCollection->getIterator()->current(); - $resource->shouldHaveType(Resource::class); + $resource->shouldHaveType(ResourceMetadata::class); $resource->getAlias()->shouldReturn('app.dummy'); $operations = $resource->getOperations(); @@ -494,7 +494,7 @@ function it_creates_resource_metadata_with_default_responder_on_http_operations( $metadataCollection->shouldHaveType(ResourceMetadataCollection::class); $resource = $metadataCollection->getIterator()->current(); - $resource->shouldHaveType(Resource::class); + $resource->shouldHaveType(ResourceMetadata::class); $resource->getAlias()->shouldReturn('app.dummy'); $operations = $resource->getOperations(); @@ -533,7 +533,7 @@ function it_creates_resource_metadata_with_route_prefix(RegistryInterface $resou $metadataCollection->shouldHaveType(ResourceMetadataCollection::class); $resource = $metadataCollection->getIterator()->current(); - $resource->shouldHaveType(Resource::class); + $resource->shouldHaveType(ResourceMetadata::class); $resource->getAlias()->shouldReturn('app.dummy'); $operations = $resource->getOperations(); @@ -576,7 +576,7 @@ function it_creates_resource_metadata_with_normalization_context(RegistryInterfa $metadataCollection->shouldHaveType(ResourceMetadataCollection::class); $resource = $metadataCollection->getIterator()->current(); - $resource->shouldHaveType(Resource::class); + $resource->shouldHaveType(ResourceMetadata::class); $resource->getAlias()->shouldReturn('app.dummy'); $operations = $resource->getOperations(); @@ -619,7 +619,7 @@ function it_creates_resource_metadata_with_denormalization_context(RegistryInter $metadataCollection->shouldHaveType(ResourceMetadataCollection::class); $resource = $metadataCollection->getIterator()->current(); - $resource->shouldHaveType(Resource::class); + $resource->shouldHaveType(ResourceMetadata::class); $resource->getAlias()->shouldReturn('app.dummy'); $operations = $resource->getOperations(); @@ -662,7 +662,7 @@ function it_creates_resource_metadata_with_default_twig_context_factory(Registry $metadataCollection->shouldHaveType(ResourceMetadataCollection::class); $resource = $metadataCollection->getIterator()->current(); - $resource->shouldHaveType(Resource::class); + $resource->shouldHaveType(ResourceMetadata::class); $resource->getAlias()->shouldReturn('app.dummy'); $operations = $resource->getOperations(); diff --git a/src/Component/spec/Metadata/Resource/Factory/EventShortNameResourceMetadataCollectionFactorySpec.php b/src/Component/spec/Metadata/Resource/Factory/EventShortNameResourceMetadataCollectionFactorySpec.php index 6eb22738c..fb378c36c 100644 --- a/src/Component/spec/Metadata/Resource/Factory/EventShortNameResourceMetadataCollectionFactorySpec.php +++ b/src/Component/spec/Metadata/Resource/Factory/EventShortNameResourceMetadataCollectionFactorySpec.php @@ -18,7 +18,7 @@ use Sylius\Component\Resource\Metadata\BulkDelete; use Sylius\Component\Resource\Metadata\Create; use Sylius\Component\Resource\Metadata\Operations; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Resource\Factory\EventShortNameResourceMetadataCollectionFactory; use Sylius\Component\Resource\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; use Sylius\Component\Resource\Metadata\Resource\ResourceMetadataCollection; @@ -40,7 +40,7 @@ function it_is_initializable(): void function it_configures_default_event_short_name_on_operations( ResourceMetadataCollectionFactoryInterface $decorated, ): void { - $resource = new Resource(alias: 'app.book', name: 'book', applicationName: 'app'); + $resource = new ResourceMetadata(alias: 'app.book', name: 'book', applicationName: 'app'); $create = (new Create(name: 'app_book_create'))->withResource($resource); $show = (new Show(name: 'app_book_show'))->withResource($resource); diff --git a/src/Component/spec/Metadata/Resource/Factory/FactoryResourceMetadataCollectionFactorySpec.php b/src/Component/spec/Metadata/Resource/Factory/FactoryResourceMetadataCollectionFactorySpec.php index b320ee411..131731d35 100644 --- a/src/Component/spec/Metadata/Resource/Factory/FactoryResourceMetadataCollectionFactorySpec.php +++ b/src/Component/spec/Metadata/Resource/Factory/FactoryResourceMetadataCollectionFactorySpec.php @@ -18,7 +18,7 @@ use Sylius\Component\Resource\Metadata\MetadataInterface; use Sylius\Component\Resource\Metadata\Operations; use Sylius\Component\Resource\Metadata\RegistryInterface; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Resource\Factory\FactoryResourceMetadataCollectionFactory; use Sylius\Component\Resource\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; use Sylius\Component\Resource\Metadata\Resource\ResourceMetadataCollection; @@ -42,7 +42,7 @@ function it_configures_factory_if_operation_implements_the_interface( ResourceMetadataCollectionFactoryInterface $decorated, MetadataInterface $resourceConfiguration, ): void { - $resource = new Resource(alias: 'app.book', name: 'book', applicationName: 'app'); + $resource = new ResourceMetadata(alias: 'app.book', name: 'book', applicationName: 'app'); $create = (new Create(name: 'app_book_create'))->withResource($resource); diff --git a/src/Component/spec/Metadata/Resource/Factory/ProviderResourceMetadataCollectionFactorySpec.php b/src/Component/spec/Metadata/Resource/Factory/ProviderResourceMetadataCollectionFactorySpec.php index f506f5dfc..582e370a7 100644 --- a/src/Component/spec/Metadata/Resource/Factory/ProviderResourceMetadataCollectionFactorySpec.php +++ b/src/Component/spec/Metadata/Resource/Factory/ProviderResourceMetadataCollectionFactorySpec.php @@ -17,7 +17,7 @@ use Sylius\Component\Resource\Grid\State\RequestGridProvider; use Sylius\Component\Resource\Metadata\Index; use Sylius\Component\Resource\Metadata\Operations; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Resource\Factory\ProviderResourceMetadataCollectionFactory; use Sylius\Component\Resource\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; use Sylius\Component\Resource\Metadata\Resource\ResourceMetadataCollection; @@ -39,7 +39,7 @@ function it_is_initializable(): void function it_creates_resource_metadata_with_default_provider_on_http_operations( ResourceMetadataCollectionFactoryInterface $decorated, ): void { - $resource = new Resource(alias: 'app.book', name: 'book', applicationName: 'app'); + $resource = new ResourceMetadata(alias: 'app.book', name: 'book', applicationName: 'app'); $index = (new Index(name: 'app_book_index'))->withResource($resource); @@ -61,7 +61,7 @@ function it_creates_resource_metadata_with_default_provider_on_http_operations( function it_configures_request_grid_provider_if_operation_has_a_grid( ResourceMetadataCollectionFactoryInterface $decorated, ): void { - $resource = new Resource(alias: 'app.book', name: 'book', applicationName: 'app'); + $resource = new ResourceMetadata(alias: 'app.book', name: 'book', applicationName: 'app'); $index = (new Index(name: 'app_book_index', grid: 'app_book'))->withResource($resource); diff --git a/src/Component/spec/Metadata/Resource/Factory/RedirectResourceMetadataCollectionFactorySpec.php b/src/Component/spec/Metadata/Resource/Factory/RedirectResourceMetadataCollectionFactorySpec.php index 8d8dc6d0b..7b9d58cfb 100644 --- a/src/Component/spec/Metadata/Resource/Factory/RedirectResourceMetadataCollectionFactorySpec.php +++ b/src/Component/spec/Metadata/Resource/Factory/RedirectResourceMetadataCollectionFactorySpec.php @@ -18,7 +18,7 @@ use Sylius\Component\Resource\Metadata\Delete; use Sylius\Component\Resource\Metadata\Index; use Sylius\Component\Resource\Metadata\Operations; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Resource\Factory\RedirectResourceMetadataCollectionFactory; use Sylius\Component\Resource\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; use Sylius\Component\Resource\Metadata\Resource\ResourceMetadataCollection; @@ -41,7 +41,7 @@ function it_is_initializable(): void function it_redirects_create_to_show_if_route_exists( ResourceMetadataCollectionFactoryInterface $decorated, ): void { - $resource = new Resource(alias: 'app.book', name: 'book', applicationName: 'app'); + $resource = new ResourceMetadata(alias: 'app.book', name: 'book', applicationName: 'app'); $create = (new Create(name: 'app_book_create'))->withResource($resource); $show = (new Show(name: 'app_book_show'))->withResource($resource); @@ -65,7 +65,7 @@ function it_redirects_create_to_show_if_route_exists( function it_redirects_create_to_index_if_route_exists( ResourceMetadataCollectionFactoryInterface $decorated, ): void { - $resource = new Resource(alias: 'app.book', name: 'book', applicationName: 'app'); + $resource = new ResourceMetadata(alias: 'app.book', name: 'book', applicationName: 'app'); $create = (new Create(name: 'app_book_create'))->withResource($resource); $index = (new Create(name: 'app_book_index'))->withResource($resource); @@ -89,7 +89,7 @@ function it_redirects_create_to_index_if_route_exists( function it_redirects_update_to_show_if_route_exists( ResourceMetadataCollectionFactoryInterface $decorated, ): void { - $resource = new Resource(alias: 'app.book', name: 'book', applicationName: 'app'); + $resource = new ResourceMetadata(alias: 'app.book', name: 'book', applicationName: 'app'); $update = (new Update(name: 'app_book_update'))->withResource($resource); $show = (new Show(name: 'app_book_show'))->withResource($resource); @@ -113,7 +113,7 @@ function it_redirects_update_to_show_if_route_exists( function it_redirects_update_to_index_if_route_exists( ResourceMetadataCollectionFactoryInterface $decorated, ): void { - $resource = new Resource(alias: 'app.book', name: 'book', applicationName: 'app'); + $resource = new ResourceMetadata(alias: 'app.book', name: 'book', applicationName: 'app'); $update = (new Update(name: 'app_book_update'))->withResource($resource); $index = (new Index(name: 'app_book_index'))->withResource($resource); @@ -137,7 +137,7 @@ function it_redirects_update_to_index_if_route_exists( function it_redirects_delete_to_index_if_route_exists( ResourceMetadataCollectionFactoryInterface $decorated, ): void { - $resource = new Resource(alias: 'app.book', name: 'book', applicationName: 'app'); + $resource = new ResourceMetadata(alias: 'app.book', name: 'book', applicationName: 'app'); $delete = (new Delete(name: 'app_book_delete'))->withResource($resource); $index = (new Show(name: 'app_book_index'))->withResource($resource); diff --git a/src/Component/spec/Metadata/Resource/Factory/StateMachineResourceMetadataCollectionFactorySpec.php b/src/Component/spec/Metadata/Resource/Factory/StateMachineResourceMetadataCollectionFactorySpec.php index f61e18b25..8d2ae91b6 100644 --- a/src/Component/spec/Metadata/Resource/Factory/StateMachineResourceMetadataCollectionFactorySpec.php +++ b/src/Component/spec/Metadata/Resource/Factory/StateMachineResourceMetadataCollectionFactorySpec.php @@ -18,7 +18,7 @@ use Sylius\Component\Resource\Metadata\MetadataInterface; use Sylius\Component\Resource\Metadata\Operations; use Sylius\Component\Resource\Metadata\RegistryInterface; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; use Sylius\Component\Resource\Metadata\Resource\Factory\StateMachineResourceMetadataCollectionFactory; use Sylius\Component\Resource\Metadata\Resource\ResourceMetadataCollection; @@ -45,7 +45,7 @@ function it_sets_the_default_state_machine_component_from_settings( ): void { $this->beConstructedWith($resourceRegistry, $decorated, 'symfony'); - $resource = new Resource(alias: 'app.book', name: 'book', applicationName: 'app'); + $resource = new ResourceMetadata(alias: 'app.book', name: 'book', applicationName: 'app'); $create = (new Create(name: 'app_book_create'))->withResource($resource); @@ -73,7 +73,7 @@ function it_sets_the_default_state_machine_component_from_resource_configuration ResourceMetadataCollectionFactoryInterface $decorated, MetadataInterface $resourceConfiguration, ): void { - $resource = new Resource(alias: 'app.book', name: 'book', applicationName: 'app'); + $resource = new ResourceMetadata(alias: 'app.book', name: 'book', applicationName: 'app'); $create = (new Create(name: 'app_book_create'))->withResource($resource); @@ -101,7 +101,7 @@ function it_sets_the_configured_state_machine_component_from_operation( ResourceMetadataCollectionFactoryInterface $decorated, MetadataInterface $resourceConfiguration, ): void { - $resource = new Resource(alias: 'app.book', name: 'book', applicationName: 'app'); + $resource = new ResourceMetadata(alias: 'app.book', name: 'book', applicationName: 'app'); $create = (new Create(name: 'app_book_create', stateMachineComponent: 'winzou'))->withResource($resource); @@ -129,7 +129,7 @@ function it_configures_apply_state_machine_transition_processor_if_operation_has ResourceMetadataCollectionFactoryInterface $decorated, MetadataInterface $resourceConfiguration, ): void { - $resource = new Resource(alias: 'app.book', name: 'book', applicationName: 'app'); + $resource = new ResourceMetadata(alias: 'app.book', name: 'book', applicationName: 'app'); $create = (new Create(name: 'app_book_create', stateMachineTransition: 'publish'))->withResource($resource); diff --git a/src/Component/spec/Metadata/Resource/Factory/TemplatesDirResourceMetadataCollectionFactorySpec.php b/src/Component/spec/Metadata/Resource/Factory/TemplatesDirResourceMetadataCollectionFactorySpec.php index 4bec024e2..075626286 100644 --- a/src/Component/spec/Metadata/Resource/Factory/TemplatesDirResourceMetadataCollectionFactorySpec.php +++ b/src/Component/spec/Metadata/Resource/Factory/TemplatesDirResourceMetadataCollectionFactorySpec.php @@ -16,7 +16,7 @@ use PhpSpec\ObjectBehavior; use Sylius\Component\Resource\Metadata\Create; use Sylius\Component\Resource\Metadata\Operations; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; use Sylius\Component\Resource\Metadata\Resource\Factory\TemplatesDirResourceMetadataCollectionFactory; use Sylius\Component\Resource\Metadata\Resource\ResourceMetadataCollection; @@ -39,7 +39,7 @@ function it_uses_default_templates_dir( ): void { $this->beConstructedWith($decorated, ['default_templates_dir' => 'crud']); - $resource = new Resource(alias: 'app.book'); + $resource = new ResourceMetadata(alias: 'app.book'); $create = (new Create(name: 'app_book_create'))->withResource($resource); $show = (new Show(name: 'app_book_show'))->withResource($resource); @@ -66,7 +66,7 @@ function it_uses_default_templates_dir( function it_uses_resource_templates_dir( ResourceMetadataCollectionFactoryInterface $decorated, ): void { - $resource = new Resource(alias: 'app.book', templatesDir: 'book'); + $resource = new ResourceMetadata(alias: 'app.book', templatesDir: 'book'); $create = (new Create(name: 'app_book_create'))->withResource($resource); $show = (new Show(name: 'app_book_show'))->withResource($resource); diff --git a/src/Component/spec/Metadata/Resource/Factory/VarsResourceMetadataCollectionFactorySpec.php b/src/Component/spec/Metadata/Resource/Factory/VarsResourceMetadataCollectionFactorySpec.php index a91a1ae45..6de659d3b 100644 --- a/src/Component/spec/Metadata/Resource/Factory/VarsResourceMetadataCollectionFactorySpec.php +++ b/src/Component/spec/Metadata/Resource/Factory/VarsResourceMetadataCollectionFactorySpec.php @@ -16,7 +16,7 @@ use PhpSpec\ObjectBehavior; use Sylius\Component\Resource\Metadata\Create; use Sylius\Component\Resource\Metadata\Operations; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; use Sylius\Component\Resource\Metadata\Resource\Factory\VarsResourceMetadataCollectionFactory; use Sylius\Component\Resource\Metadata\Resource\ResourceMetadataCollection; @@ -37,7 +37,7 @@ function it_is_initializable(): void function it_merge_resource_vars_with_operation_vars( ResourceMetadataCollectionFactoryInterface $decorated, ): void { - $resource = new Resource(alias: 'app.book', name: 'book', applicationName: 'app', vars: ['header' => 'Library', 'subheader' => 'Managing your library']); + $resource = new ResourceMetadata(alias: 'app.book', name: 'book', applicationName: 'app', vars: ['header' => 'Library', 'subheader' => 'Managing your library']); $create = (new Create(name: 'app_book_create', vars: ['subheader' => 'Adding a new book']))->withResource($resource); $show = (new Show(name: 'app_book_show'))->withResource($resource); @@ -64,7 +64,7 @@ function it_merge_resource_vars_with_operation_vars( function it_does_nothing_when_resource_has_no_vars( ResourceMetadataCollectionFactoryInterface $decorated, ): void { - $resource = new Resource(alias: 'app.book', name: 'book', applicationName: 'app'); + $resource = new ResourceMetadata(alias: 'app.book', name: 'book', applicationName: 'app'); $create = (new Create(name: 'app_book_create'))->withResource($resource); $show = (new Show(name: 'app_book_show'))->withResource($resource); diff --git a/src/Component/spec/Metadata/Resource/ResourceMetadataCollectionSpec.php b/src/Component/spec/Metadata/Resource/ResourceMetadataCollectionSpec.php index 18eab92e9..a59053148 100644 --- a/src/Component/spec/Metadata/Resource/ResourceMetadataCollectionSpec.php +++ b/src/Component/spec/Metadata/Resource/ResourceMetadataCollectionSpec.php @@ -17,7 +17,7 @@ use Sylius\Component\Resource\Metadata\Create; use Sylius\Component\Resource\Metadata\Index; use Sylius\Component\Resource\Metadata\Operations; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Resource\ResourceMetadataCollection; final class ResourceMetadataCollectionSpec extends ObjectBehavior @@ -25,7 +25,7 @@ final class ResourceMetadataCollectionSpec extends ObjectBehavior function let(): void { $this->beConstructedWith([ - (new Resource('app.dummy'))->withOperations(new Operations([ + (new ResourceMetadata('app.dummy'))->withOperations(new Operations([ 'app_dummy_index' => new Index(), 'app_dummy_create' => new Create(), ])), diff --git a/src/Component/spec/Metadata/ResourceSpec.php b/src/Component/spec/Metadata/ResourceSpec.php index 8c894324e..3989329be 100644 --- a/src/Component/spec/Metadata/ResourceSpec.php +++ b/src/Component/spec/Metadata/ResourceSpec.php @@ -16,14 +16,14 @@ use PhpSpec\ObjectBehavior; use Sylius\Component\Resource\Metadata\Create; use Sylius\Component\Resource\Metadata\Operations; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Update; final class ResourceSpec extends ObjectBehavior { function it_is_initializable(): void { - $this->shouldHaveType(Resource::class); + $this->shouldHaveType(ResourceMetadata::class); } function it_has_no_alias_by_default(): void diff --git a/src/Component/spec/Metadata/ShowSpec.php b/src/Component/spec/Metadata/ShowSpec.php index 71631370f..fcdb27412 100644 --- a/src/Component/spec/Metadata/ShowSpec.php +++ b/src/Component/spec/Metadata/ShowSpec.php @@ -15,7 +15,7 @@ use PhpSpec\ObjectBehavior; use Sylius\Component\Resource\Metadata\Operation; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Show; use Sylius\Component\Resource\Metadata\ShowOperationInterface; @@ -43,7 +43,7 @@ function it_has_no_resource_by_default(): void function it_could_have_a_resource(): void { - $resource = new Resource(alias: 'app.book'); + $resource = new ResourceMetadata(alias: 'app.book'); $this->withResource($resource) ->getResource() diff --git a/src/Component/spec/Metadata/UpdateSpec.php b/src/Component/spec/Metadata/UpdateSpec.php index c35deab78..c0a613e9b 100644 --- a/src/Component/spec/Metadata/UpdateSpec.php +++ b/src/Component/spec/Metadata/UpdateSpec.php @@ -15,7 +15,7 @@ use PhpSpec\ObjectBehavior; use Sylius\Component\Resource\Metadata\Operation; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Update; use Sylius\Component\Resource\Metadata\UpdateOperationInterface; @@ -43,7 +43,7 @@ function it_has_no_resource_by_default(): void function it_could_have_a_resource(): void { - $resource = new Resource(alias: 'app.book'); + $resource = new ResourceMetadata(alias: 'app.book'); $this->withResource($resource) ->getResource() diff --git a/src/Component/spec/Symfony/EventDispatcher/OperationEventDispatcherSpec.php b/src/Component/spec/Symfony/EventDispatcher/OperationEventDispatcherSpec.php index d164a19b8..b7e3f20b0 100644 --- a/src/Component/spec/Symfony/EventDispatcher/OperationEventDispatcherSpec.php +++ b/src/Component/spec/Symfony/EventDispatcher/OperationEventDispatcherSpec.php @@ -17,7 +17,7 @@ use Sylius\Component\Resource\Context\Context; use Sylius\Component\Resource\Metadata\BulkDelete; use Sylius\Component\Resource\Metadata\Create; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Show; use Sylius\Component\Resource\Symfony\EventDispatcher\OperationEvent; use Sylius\Component\Resource\Symfony\EventDispatcher\OperationEventDispatcher; @@ -39,7 +39,7 @@ function it_dispatches_events( EventDispatcherInterface $eventDispatcher, \stdClass $data, ): void { - $resource = new Resource(alias: 'app.book', name: 'book', applicationName: 'app'); + $resource = new ResourceMetadata(alias: 'app.book', name: 'book', applicationName: 'app'); $show = (new Show(eventShortName: 'read'))->withResource($resource); $context = new Context(); @@ -58,7 +58,7 @@ function it_dispatches_events_for_bulk_operations( EventDispatcherInterface $eventDispatcher, \ArrayObject $data, ): void { - $resource = new Resource(alias: 'app.book', name: 'book', applicationName: 'app'); + $resource = new ResourceMetadata(alias: 'app.book', name: 'book', applicationName: 'app'); $bulkDelete = (new BulkDelete(eventShortName: 'delete'))->withResource($resource); $context = new Context(); @@ -77,7 +77,7 @@ function it_dispatches_pre_events( EventDispatcherInterface $eventDispatcher, \stdClass $data, ): void { - $resource = new Resource(alias: 'app.book', name: 'book', applicationName: 'app'); + $resource = new ResourceMetadata(alias: 'app.book', name: 'book', applicationName: 'app'); $create = (new Create(eventShortName: 'create'))->withResource($resource); $context = new Context(); @@ -96,7 +96,7 @@ function it_dispatches_post_events( EventDispatcherInterface $eventDispatcher, \stdClass $data, ): void { - $resource = new Resource(alias: 'app.book', name: 'book', applicationName: 'app'); + $resource = new ResourceMetadata(alias: 'app.book', name: 'book', applicationName: 'app'); $create = (new Create(eventShortName: 'create'))->withResource($resource); $context = new Context(); @@ -115,7 +115,7 @@ function it_dispatches_initialize_events( EventDispatcherInterface $eventDispatcher, \stdClass $data, ): void { - $resource = new Resource(alias: 'app.book', name: 'book', applicationName: 'app'); + $resource = new ResourceMetadata(alias: 'app.book', name: 'book', applicationName: 'app'); $create = (new Create(eventShortName: 'create'))->withResource($resource); $context = new Context(); diff --git a/src/Component/spec/Symfony/EventListener/DeserializeListenerSpec.php b/src/Component/spec/Symfony/EventListener/DeserializeListenerSpec.php index 88b0f76a8..2b671b195 100644 --- a/src/Component/spec/Symfony/EventListener/DeserializeListenerSpec.php +++ b/src/Component/spec/Symfony/EventListener/DeserializeListenerSpec.php @@ -16,7 +16,7 @@ use PhpSpec\ObjectBehavior; use Sylius\Component\Resource\Metadata\HttpOperation; use Sylius\Component\Resource\Metadata\Operation\HttpOperationInitiatorInterface; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Symfony\EventListener\DeserializeListener; use Symfony\Component\HttpFoundation\ParameterBag; use Symfony\Component\HttpFoundation\Request; @@ -51,7 +51,7 @@ function it_deserializes_data( $request->attributes = new ParameterBag(); - $operation->getResource()->willReturn(new Resource(alias: 'app.dummy', class: 'App\Resource')); + $operation->getResource()->willReturn(new ResourceMetadata(alias: 'app.dummy', class: 'App\Resource')); $operation->getDenormalizationContext()->willReturn(null)->shouldBeCalled(); $request->isMethodSafe()->willReturn(false); @@ -84,7 +84,7 @@ function it_deserializes_data_with_denormalization_context( $request->getRequestFormat()->willReturn('json'); $request->getContent()->willReturn(['food' => 'fighters']); - $operation->getResource()->willReturn(new Resource(alias: 'app.dummy', class: 'App\Resource')); + $operation->getResource()->willReturn(new ResourceMetadata(alias: 'app.dummy', class: 'App\Resource')); $operation->canDeserialize()->willReturn(null)->shouldBeCalled(); $operation->getDenormalizationContext()->willReturn(['groups' => ['dummy:write']]); @@ -111,7 +111,7 @@ function it_does_nothing_if_operation_cannot_be_deserialized( $request->getRequestFormat()->willReturn('json'); $request->getContent()->willReturn(['food' => 'fighters']); - $operation->getResource()->willReturn(new Resource(alias: 'app.dummy', class: 'App\Resource')); + $operation->getResource()->willReturn(new ResourceMetadata(alias: 'app.dummy', class: 'App\Resource')); $operation->canDeserialize()->willReturn(false)->shouldBeCalled(); $serializer->deserialize(['food' => 'fighters'], 'App\Resource', 'json', [])->willReturn($data)->shouldNotBeCalled(); diff --git a/src/Component/spec/Symfony/EventListener/ValidateListenerSpec.php b/src/Component/spec/Symfony/EventListener/ValidateListenerSpec.php index 27a98f727..49eb4c267 100644 --- a/src/Component/spec/Symfony/EventListener/ValidateListenerSpec.php +++ b/src/Component/spec/Symfony/EventListener/ValidateListenerSpec.php @@ -19,7 +19,7 @@ use Sylius\Component\Resource\Metadata\Index; use Sylius\Component\Resource\Metadata\Operation\HttpOperationInitiatorInterface; use Sylius\Component\Resource\Metadata\Operations; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; use Sylius\Component\Resource\Metadata\Resource\ResourceMetadataCollection; use Sylius\Component\Resource\Symfony\EventListener\ValidateListener; @@ -151,7 +151,7 @@ function it_does_nothing_if_operation_is_not_a_create_or_update_operation( $operations->add('app_dummy_create', $operation); $resourceMetadataCollection = new ResourceMetadataCollection(); - $resourceMetadataCollection[] = (new Resource(alias: 'app.dummy'))->withOperations($operations); + $resourceMetadataCollection[] = (new ResourceMetadata(alias: 'app.dummy'))->withOperations($operations); $resourceMetadataCollectionFactory->create('App\Dummy')->willReturn($resourceMetadataCollection); diff --git a/src/Component/spec/Symfony/Request/State/ApiResponderSpec.php b/src/Component/spec/Symfony/Request/State/ApiResponderSpec.php index be4073c17..5067e47e8 100644 --- a/src/Component/spec/Symfony/Request/State/ApiResponderSpec.php +++ b/src/Component/spec/Symfony/Request/State/ApiResponderSpec.php @@ -18,7 +18,7 @@ use Sylius\Component\Resource\Context\Option\RequestOption; use Sylius\Component\Resource\Metadata\Create; use Sylius\Component\Resource\Metadata\Delete; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Update; use Sylius\Component\Resource\Symfony\Request\State\ApiResponder; use Sylius\Component\Resource\Symfony\Response\ApiHeadersInitiator; @@ -52,7 +52,7 @@ function it_returns_a_response_with_http_created_for_resource_create( $attributes->getBoolean('is_valid', true)->willReturn(true)->shouldBeCalled(); $attributes->get('form')->willReturn(null); - $resource = new Resource(alias: 'app.book', name: 'book'); + $resource = new ResourceMetadata(alias: 'app.book', name: 'book'); $operation = (new Create())->withResource($resource); $response = $this->respond('serialized_data', $operation, $context); @@ -74,7 +74,7 @@ function it_returns_a_response_with_http_no_content_for_resource_update( $attributes->getBoolean('is_valid', true)->willReturn(true)->shouldBeCalled(); $attributes->get('form')->willReturn(null); - $resource = new Resource(alias: 'app.book', name: 'book'); + $resource = new ResourceMetadata(alias: 'app.book', name: 'book'); $operation = (new Update())->withResource($resource); $response = $this->respond('serialized_data', $operation, $context); @@ -96,7 +96,7 @@ function it_returns_a_response_with_http_no_content_for_resource_delete( $attributes->getBoolean('is_valid', true)->willReturn(true)->shouldBeCalled(); $attributes->get('form')->willReturn(null); - $resource = new Resource(alias: 'app.book', name: 'book'); + $resource = new ResourceMetadata(alias: 'app.book', name: 'book'); $operation = (new Delete())->withResource($resource); $response = $this->respond('serialized_data', $operation, $context); @@ -118,7 +118,7 @@ function it_returns_a_response_with_http_unprocessable_entity_for_invalid_resour $attributes->getBoolean('is_valid', true)->willReturn(false)->shouldBeCalled(); $attributes->get('form')->willReturn(null); - $resource = new Resource(alias: 'app.book', name: 'book'); + $resource = new ResourceMetadata(alias: 'app.book', name: 'book'); $operation = (new Create())->withResource($resource); $response = $this->respond('serialized_data', $operation, $context); diff --git a/src/Component/spec/Symfony/Request/State/TwigResponderSpec.php b/src/Component/spec/Symfony/Request/State/TwigResponderSpec.php index e0fdd8543..40c146847 100644 --- a/src/Component/spec/Symfony/Request/State/TwigResponderSpec.php +++ b/src/Component/spec/Symfony/Request/State/TwigResponderSpec.php @@ -18,7 +18,7 @@ use Sylius\Component\Resource\Context\Option\RequestOption; use Sylius\Component\Resource\Metadata\Create; use Sylius\Component\Resource\Metadata\Index; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Show; use Sylius\Component\Resource\Symfony\Request\State\TwigResponder; use Sylius\Component\Resource\Symfony\Routing\RedirectHandlerInterface; @@ -57,7 +57,7 @@ function it_returns_a_response_for_resource_show( $attributes->getBoolean('is_valid', true)->willReturn(true)->shouldBeCalled(); $attributes->get('form')->willReturn(null); - $resource = new Resource(alias: 'app.book', name: 'book'); + $resource = new ResourceMetadata(alias: 'app.book', name: 'book'); $operation = (new Show(template: 'book/show.html.twig'))->withResource($resource); $contextFactory->create($data, $operation, $context)->willReturn(['book' => $data]); @@ -83,7 +83,7 @@ function it_returns_a_response_for_resource_index( $attributes->getBoolean('is_valid', true)->willReturn(true)->shouldBeCalled(); $attributes->get('form')->willReturn(null); - $resource = new Resource(alias: 'app.book', pluralName: 'books'); + $resource = new ResourceMetadata(alias: 'app.book', pluralName: 'books'); $operation = (new Index(template: 'book/index.html.twig'))->withResource($resource); $contextFactory->create($data, $operation, $context)->willReturn(['books' => $data]); diff --git a/src/Component/spec/Symfony/Routing/Factory/DeleteOperationRoutePathFactorySpec.php b/src/Component/spec/Symfony/Routing/Factory/DeleteOperationRoutePathFactorySpec.php index ed5599857..540573f61 100644 --- a/src/Component/spec/Symfony/Routing/Factory/DeleteOperationRoutePathFactorySpec.php +++ b/src/Component/spec/Symfony/Routing/Factory/DeleteOperationRoutePathFactorySpec.php @@ -16,7 +16,7 @@ use PhpSpec\ObjectBehavior; use Sylius\Component\Resource\Metadata\Api; use Sylius\Component\Resource\Metadata\Delete; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Symfony\Routing\Factory\DeleteOperationRoutePathFactory; use Sylius\Component\Resource\Symfony\Routing\Factory\OperationRoutePathFactoryInterface; @@ -41,7 +41,7 @@ function it_generates_route_path_for_delete_operations(): void function it_generates_route_path_for_delete_operations_with_custom_identifier(): void { - $operation = (new Delete())->withResource(new Resource(identifier: 'code')); + $operation = (new Delete())->withResource(new ResourceMetadata(identifier: 'code')); $this->createRoutePath($operation, '/dummies')->shouldReturn('/dummies/{code}/delete'); } diff --git a/src/Component/spec/Symfony/Routing/Factory/OperationRouteFactorySpec.php b/src/Component/spec/Symfony/Routing/Factory/OperationRouteFactorySpec.php index ad58beddb..208425180 100644 --- a/src/Component/spec/Symfony/Routing/Factory/OperationRouteFactorySpec.php +++ b/src/Component/spec/Symfony/Routing/Factory/OperationRouteFactorySpec.php @@ -23,7 +23,7 @@ use Sylius\Component\Resource\Metadata\HttpOperation; use Sylius\Component\Resource\Metadata\Index; use Sylius\Component\Resource\Metadata\Metadata; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Show; use Sylius\Component\Resource\Metadata\Update; use Sylius\Component\Resource\Symfony\Routing\Factory\OperationRouteFactory; @@ -52,7 +52,7 @@ function it_generates_create_routes( $route = $this->create( $metadata, - new Resource('app.dummy'), + new ResourceMetadata('app.dummy'), $operation, ); @@ -77,7 +77,7 @@ function it_generates_index_routes( $route = $this->create( $metadata, - new Resource('app.dummy'), + new ResourceMetadata('app.dummy'), new Index(), ); @@ -102,7 +102,7 @@ function it_generates_show_routes( $route = $this->create( $metadata, - new Resource('app.dummy'), + new ResourceMetadata('app.dummy'), $operation, ); @@ -127,7 +127,7 @@ function it_generates_update_routes( $route = $this->create( $metadata, - new Resource('app.dummy'), + new ResourceMetadata('app.dummy'), $operation, ); @@ -152,7 +152,7 @@ function it_generates_delete_routes( $route = $this->create( $metadata, - new Resource('app.dummy'), + new ResourceMetadata('app.dummy'), $operation, ); @@ -177,7 +177,7 @@ function it_generates_bulk_delete_routes( $route = $this->create( $metadata, - new Resource('app.dummy'), + new ResourceMetadata('app.dummy'), $operation, ); @@ -202,7 +202,7 @@ function it_generates_bulk_update_routes( $route = $this->create( $metadata, - new Resource('app.dummy'), + new ResourceMetadata('app.dummy'), $operation, ); @@ -227,7 +227,7 @@ function it_generates_custom_operations_routes( $route = $this->create( $metadata, - new Resource('app.dummy'), + new ResourceMetadata('app.dummy'), $operation, ); @@ -252,7 +252,7 @@ function it_generates_routes_with_sections( $route = $this->create( $metadata, - new Resource(alias: 'app.dummy', section: 'admin'), + new ResourceMetadata(alias: 'app.dummy', section: 'admin'), $operation, ); @@ -278,7 +278,7 @@ function it_generates_routes_with_vars( $route = $this->create( $metadata, - new Resource(alias: 'app.dummy'), + new ResourceMetadata(alias: 'app.dummy'), $operation, ); diff --git a/src/Component/spec/Symfony/Routing/Factory/OperationRouteNameFactorySpec.php b/src/Component/spec/Symfony/Routing/Factory/OperationRouteNameFactorySpec.php index 6f8c4cd17..b8a52699c 100644 --- a/src/Component/spec/Symfony/Routing/Factory/OperationRouteNameFactorySpec.php +++ b/src/Component/spec/Symfony/Routing/Factory/OperationRouteNameFactorySpec.php @@ -15,7 +15,7 @@ use PhpSpec\ObjectBehavior; use Sylius\Component\Resource\Metadata\Create; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Symfony\Routing\Factory\OperationRouteNameFactory; final class OperationRouteNameFactorySpec extends ObjectBehavior @@ -27,7 +27,7 @@ function it_is_initializable(): void function it_create_a_route_name(): void { - $resource = new Resource(alias: 'app.book', name: 'book', applicationName: 'app'); + $resource = new ResourceMetadata(alias: 'app.book', name: 'book', applicationName: 'app'); $operation = (new Create())->withResource($resource); $this->createRouteName($operation)->shouldReturn('app_book_create'); @@ -35,7 +35,7 @@ function it_create_a_route_name(): void function it_create_a_route_name_with_a_section(): void { - $resource = new Resource(alias: 'app.book', section: 'admin', name: 'book', applicationName: 'app'); + $resource = new ResourceMetadata(alias: 'app.book', section: 'admin', name: 'book', applicationName: 'app'); $operation = (new Create())->withResource($resource); $this->createRouteName($operation)->shouldReturn('app_admin_book_create'); diff --git a/src/Component/spec/Symfony/Routing/Factory/ShowOperationRoutePathFactorySpec.php b/src/Component/spec/Symfony/Routing/Factory/ShowOperationRoutePathFactorySpec.php index c3d60e48a..4c6d33249 100644 --- a/src/Component/spec/Symfony/Routing/Factory/ShowOperationRoutePathFactorySpec.php +++ b/src/Component/spec/Symfony/Routing/Factory/ShowOperationRoutePathFactorySpec.php @@ -15,7 +15,7 @@ use PhpSpec\ObjectBehavior; use Sylius\Component\Resource\Metadata\Api; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Show; use Sylius\Component\Resource\Symfony\Routing\Factory\OperationRoutePathFactoryInterface; use Sylius\Component\Resource\Symfony\Routing\Factory\ShowOperationRoutePathFactory; @@ -41,7 +41,7 @@ function it_generates_route_path_for_show_operations(): void function it_generates_route_path_for_delete_operations_with_custom_identifier(): void { - $operation = (new Show())->withResource(new Resource(identifier: 'code')); + $operation = (new Show())->withResource(new ResourceMetadata(identifier: 'code')); $this->createRoutePath($operation, '/dummies')->shouldReturn('/dummies/{code}'); } diff --git a/src/Component/spec/Symfony/Routing/Factory/UpdateOperationRoutePathFactorySpec.php b/src/Component/spec/Symfony/Routing/Factory/UpdateOperationRoutePathFactorySpec.php index 384311cd6..7cc0230e7 100644 --- a/src/Component/spec/Symfony/Routing/Factory/UpdateOperationRoutePathFactorySpec.php +++ b/src/Component/spec/Symfony/Routing/Factory/UpdateOperationRoutePathFactorySpec.php @@ -15,7 +15,7 @@ use PhpSpec\ObjectBehavior; use Sylius\Component\Resource\Metadata\Api; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Update; use Sylius\Component\Resource\Symfony\Routing\Factory\OperationRoutePathFactoryInterface; use Sylius\Component\Resource\Symfony\Routing\Factory\UpdateOperationRoutePathFactory; @@ -41,7 +41,7 @@ function it_generates_route_path_for_update_operations(): void function it_generates_route_path_for_update_operations_with_custom_identifier(): void { - $operation = (new Update())->withResource(new Resource(identifier: 'code')); + $operation = (new Update())->withResource(new ResourceMetadata(identifier: 'code')); $this->createRoutePath($operation, '/dummies')->shouldReturn('/dummies/{code}/edit'); } diff --git a/src/Component/spec/Symfony/Routing/RedirectHandlerSpec.php b/src/Component/spec/Symfony/Routing/RedirectHandlerSpec.php index 2324ca146..471ae8ca6 100644 --- a/src/Component/spec/Symfony/Routing/RedirectHandlerSpec.php +++ b/src/Component/spec/Symfony/Routing/RedirectHandlerSpec.php @@ -18,7 +18,7 @@ use Sylius\Component\Resource\Metadata\BulkUpdate; use Sylius\Component\Resource\Metadata\Create; use Sylius\Component\Resource\Metadata\Delete; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Symfony\ExpressionLanguage\ArgumentParserInterface; use Sylius\Component\Resource\Symfony\Routing\Factory\OperationRouteNameFactoryInterface; use Sylius\Component\Resource\Symfony\Routing\RedirectHandler; @@ -51,7 +51,7 @@ function it_redirects_to_resource_with_id_argument_by_default( ): void { $data->id = 'xyz'; $operation = new Create(redirectToRoute: 'app_dummy_index'); - $resource = new Resource(alias: 'app.book'); + $resource = new ResourceMetadata(alias: 'app.book'); $operation = $operation->withResource($resource); $router->generate('app_dummy_index', ['id' => 'xyz'])->willReturn('/dummies')->shouldBeCalled(); @@ -66,7 +66,7 @@ function it_redirects_to_resource_with_custom_identifier_argument_by_default( ): void { $data->code = 'xyz'; $operation = new Create(redirectToRoute: 'app_dummy_index'); - $resource = new Resource(alias: 'app.ok', identifier: 'code'); + $resource = new ResourceMetadata(alias: 'app.ok', identifier: 'code'); $operation = $operation->withResource($resource); $router->generate('app_dummy_index', ['code' => 'xyz'])->willReturn('/dummies')->shouldBeCalled(); @@ -80,7 +80,7 @@ function it_redirects_to_resource_with_id_via_property_access( ): void { $data = new BoardGameResource('uid'); $operation = new Create(redirectToRoute: 'app_board_game_index'); - $resource = new Resource(alias: 'app.board_game'); + $resource = new ResourceMetadata(alias: 'app.board_game'); $operation = $operation->withResource($resource); $router->generate('app_board_game_index', ['id' => 'uid'])->willReturn('/board-games')->shouldBeCalled(); @@ -95,7 +95,7 @@ function it_redirects_to_resource_with_custom_arguments( ): void { $data->code = 'xyz'; $operation = new Create(redirectToRoute: 'app_dummy_index', redirectArguments: ['code' => 'resource.code']); - $resource = new Resource(alias: 'app.book'); + $resource = new ResourceMetadata(alias: 'app.book'); $operation = $operation->withResource($resource); $router->generate('app_dummy_index', ['code' => 'xyz'])->willReturn('/dummies')->shouldBeCalled(); @@ -110,7 +110,7 @@ function it_redirects_to_resource_with_id_via_the_getter( ): void { $data = new BoardGameResource('uid'); $operation = new Create(redirectToRoute: 'app_board_game_index', redirectArguments: ['id' => 'resource.id()']); - $resource = new Resource(alias: 'app.board_game'); + $resource = new ResourceMetadata(alias: 'app.board_game'); $operation = $operation->withResource($resource); $argumentParser->parseExpression('resource.id()', ['resource' => $data])->willReturn('uid'); @@ -127,7 +127,7 @@ function it_redirects_to_resource_without_arguments_after_delete_operation_by_de ): void { $data->id = 'xyz'; $operation = new Delete(redirectToRoute: 'app_dummy_index'); - $resource = new Resource(alias: 'app.book'); + $resource = new ResourceMetadata(alias: 'app.book'); $operation = $operation->withResource($resource); $router->generate('app_dummy_index', [])->willReturn('/dummies')->shouldBeCalled(); @@ -142,7 +142,7 @@ function it_redirects_to_resource_without_arguments_after_bulk_operation_by_defa ): void { $data->id = 'xyz'; $operation = new BulkUpdate(redirectToRoute: 'app_dummy_index'); - $resource = new Resource(alias: 'app.book'); + $resource = new ResourceMetadata(alias: 'app.book'); $operation = $operation->withResource($resource); $router->generate('app_dummy_index', [])->willReturn('/dummies')->shouldBeCalled(); diff --git a/src/Component/spec/Symfony/Session/Flash/FlashHelperSpec.php b/src/Component/spec/Symfony/Session/Flash/FlashHelperSpec.php index d17224d7d..5a5b77b3c 100644 --- a/src/Component/spec/Symfony/Session/Flash/FlashHelperSpec.php +++ b/src/Component/spec/Symfony/Session/Flash/FlashHelperSpec.php @@ -19,7 +19,7 @@ use Sylius\Component\Resource\Context\Option\RequestOption; use Sylius\Component\Resource\Metadata\BulkDelete; use Sylius\Component\Resource\Metadata\Create; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Symfony\EventDispatcher\GenericEvent; use Sylius\Component\Resource\Symfony\Session\Flash\FlashHelper; use Symfony\Component\HttpFoundation\Request; @@ -48,7 +48,7 @@ function it_adds_success_flashes_with_specific_message( TranslatorBagInterface $translator, MessageCatalogueInterface $messageCatalogue, ): void { - $operation = (new Create())->withResource(new Resource(alias: 'app.dummy', name: 'dummy', applicationName: 'app')); + $operation = (new Create())->withResource(new ResourceMetadata(alias: 'app.dummy', name: 'dummy', applicationName: 'app')); $context = new Context(new RequestOption($request->getWrappedObject())); $request->getSession()->willReturn($session); @@ -73,7 +73,7 @@ function it_adds_success_flashes_with_fallback_message( TranslatorBagInterface $translator, MessageCatalogueInterface $messageCatalogue, ): void { - $operation = (new Create())->withResource(new Resource(alias: 'app.dummy', name: 'dummy', applicationName: 'app')); + $operation = (new Create())->withResource(new ResourceMetadata(alias: 'app.dummy', name: 'dummy', applicationName: 'app')); $context = new Context(new RequestOption($request->getWrappedObject())); $request->getSession()->willReturn($session); @@ -97,7 +97,7 @@ function it_adds_success_flashes_with_default_message_when_translator_is_not_a_b FlashBagInterface $flashBag, TranslatorInterface $translator, ): void { - $operation = (new Create())->withResource(new Resource(alias: 'app.dummy', name: 'dummy', applicationName: 'app')); + $operation = (new Create())->withResource(new ResourceMetadata(alias: 'app.dummy', name: 'dummy', applicationName: 'app')); $context = new Context(new RequestOption($request->getWrappedObject())); $request->getSession()->willReturn($session); @@ -118,7 +118,7 @@ function it_adds_success_flashes_with_humanized_message( TranslatorBagInterface $translator, MessageCatalogueInterface $messageCatalogue, ): void { - $operation = (new Create())->withResource(new Resource(alias: 'app.dummy', name: 'admin_user', applicationName: 'app')); + $operation = (new Create())->withResource(new ResourceMetadata(alias: 'app.dummy', name: 'admin_user', applicationName: 'app')); $context = new Context(new RequestOption($request->getWrappedObject())); $request->getSession()->willReturn($session); @@ -143,7 +143,7 @@ function it_adds_success_flashes_with_humanized_message_and_plural_name_on_bulk_ TranslatorBagInterface $translator, MessageCatalogueInterface $messageCatalogue, ): void { - $operation = (new BulkDelete())->withResource(new Resource(alias: 'app.dummy', name: 'admin_user', pluralName: 'admin_users', applicationName: 'app')); + $operation = (new BulkDelete())->withResource(new ResourceMetadata(alias: 'app.dummy', name: 'admin_user', pluralName: 'admin_users', applicationName: 'app')); $context = new Context(new RequestOption($request->getWrappedObject())); $request->getSession()->willReturn($session); diff --git a/src/Component/spec/Twig/Context/Factory/DefaultContextFactorySpec.php b/src/Component/spec/Twig/Context/Factory/DefaultContextFactorySpec.php index c78d225b4..37965e8b0 100644 --- a/src/Component/spec/Twig/Context/Factory/DefaultContextFactorySpec.php +++ b/src/Component/spec/Twig/Context/Factory/DefaultContextFactorySpec.php @@ -16,7 +16,7 @@ use PhpSpec\ObjectBehavior; use Sylius\Component\Resource\Context\Context; use Sylius\Component\Resource\Metadata\Index; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Show; use Sylius\Component\Resource\Twig\Context\Factory\DefaultContextFactory; @@ -30,7 +30,7 @@ function it_is_initializable(): void function it_creates_twig_context_for_resource( \stdClass $data, ): void { - $operation = (new Show())->withResource(new Resource(alias: 'app.dummy', name: 'dummy')); + $operation = (new Show())->withResource(new ResourceMetadata(alias: 'app.dummy', name: 'dummy')); $this->create($data, $operation, new Context())->shouldReturn([ 'operation' => $operation, @@ -42,7 +42,7 @@ function it_creates_twig_context_for_resource( function it_creates_twig_context_for_resource_collection( \stdClass $data, ): void { - $operation = (new Index())->withResource(new Resource(alias: 'app.dummy', pluralName: 'dummies')); + $operation = (new Index())->withResource(new ResourceMetadata(alias: 'app.dummy', pluralName: 'dummies')); $this->create($data, $operation, new Context())->shouldReturn([ 'operation' => $operation, diff --git a/tests/Application/src/BoardGameBlog/Infrastructure/Sylius/Resource/BoardGameResource.php b/tests/Application/src/BoardGameBlog/Infrastructure/Sylius/Resource/BoardGameResource.php index cf89ba4bd..6b85ddcb7 100644 --- a/tests/Application/src/BoardGameBlog/Infrastructure/Sylius/Resource/BoardGameResource.php +++ b/tests/Application/src/BoardGameBlog/Infrastructure/Sylius/Resource/BoardGameResource.php @@ -20,17 +20,17 @@ use App\BoardGameBlog\Infrastructure\Sylius\State\Http\Provider\BoardGameCollectionProvider; use App\BoardGameBlog\Infrastructure\Sylius\State\Http\Provider\BoardGameItemProvider; use App\BoardGameBlog\Infrastructure\Symfony\Form\Type\BoardGameType; +use Sylius\Component\Resource\Metadata\AsResource; use Sylius\Component\Resource\Metadata\Create; use Sylius\Component\Resource\Metadata\Delete; use Sylius\Component\Resource\Metadata\Index; -use Sylius\Component\Resource\Metadata\Resource; use Sylius\Component\Resource\Metadata\Show; use Sylius\Component\Resource\Metadata\Update; use Sylius\Component\Resource\Model\ResourceInterface; use Symfony\Component\Uid\AbstractUid; use Symfony\Component\Validator\Constraints as Assert; -#[Resource( +#[AsResource( alias: 'app.board_game', section: 'admin', formType: BoardGameType::class, diff --git a/tests/Application/src/Subscription/Entity/Subscription.php b/tests/Application/src/Subscription/Entity/Subscription.php index 7f9d6b8c7..e9a2cf744 100644 --- a/tests/Application/src/Subscription/Entity/Subscription.php +++ b/tests/Application/src/Subscription/Entity/Subscription.php @@ -18,19 +18,19 @@ use Doctrine\ORM\Mapping as ORM; use Sylius\Component\Resource\Metadata\Api; use Sylius\Component\Resource\Metadata\ApplyStateMachineTransition; +use Sylius\Component\Resource\Metadata\AsResource; use Sylius\Component\Resource\Metadata\BulkDelete; use Sylius\Component\Resource\Metadata\BulkUpdate; use Sylius\Component\Resource\Metadata\Create; use Sylius\Component\Resource\Metadata\Delete; use Sylius\Component\Resource\Metadata\Index; -use Sylius\Component\Resource\Metadata\Resource; use Sylius\Component\Resource\Metadata\Show; use Sylius\Component\Resource\Metadata\Update; use Sylius\Component\Resource\Model\ResourceInterface; use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Validator\Constraints as Assert; -#[Resource( +#[AsResource( section: 'admin', formType: SubscriptionType::class, templatesDir: 'crud', @@ -52,7 +52,7 @@ twigContextFactory: ShowSubscriptionContextFactory::class, )] -#[Resource( +#[AsResource( alias: 'app.subscription', section: 'ajax', routePrefix: '/ajax', diff --git a/tests/Bundle/Command/DebugResourceCommandTest.php b/tests/Bundle/Command/DebugResourceCommandTest.php index a3d251171..ec84b8a41 100644 --- a/tests/Bundle/Command/DebugResourceCommandTest.php +++ b/tests/Bundle/Command/DebugResourceCommandTest.php @@ -23,7 +23,7 @@ use Sylius\Component\Resource\Metadata\MetadataInterface; use Sylius\Component\Resource\Metadata\Operations; use Sylius\Component\Resource\Metadata\RegistryInterface; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\ResourceMetadata; use Sylius\Component\Resource\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; use Sylius\Component\Resource\Metadata\Resource\ResourceMetadataCollection; use Symfony\Component\Console\Tester\CommandTester; @@ -100,7 +100,7 @@ public function it_displays_the_metadata_for_given_resource_alias_with_operation { $this->registry->get('metadata.one')->willReturn($this->createMetadata('one')); - $resourceMetadata = (new Resource())->withOperations(new Operations([ + $resourceMetadata = (new ResourceMetadata())->withOperations(new Operations([ 'app_one_index' => new Index(name: 'app_one_index', provider: 'App\GetOneItemProvider'), 'app_one_create' => new Create(name: 'app_one_create', processor: 'App\CreateOneProcessor'), ])); @@ -188,7 +188,7 @@ public function it_displays_the_metadata_for_given_resource_as_fully_qualified_c { $this->registry->getByClass('App\Resource')->willReturn($this->createMetadata('one')); - $resourceMetadata = (new Resource(alias: 'sylius.one'))->withOperations(new Operations([ + $resourceMetadata = (new ResourceMetadata(alias: 'sylius.one'))->withOperations(new Operations([ 'app_one_index' => new Index(name: 'app_one_index', provider: 'App\GetOneItemProvider'), 'app_one_create' => new Create(name: 'app_one_create', processor: 'App\CreateOneProcessor'), ])); @@ -276,7 +276,7 @@ public function it_displays_the_metadata_for_given_resource_operation(): void { $this->registry->get('metadata.one')->willReturn($this->createMetadata('one')); - $resourceMetadata = (new Resource(alias: 'sylius.one'))->withOperations(new Operations([ + $resourceMetadata = (new ResourceMetadata(alias: 'sylius.one'))->withOperations(new Operations([ 'app_one_index' => new Index(name: 'app_one_index', provider: 'App\GetOneItemProvider'), 'app_one_create' => new Create( template: 'register.html.twig', diff --git a/tests/Bundle/DependencyInjection/Dummy/BookWithAliasResource.php b/tests/Bundle/DependencyInjection/Dummy/BookWithAliasResource.php index f743ed67f..bd5588dd4 100644 --- a/tests/Bundle/DependencyInjection/Dummy/BookWithAliasResource.php +++ b/tests/Bundle/DependencyInjection/Dummy/BookWithAliasResource.php @@ -13,9 +13,9 @@ namespace Sylius\Bundle\ResourceBundle\Tests\DependencyInjection\Dummy; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\AsResource; -#[Resource(alias: 'app.book')] +#[AsResource(alias: 'app.book')] final class BookWithAliasResource { } diff --git a/tests/Bundle/DependencyInjection/Dummy/DummyResource.php b/tests/Bundle/DependencyInjection/Dummy/DummyResource.php index 1a2f54217..703947206 100644 --- a/tests/Bundle/DependencyInjection/Dummy/DummyResource.php +++ b/tests/Bundle/DependencyInjection/Dummy/DummyResource.php @@ -13,9 +13,9 @@ namespace Sylius\Bundle\ResourceBundle\Tests\DependencyInjection\Dummy; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\AsResource; -#[Resource] +#[AsResource] final class DummyResource { } diff --git a/tests/Bundle/DependencyInjection/Dummy/NoDriverResource.php b/tests/Bundle/DependencyInjection/Dummy/NoDriverResource.php index 05d3f1743..bb90465d7 100644 --- a/tests/Bundle/DependencyInjection/Dummy/NoDriverResource.php +++ b/tests/Bundle/DependencyInjection/Dummy/NoDriverResource.php @@ -13,9 +13,9 @@ namespace Sylius\Bundle\ResourceBundle\Tests\DependencyInjection\Dummy; -use Sylius\Component\Resource\Metadata\Resource; +use Sylius\Component\Resource\Metadata\AsResource; -#[Resource(driver: false)] +#[AsResource(driver: false)] final class NoDriverResource { }