Parent class:
abstract class AbstractObjectRestController extends FOSRestController {
/**
*
* @param ParamFetcher $params
* @return FOSRestBundleViewView
*/
public function cgetAction(ParamFetcher $params)
{
// Get DB data and return View
}
}
Child class:
/**
* Class RoleRestController
* @package AbstratUsersBundleController
* @RESTRouteResource("Roles")
*/
class CertificateRestController extends AbstractObjectRestController {
/**
*
* @RESTPost("/certificates/download/{certificateId}")
* @throws Exception
*/
public function downloadAction(Request $request, $certificateId)
{
}
}
php bin/console debug:router
app_certificate_certificaterest_download POST ANY ANY /certificates/download/{certificateId} AppControllerCertificateCertificateRestController::downloadAction()
The problem is that even though CertificateRestController is extending AbstractObjectRestController and routes defined within CertificateRestController are showing, none of the routes from the parent class (AbstractObjectRestController) are being registered
config/services.yml:
parameters:
services:
# default configuration for services in *this* file
_defaults:
autowire: true
autoconfigure: true
public: false
AppController:
resource: '../src/Controller'
tags: [ 'controller.service_arguments' ]
# Data fixtures
AppDataFixtures:
resource: '../src/DataFixtures'
tags: [ 'doctrine.fixture.orm' ]
config/routes.yml:
Users:
type : rest
resource: "@Usersbundle/Resources/config/routing.yml"
OAuth:
type : rest
resource: "@OauthBundle/Resources/config/routing.yml"
The strange thing is that the UsersBundle and OauthBundle both have rest controllers which extend AbstractObjectRestController (mentioned above) and the cgetAction method is being registered against those
Source: Symfony4 Questions
Was this helpful?
0 / 0