如何在symfony 4中使用liipimagineBundle的filterService

时间:2018-12-26 15:44:51

标签: autowired symfony4 liipimaginebundle

我已经将捆绑包LiipImageBundle与symfony3一起使用了,但是我再也无法通过symfony4来使用它了

我想在控制器中使用捆绑软件的filterService服务,所以我做了:

/** @var FilterService */
$imagine = $this->container
                ->get('liip_imagine.service.filter');


   $ori = 'public/uploads/images/'.$fileName;
   $resPath_150x150 = $imagine->getUrlOfFilteredImage($ori, 'filter_150x150');

但是我有这个错误:

 Service "liip_imagine.service.filter" not found: even though it exists in the app's container, the container inside "App\Controller\ProduitController" is a smaller service locator that only knows about the "doctrine", "form.factory", "http_kernel", "parameter_bag", "request_stack", "router", "security.authorization_checker", "security.csrf.token_manager", "security.token_storage", "serializer", "session", "templating" and "twig" services. Unless you need extra laziness, try using dependency injection instead. Otherwise, you need to declare it using "ProduitController::getSubscribedServices()".

我该如何解决?

0 个答案:

没有答案