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

How to inject entity manager into filter class #201

Open
bartek75 opened this issue Jan 8, 2016 · 0 comments
Open

How to inject entity manager into filter class #201

bartek75 opened this issue Jan 8, 2016 · 0 comments

Comments

@bartek75
Copy link

bartek75 commented Jan 8, 2016

Hi, how do you get entity manager injected into filter class?
When i call validateIncomingData i got exception "Argument 1 passed to UserInputFilter::__construct() must implement interface Doctrine\ORM\EntityManagerInterface, none given"
NodefectFilter.php

<?php
namespace Project\Form;

use Zend\InputFilter\Factory as InputFactory;
use Zend\InputFilter\InputFilter;
use Doctrine\ORM\EntityManagerInterface;

class NodefectFilter extends InputFilter
{
    private $entityManager;

    public function __construct(EntityManagerInterface $entityManager)
    {   
        $this->entityManager = $entityManager;

        $this->add(array(
         ....
        ));

    }
}

in controller

$data  = $this->validateIncomingData(NodefectFilter::class);
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