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

Warning: Missing argument 1 ::__construct() #274

Open
trottera opened this issue Mar 27, 2017 · 0 comments
Open

Warning: Missing argument 1 ::__construct() #274

trottera opened this issue Mar 27, 2017 · 0 comments

Comments

@trottera
Copy link

I've created a command with the following code:

`use JMS\DiExtraBundle\Annotation as DI;

/**

  • @di\Service("app.importer.command", public=true)

  • @di\Tag(name="console.command")
    */
    class ImportCommand extends ContainerAwareCommand
    {

    protected function execute(InputInterface $input, OutputInterface $output)
    {
    $cityId = $input->getOption('city');
    $importer = $this->getContainer()->get("app.importer");

     ...
    

    }

}`

the "app.importer" is a service i declared using annotations like that:

`use JMS\DiExtraBundle\Annotation as DI;

/**

  • @di\Service("app.importer", public=true)
    */
    class Importer
    {

    /*

    • @di\InjectParams({
    • "client" = @DI\Inject("guzzle.client.importer"),
      
    • "key" = @DI\Inject("%apikey%"),
      
    • "doctrine" = @DI\Inject("doctrine"),
      
    • "fileDownloader" = @DI\Inject("app.filedownloader"),
      
    • })
      */
      public function __construct($client, $key, $doctrine, $fileDownloader)
      {
      $this->client = $client;
      $this->key = $key;
      $this->doctrine = $doctrine;
      $this->fileDownloader = $fileDownloader;
      }

    ...
    }`

when i run the command i get a error message: [Symfony\Component\Debug\Exception\ContextErrorException]
Warning: Missing argument 1 for BackendBundle\Service\Importer::__construct(), called in /mnt/sdc/www/mysite/htdocs/var/cache/dev/appDevDebugProjectContainer.php on line 558 and defined

If i don't get the "app.importer" service the error message is gone. Shouldn't this work? Or am i missing something?

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

1 participant