Skip to content

New resource loader#997

Merged
GSadee merged 11 commits into
1.13from
new-resource-loader
Mar 13, 2025
Merged

New resource loader#997
GSadee merged 11 commits into
1.13from
new-resource-loader

Conversation

@loic425

@loic425 loic425 commented Mar 7, 2025

Copy link
Copy Markdown
Member
Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Related tickets
License MIT

This work have ben reviewed via multiple PRs.
#985
#986
#987

It reworks the routing system to allow more routing system than the attributes one in the near future.

loic425 and others added 9 commits February 20, 2025 09:44
| Q               | A
| --------------- | -----
| Bug fix?        | no
| New feature?    | yes
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | 
| License         | MIT

The idea of this collection is to have a collection of resource names
(that will be class names inside, but I want it to be more generic if
needed later).

It will be used in a new resource loader (for Routing) which will be
used instead of this [too much specific
one](https://github.com/Sylius/SyliusResourceBundle/blob/1.13/src/Bundle/Routing/RoutesAttributesLoader.php).

It will allow to create route collection for all resources that have new
resource metadata.

```php
# config/sylius/resources/speaker.php

use App\Conference\Entity\Speaker;
use Sylius\Resource\Metadata\Create;
use Sylius\Resource\Metadata\Index;
use Sylius\Resource\Metadata\Operations;
use Sylius\Resource\Metadata\ResourceMetadata;

return (new ResourceMetadata())
    ->withRoutePrefix('/admin')
    ->withClass(Speaker::class)
    ->withSection('admin')
    ->withTemplatesDir('crud')
    ->withOperations(new Operations([
        new Create(),
        new Index(),
    ]))
;
```

I've created a specific new-resource-loader branch to allow us to merge
it quicky in a WIP mode.
Co-authored-by: Dmitri Perunov <diimpp@gmail.com>
| Q               | A
| --------------- | -----
| Bug fix?        | no
| New feature?    | yes
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | 
| License         | MIT

Based on #985
Co-authored-by: Dmitri Perunov <diimpp@gmail.com>
| Q               | A
| --------------- | -----
| Bug fix?        | no
| New feature?    | yes
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | 
| License         | MIT
@GSadee GSadee added the Feature New feature proposals. label Mar 12, 2025
</argument>
<argument>%kernel.environment%</argument>
<tag name="routing.loader" />
<deprecated package="sylius/resource" version="1.13">The "%service_id%" service is deprecated since sylius/resource-bundle 1.13 and will be removed in sylius/resource-bundle 2.0. Use "sylius_resource.symfony.routing.loader.resource" instead.</deprecated>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no such a service: sylius_resource.symfony.routing.loader.resource 🤔

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed, well observed.

Comment on lines +27 to +29
/**
* @param array{paths: string[]} $mapping
*/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can be in one line, similar as other doc blocks

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

Comment on lines +33 to +35
private OperationRouteFactoryInterface $operationRouteFactory,
private ResourceMetadataCollectionFactoryInterface $resourceMetadataFactory,
private RegistryInterface $resourceRegistry,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They can be readonly

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed.

@loic425

loic425 commented Mar 12, 2025

Copy link
Copy Markdown
Member Author

@GSadee thx for the review, I will fix that in one hour. This one is one of the most important for me to continue my work on external PHP file support.

Comment thread src/Component/src/Symfony/Routing/Loader/ResourceLoader.php Outdated
@loic425 loic425 force-pushed the new-resource-loader branch 2 times, most recently from 2549c7f to efe57d1 Compare March 12, 2025 13:42
Co-authored-by: Jan Góralski <jan.wojciech.goralski@gmail.com>
@loic425 loic425 force-pushed the new-resource-loader branch from efe57d1 to 2fa38d2 Compare March 12, 2025 13:44
@GSadee GSadee merged commit 4296466 into 1.13 Mar 13, 2025
@GSadee GSadee deleted the new-resource-loader branch March 13, 2025 05:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature New feature proposals.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants