Skip to content

Init resource class list factory with attributes#986

Merged
loic425 merged 2 commits into
Sylius:new-resource-loaderfrom
loic425:feature/resource-name-factory
Feb 25, 2025
Merged

Init resource class list factory with attributes#986
loic425 merged 2 commits into
Sylius:new-resource-loaderfrom
loic425:feature/resource-name-factory

Conversation

@loic425

@loic425 loic425 commented Feb 20, 2025

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

Based on #985

@loic425 loic425 force-pushed the feature/resource-name-factory branch from cb727cd to 59ffdae Compare February 20, 2025 13:26
@loic425 loic425 self-assigned this Feb 21, 2025
@loic425 loic425 force-pushed the feature/resource-name-factory branch from 59ffdae to beb7ae6 Compare February 24, 2025 14:23

declare(strict_types=1);

namespace Sylius\Resource\Metadata\Resource\Factory;

@loic425 loic425 Feb 24, 2025

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.

I think it will be better like this

Suggested change
namespace Sylius\Resource\Metadata\Resource\Factory;
namespace Sylius\Resource\Metadata\Resource\NameCollection\Factory;

WDYT @diimpp?

@loic425 loic425 Feb 24, 2025

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.

But in this, case we should move The ResourceNameCollection too, and moved all the service related to MetadataCollection factories in another namespace too.
I have an issue, cause I forgot some "Experimental" tags and then we need class and interface aliases for that. So maybe we could keep this coherent.

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.

Discussed in slack; Since NameCollection is just a VO, then extensive namespacing is not needed and current one looks good enough.


declare(strict_types=1);

namespace Sylius\Resource\Metadata\Resource\Factory;

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.

Discussed in slack; Since NameCollection is just a VO, then extensive namespacing is not needed and current one looks good enough.

Comment thread src/Bundle/Resources/config/services/metadata.xml
<service id="sylius_resource.metadata.resource.name_collection.factory" alias="sylius_resource.metadata.resource.name_collection.factory.attributes" />
<service id="Sylius\Resource\Metadata\Resource\Factory\ResourceNameCollectionFactoryInterface" alias="sylius_resource.metadata.resource.name_collection.factory" />

<service id="sylius_resource.metadata.resource.name_collection.factory.attributes"

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.

Naming should match existing IDs.

Example

sylius.resource_metadata_collection.factory.attributes
Suggested change
<service id="sylius_resource.metadata.resource.name_collection.factory.attributes"
<service id="sylius.resource_name_collection.factory.attributes"

@loic425 loic425 Feb 24, 2025

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.

So you prefer we change all the service ids in 2.0 than start using the new naming for the new service ids?

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.

@loic425 yes, but it's more about consistency -- two files in same directory shouldn't have different ID naming scheme.

So I guess sylius_resource.*** can be left for 2.0.

@loic425 loic425 force-pushed the feature/resource-name-factory branch 2 times, most recently from 9258717 to a0e8aac Compare February 25, 2025 08:13
@loic425 loic425 force-pushed the feature/resource-name-factory branch from a0e8aac to a866510 Compare February 25, 2025 08:18
@loic425

loic425 commented Feb 25, 2025

Copy link
Copy Markdown
Member Author

Interesting discussions there
api-platform/core#6943

But we are in a specific branch and also everything are tagged as experimental here, so we can adjust later.

Comment thread src/Component/src/Metadata/Resource/Factory/ResourceClassListFactoryInterface.php Outdated
final class ResourceClassList implements \IteratorAggregate, \Countable
{
/**
* @param string[] $names

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.

---     public function __construct(private readonly array $names = [])
+++     public function __construct(private readonly array $classNames = [])
+++     public function __construct(private readonly array $classes = [])

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.

src/Component/src/Metadata/Resource/Factory/AttributesResourceClassListFactory.php uses $classes internally, so I guess it should be preferred.

Comment thread src/Component/tests/Metadata/Resource/ResourceClassListTest.php Outdated
Comment thread src/Component/tests/Metadata/Resource/ResourceClassListTest.php Outdated
Comment thread src/Component/tests/Metadata/Resource/ResourceClassListTest.php Outdated
@diimpp diimpp changed the title Init resource name collection factory with attributes Init resource class list factory with attributes Feb 25, 2025
@loic425 loic425 force-pushed the feature/resource-name-factory branch 2 times, most recently from cbffe74 to cfffa21 Compare February 25, 2025 14:42
Co-authored-by: Dmitri Perunov <diimpp@gmail.com>
@loic425 loic425 force-pushed the feature/resource-name-factory branch from cfffa21 to 7bc5c10 Compare February 25, 2025 15:01
@loic425 loic425 merged commit c98f1a3 into Sylius:new-resource-loader Feb 25, 2025
@loic425 loic425 deleted the feature/resource-name-factory branch February 25, 2025 15:20
@loic425 loic425 mentioned this pull request Mar 7, 2025
GSadee added a commit that referenced this pull request Mar 13, 2025
| 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.
GSadee added a commit to Sylius/Resource that referenced this pull request May 28, 2025
| 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.
Sylius/SyliusResourceBundle#985
Sylius/SyliusResourceBundle#986
Sylius/SyliusResourceBundle#987

It reworks the routing system to allow more routing system than the
attributes one in the near future.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants