I am learning Symfony2 and how to do dependency injection. The question might be a bit long one but i guess I have to include all the code that leads to this error.
So i have a Factory design pattern in my Symfony2 project Interfacr -> Factory -> Controller.
My Interface file:
<?php
namespace Inter\DemoBundle\Interfaces;
interface ObjectInterface {
public function create($testObject);
}
Factory File:
<?php
namespace Inter\DemoBundle\Factory;
use Inter\DemoBundle\Interfaces\ObjectInterface;
class ObjectFactory implements ObjectInterface{
public function create($testObject)
{
$testObject = 'Hello World';
return $testObject;
}
}
Controller File:
<?php
namespace Inter\DemoBundle\Controller\DataController;
use Inter\DemoBundle\Factory\ObjectFactory;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
/**
* @Route("/test" service="inter.controller")
*/
class DataController
{
public $object;
public function __construct(
ObjectFactory $objectFactory
){
$this->object = $objectFactory;
}
public function test()
{
return $this->object;
}
}
Services File:
<?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">
<services>
<!--Factory Services-->
<service id="inter.factory.object.factory"
class="Inter\DemoBundle\Factory\ObjectFactory">
</service>
<!--Controller Services-->
<service id="inter_controller" class="Inter\DemoBundle\DataController">
<argument type="service" id="inter.factory.object.factory" />
</service>
</services>
</container>
Error:
FileLoaderImportCircularReferenceException in FileLoader.php line 97:
Circular reference detected in "/home/tomazi/Dev/interface.test/app/config/routing_dev.yml"
("/home/tomazi/Dev/interface.test/app/config/routing_dev.yml" > "/home/tomazi/Dev/interface.test/app/config/routing.yml" >
"/home/tomazi/Dev/interface.test/src/Inter/DemoBundle/Controller/" > "/home/tomazi/Dev/interface.test/app/config/routing_dev.yml").
I tried tried to fix this for ages now but no luck at all i Google it and now answers there ather than people complaining this is a miss leading Error in smymfony2 which might have nothing to do with routing.
Can someone help here please
rounting
androunting_dev
– b.b3rn4rd