LuisF
LuisF

Reputation: 564

FilterService Liip Imagine Bundle

I'm trying to inject the FilterService into a constructor in order to be able to call getUrlOfFilteredImage.

However, I'm getting the following error:

Cannot autowire service "App\Bll\PhotoService": argument "$filterService" of method "__construct()" references class "Liip\ImagineBundle\Service\FilterService" but no such service exists. You should maybe alias this class to the existing "liip_imagine.service.filter" service.

How can I alias this class so I can inject the service?

I've also tried the old method of using container->get(...), but container is null and I'm not sure if it is the correct approach as well.

Upvotes: 1

Views: 856

Answers (2)

Cadot.eu
Cadot.eu

Reputation: 394

Declare the service as @Bonewolf in your services.yaml add

services:
...
   Liip\ImagineBundle\Service\FilterService:
        alias: "liip_imagine.service.filter"

after in your controller use by injection your service

public function upload(FilterService $filterService,...)
{
$filterService->getUrlOfFilteredImage($request->files->get('upload'),'your filter imagine');
}

Upvotes: 0

Bonewolf
Bonewolf

Reputation: 149

One solution should be to add class into config/services.yaml

services:
    Liip\ImagineBundle\Service\FilterService:
        # some settings

Symfony service container
Service aliases

Upvotes: 1

Related Questions