i'm trying to create a param converter for my project (symfony 2.4) Here is my converter:
namespace Test\ParamConvertersBundle\ProgramConverter;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ConfigurationInterface;
use Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterInterface;
use Symfony\Component\HttpFoundation\Request;
use Doctrine\ORM\EntityManager;
class ProgramConverter implements ParamConverterInterface{
protected $class;
protected $repository;
public function __construct($class, EntityManager $em){
$this->class = $class;
$this->repository = $em->getRepository($class);
}
public function apply(Request $request, ParamConverter $configuration){
return true;
}
public function supports(ParamConverter $configuration){
return $this->class === $configuration->getClass();
}
}
And here is the exception that drives me crazy:
FatalErrorException: Compile Error: Declaration of Test\ParamConvertersBundle\ProgramConverter\ProgramConverter::apply() must be compatible with Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterInterface::apply(Symfony\Component\HttpFoundation\Request $request, Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter $configuration)
I don't get the problem ....
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
? ;) – Bartekuse Sensio\Bundle\FrameworkExtraBundle\Configuration as Sensio
and then useSensio\ParamConverter
in method signature ;) – Jovan Perovic