You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if i construct two 'resource' without a prefix, then the route may incorrect. because the route name of the resource is conflict. This situation is likely to occur when i making restful design. for example:
i design three restful api:
GET http://www.***.com/users/{user_id}/ordersquery all orders of user {user_id}
GET http://www.***.com/orders/{order_id}query orders of {order_id}
GET http://www.***.com/orders/query all orders
these api may designed in the some Controller and Resource, named OrderController and OrderResource.
but i can't give a prefix in the OrderResource created place.
i can only give a full path in the Endpoints created place. for example:
protected function createRouteName(ApiEndpoint $endpoint)
{
return serialize([
'collection' => $this->getIdentifier(),
'endpoint' => $endpoint->getIdentifier()
]);
}
public function getIdentifier()
{
return $this->getPrefix();
}
so i recommend that we can replace the getIdentifier() as follows:
public function getIdentifier()
{
return static::class . '/' . $this->getPrefix();
}
The text was updated successfully, but these errors were encountered:
if i construct two 'resource' without a prefix, then the route may incorrect. because the route name of the resource is conflict. This situation is likely to occur when i making restful design. for example:
i design three restful api:
GET http://www.***.com/users/{user_id}/orders query all orders of user {user_id}
GET http://www.***.com/orders/{order_id} query orders of {order_id}
GET http://www.***.com/orders/ query all orders
these api may designed in the some Controller and Resource, named OrderController and OrderResource.
but i can't give a prefix in the OrderResource created place.
i can only give a full path in the Endpoints created place. for example:
->handler(OrderController ::class)
->endpoint(ApiEndpoint::get('/users/{user_id}/orders', 'allOfUser'))
->endpoint(ApiEndpoint::get('/orders/{order_id} ', 'find'))
->endpoint(ApiEndpoint::get('/orders', 'all'))
the code in PhalconRest\Api\ApiCollection:
protected function createRouteName(ApiEndpoint $endpoint)
{
return serialize([
'collection' => $this->getIdentifier(),
'endpoint' => $endpoint->getIdentifier()
]);
}
public function getIdentifier()
{
return $this->getPrefix();
}
so i recommend that we can replace the getIdentifier() as follows:
public function getIdentifier()
{
return static::class . '/' . $this->getPrefix();
}
The text was updated successfully, but these errors were encountered: