We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
itemOperations.get
Can someone help me to override GET method with default path.
GET
What I need: GET /api/content_pages/{id} should use my custom controller, where I need to return result using header Accept-Language
/api/content_pages/{id}
Accept-Language
// config/api/content_page.yaml resources: Api\Entity\ContentPage: itemOperations: get: route_name: 'get_content_page' methods: ['GET'] normalization_context: groups: ['v1_get_item'] swagger_context: parameters: - name: id in: path required: true type: string description: "Content page identifier"
// config/routes.yaml get_content_page: path: /content_pages/{id} methods: ['GET'] condition: "request.headers.get('Accept-Language') matches '/^[a-z]{2}-[A-Z]{2}$/i'" defaults: _controller: Api\Controller\ContentPagesController::getContentPage _api_resource_class: Api\Entity\ContentPage _api_item_operation_name: get
?php // src/Controller/ContentPagesController.php namespace Api\Controller; use Api\Entity\ContentPage; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; class ContentPagesController extends AbstractController { /** * @param Request $request * @param string $id * @return ContentPage */ public function getContentPage(Request $request, string $id): ContentPage { dd($request->headers->get('Accept-Language')); } }
I'm getting No route found for \"GET \/content_pages\/about\": Method Not Allowed (Allow: PUT, DELETE)
No route found for \"GET \/content_pages\/about\": Method Not Allowed (Allow: PUT, DELETE)
If, I do next change:
// config/api/content_page.yaml resources: Api\Entity\ContentPage: itemOperations: get: ~ get_item: route_name: 'get_content_page' methods: ['GET'] normalization_context: groups: ['v1_get_item'] swagger_context: parameters: - name: id in: path required: true type: string description: "Content page identifier"
I get Invalid identifier value or configuration.
Invalid identifier value or configuration.
The text was updated successfully, but these errors were encountered:
Problem was in condition: "request.headers.get('Accept-Language') matches '/^[a-z]{2}-[A-Z]{2}$/i'" .... trying to figure out solution...
condition: "request.headers.get('Accept-Language') matches '/^[a-z]{2}-[A-Z]{2}$/i'"
Sorry, something went wrong.
No branches or pull requests
Can someone help me to override
GET
method with default path.What I need:
GET
/api/content_pages/{id}
should use my custom controller, where I need to return result using headerAccept-Language
I'm getting
No route found for \"GET \/content_pages\/about\": Method Not Allowed (Allow: PUT, DELETE)
If, I do next change:
I get
Invalid identifier value or configuration.
The text was updated successfully, but these errors were encountered: