Skip to content

Commit

Permalink
Use AsResource attribute instead of reserved word Resource
Browse files Browse the repository at this point in the history
  • Loading branch information
loic425 committed Oct 20, 2023
1 parent b8438f0 commit cc994cf
Show file tree
Hide file tree
Showing 77 changed files with 304 additions and 250 deletions.
62 changes: 31 additions & 31 deletions docs/configure_your_operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
Expand Down Expand Up @@ -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
{
Expand All @@ -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
{
Expand All @@ -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
{
Expand Down Expand Up @@ -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
{
Expand All @@ -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
{
Expand All @@ -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
{
Expand All @@ -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]
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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
{
Expand Down
16 changes: 8 additions & 8 deletions docs/configure_your_resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
}
Expand Down Expand Up @@ -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
{
}
Expand All @@ -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
{
}
Expand All @@ -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
{
}
Expand Down
6 changes: 3 additions & 3 deletions docs/redirect.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down
16 changes: 8 additions & 8 deletions docs/resource_factories.md
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand All @@ -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
Expand Down Expand Up @@ -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'],
)]
Expand Down
4 changes: 2 additions & 2 deletions docs/responders.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/Bundle/Command/DebugResourceCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions src/Bundle/DependencyInjection/SyliusResourceExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Loading

0 comments on commit cc994cf

Please sign in to comment.