In Symfony3.4, the following error occurred while supporting automatic wiring.
The following error occurs even if the container is removed, just changing the class.
I changed the controller to an abstract controller due to another error, so I want to use the abstract controller as much as possible.
Is there anything I have forgotten?
https://symfony.com/doc/3.4/service_container/3.3-di-changes.html
Error
Attempted to call an undefined method named "getParameter" of class "Symfony\Component\DependencyInjection\ServiceLocator".
Controller.php
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
class DefaultController extends AbstractController
{
/**
* @param KeepRequestService $keepRequestService
* @return array
*/
private function getKeepRequestSummary(KeepRequestService $keepRequestService): array
{
$summary = array();
//Error line
foreach (array_keys($this->container->getParameter('keep_request_status')) as $status) {
$params = array('status' => $status);
$summary[$status] = $keepRequestService->countKeepRequestBySearchParams($params);
}
return $summary;
}
services.yml
_defaults:
autowire: true
autoconfigure: true
public: false
App\:
resource: '../../src/*'
exclude: '../../src/{Ahi/Sp/AdminBundle/Model/Entity, Ahi/Sp/AdminBundle/Model/Repository, Ahi/Sp/AdminBundle/Resources/public/uploadify, Ahi/Sp/AdminBundle/Ahi/Sp/PublicBundle/ }'
App\Ahi\Sp\AdminBundle\Controller\:
resource: '../../src/Ahi/Sp/AdminBundle/Controller'
public: true
tags: ['controller.service_arguments']