I am working one a simfony2 project and trying to inject ConteinerBuilder into one of my classes so I can use the getParameter() function to retrive info from parameters.yml file.
My class set up:
namespace NewsInfrastructure\Sitemap;
use NewsInfrastructure\DatabaseRepository;
use Symfony\Component\DependencyInjection\Container;
class DbSitemapReadRepository extends DatabaseRepository
{
protected $container;
/**
* @Route(service="parameters.container")
* @param Container $Container
*/
public function __construct(Container $Container)
{
$this->container = $Container;
}
public function getRootURL()
{
$this->container->getParameter('sitemap_root_url');
}
}
My serviices.xml file set up:
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<service id="parameters.container"
class="NewsInfrastructure\Sitemap\DbSitemapReadRepository">
<argument type="service" id="service_container" />
</service>
Symfony 2 Error Message:
The service "parameters.container" has a dependency on e non-existing service "container"
I have many other services declared in this file they all work fine but not this one....does anyone see what I am doing wrong..?
OK after a suggestion to change service id from "container" to "service_conteiner" the above error message has dissapired but new one appears
New error message.
"Catchable Fatal Error: Argument 1 passed to NewsInfrastucture\Sitemap\MyController::__construct() must be an instance of \Symfony\Component\DependencyInjection\ConteinerBuilder, Instance of Doctrine\DBAL\Connection given"