Inject Symfony Service in a Bundle for Akeneo Pim

95 Views Asked by At

I am trying to inject a service from Akeneo to my selfwritten Bundle. To be exact, i want to use the service defined here in my bundle instead of an Processor.

services:
     _defaults:
         autowire: true
         autoconfigure: true
     Acme\CategoryBuilder:
         class: Acme\CategoryBuilder\CategoryBuilder
         arguments:
             - '@pim_catalog.repository.category'
         tags:
             - { name: kernel.event_listener, event: akeneo.storage.post_save, method: onPostSave }

and this constructor:

public function __construct(CategoryRepositoryInterface
$categoryRepositoryInterface){
         $this->categoryRepositoryInterface = $categoryRepositoryInterface;
}

in a Class called CategoryBuilder. This setup does not work and if i try to clear & warmup the cache, i get the Error Response that 0 arguments are passed but 1 was expected. How can i pass this service to my Bundle?

Edit:

if i run: php bin/console debug:container pim_catalog.repository.category i get the following output:

Information for Service "pim_catalog.repository.category"
=========================================================

 Category repository

 ----------------- ------------------------------------------------------------------------------------ 
  Option            Value                                                                               
 ----------------- ------------------------------------------------------------------------------------ 
  Service ID        pim_catalog.repository.category                                                     
  Class             Akeneo\Tool\Bundle\ClassificationBundle\Doctrine\ORM\Repository\CategoryRepository  
  Tags              pim_repository                                                                      
  Public            no                                                                                  
  Synthetic         no                                                                                  
  Lazy              no                                                                                  
  Shared            yes                                                                                 
  Abstract          no                                                                                  
  Autowired         no                                                                                  
  Autoconfigured    no                                                                                  
  Factory Service   doctrine.orm.default_entity_manager                                                 
  Factory Method    getRepository                                                                       
 ----------------- ------------------------------------------------------------------------------------ 


 ! [NOTE] The "pim_catalog.repository.category" service or alias has been removed or inlined when the container was     
 !        compiled.                                                                                                     

Does the Note mean i just cant get this Service? If so, how can i restore it?

0

There are 0 best solutions below