-
-
Notifications
You must be signed in to change notification settings - Fork 159
Use plural name from new resource metadata #999
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 1.13
Are you sure you want to change the base?
Use plural name from new resource metadata #999
Conversation
e82e959
to
899baef
Compare
899baef
to
feb8279
Compare
if (null === $resource->getPluralName()) { | ||
$resourcePluralName = $resourceConfiguration->getPluralName(); | ||
|
||
$resource = $resource->withPluralName($resourcePluralName); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be optimized a little.
if (null === $resource->getPluralName()) { | |
$resourcePluralName = $resourceConfiguration->getPluralName(); | |
$resource = $resource->withPluralName($resourcePluralName); | |
} | |
if (null === $resource->getPluralName()) { | |
$resource = $resource->withPluralName( | |
$resourceConfiguration->getPluralName() | |
); | |
} |
@@ -143,20 +149,6 @@ private function getOperationWithDefaults(ResourceMetadata $resource, Operation | |||
|
|||
$operation = $operation->withResource($resource); | |||
|
|||
if (null === $resource->getName()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A question about line of code above this code.
$resourceConfiguration = $this->resourceRegistry->get($resource->getAlias() ?? '');
We probably should assert it as Assert::notNull($resource->getAlias());
as was in some other PR/code.
$operation = $operation->withResource($resource); | ||
} | ||
|
||
if (null === $resource->getPluralName()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess plural name is set somehow else, so this code is removed, but I don't fully understand how or where.
This PR will need to be refactored after #984 merge. |
It replaces #998
For now, we have two very similar metadata classes for the resource.
To calculate the route path, we use the plural name from the Metadata (the legacy one), but we can define the plural name on the ResourceMetadata.
Before this implementation, the plural name was calculated by the inflector on the MetadataClass.
With this current PR, by default, it will continue to use the plural name from the inflector (from the Medadata class), but it will use the custom one if defined. It was intended to be the case with the previous implementation, but there was an issue and the operation route factory was using the automatic plural name only.
The other plan behind is also to prepare the legacy Metadata class removal at some point.
We will be able to move the automatic plural name on the getResourceDefaults method.