Edit:
I've prepared a tar.gz which once uncompressed and after running ./bin/vendors install fails to load the fixtures through php scripts/createAll.php. In the tar.gz there are 2 bundles using 2 different connections everyone with its own database.
I think Symfony2 fails to manage them properly. If you take a look at scripts/createAll.php will see how symfony fails to load both fixtures, but if you remove a random fixture (it doesn't matter Var_.php or Foo_.php everything runs fine, which seems to me that symfony is failing to manage entities correctly.)
LINK: http://www.2shared.com/file/2u4GhFVX/SymfonyTestCasetar.html
i want to tell Symfony2 to use different entity managers for different Bundle
directories so my config.yml looks like:
orm:
auto_generate_proxy_classes: %kernel.debug%
default_entity_manager: default
entity_managers:
default:
connection: default
mappings:
myVendorURLCoreBundle: ~
myVendormyBundleBundle: ~
myVendormyBundleFooBundle:
prefix: "myVendor\myBundleFooBundle\Entity"
type: annotation
is_bundle: true
dir: "/Entity"
formacions:
connection: formacions
mappings:
myVendormyBundleFooBarBundle:
prefix: "myVendor\myBundleFooBarBundle\View"
type: annotation
is_bundle: false
dir: "%kernel.root_dir%/../src/myVendor/myBundleFooBarBundle/View"
The problem is when using relationships between the entities in the different directories i get the following error caused by vendor/doctrine/lib/Doctrine/ORM/Mapping/MappingException.php at line 142
Class FRJPC\SalleUrlFormacionsBundle\Entity\EspecialitatContingut is not a valid entity or mapped super class
The probem is that sometimes "\" before the vendor name breaks the namespace. It's really strange.
Here is how i i link entities between each other:
namespace myVendor\myBundleFooBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity( repositoryClass="myVendor\myBundleFooBundle\Repository\ARepository" )
* @ORM\ChangeTrackingPolicy( "DEFERRED_EXPLICIT" )
* @ORM\Table( name="a" )
*/
class A
{
/**
* @ORM\Id
* @ORM\Column( type="integer", length="4" )
* @ORM\GeneratedValue( strategy="AUTO" )
*/
private $id;
/**
* @ORM\ManyToOne( targetEntity="\myVendor\myBundleFooBarBundle\Entity\B", inversedBy="a", cascade={"persist"} )
* @ORM\JoinColumn( name="FooBar", nullable=true, referencedColumnName="FooBar", onDelete="CASCADE" )
*/
private $fooBar;
}
Second entity:
namespace myVendor\myBundleFooBarBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity( repositoryClass="myVendor\myBundleFooBarBundle\Repository\ARepository" )
* @ORM\ChangeTrackingPolicy( "DEFERRED_EXPLICIT" )
* @ORM\Table( name="a" )
*/
class B
{
/**
* @ORM\Id
* @ORM\Column( type="integer", length="4" )
* @ORM\GeneratedValue( strategy="AUTO" )
*/
private $id;
/** @ORM\OneToMany( targetEntity="\myVendor\myBundleFooBundle\Entity\EspecialitatContingut", mappedBy="fooBar" ) */
private $a;
}
Does any one has a clue on how should i link each entity ?
PD: Both entities work like charm when they're in the same bundle and same directory.