Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation to show Dependency Injection (Symfony 4) #191

Open
tacman opened this issue Dec 14, 2018 · 1 comment
Open

Update documentation to show Dependency Injection (Symfony 4) #191

tacman opened this issue Dec 14, 2018 · 1 comment

Comments

@tacman
Copy link

tacman commented Dec 14, 2018

Symfony4 makes services private by default, so the examples that show getting the client from the container no longer work without additional configuration (making the service public), or injecting the container, which is discouraged (but works).

What is the name of the class to be used when getting the client via Dependency Injection? I was hoping to simply inject \Solarium\Client, but am getting an error:

Cannot autowire argument $client of "App\Controller\MessageController::message()": it references class "Solarium\Client" but no such service exists. You should maybe alias this class to the existing "solr.client.adapter" service. 

Can you provide an example with a Symfony4 service or controller that doesn't inject the container? Thanks!

@NodokaMurmevent
Copy link

it's maybe to late but i have resolve the problem with :

# config/services.yml
services:
    # ...
    FS\SolrBundle\SolrInterface: '@solr.client'
# src/Controller/MyController.php
use FS\SolrBundle\SolrInterface;

class SiteController extends AbstractController{
    #...
     public function recherche(SolrInterface $client){
         //my code
    }
    #...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants