Note that there are some explanatory texts on larger screens.

plurals
  1. POIssues in entities from different bundles using different entity managers
    primarykey
    data
    text
    <p>Edit: </p> <p>I've prepared a tar.gz which once uncompressed and after running ./bin/vendors install fails to load the fixtures through php <code>scripts/createAll.php</code>. In the tar.gz there are 2 bundles using 2 different connections everyone with its own database. </p> <p>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.)</p> <p>LINK: <a href="http://www.2shared.com/file/2u4GhFVX/SymfonyTestCasetar.html" rel="nofollow noreferrer">http://www.2shared.com/file/2u4GhFVX/SymfonyTestCasetar.html</a></p> <p>i want to tell <code>Symfony2</code> to use different <code>entity managers</code> for different <code>Bundle directories</code> so my config.yml looks like: </p> <pre><code>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" </code></pre> <p>The problem is when using relationships between the entities in the different directories i get the following error caused by <code>vendor/doctrine/lib/Doctrine/ORM/Mapping/MappingException.php at line 142</code></p> <blockquote> <p>Class FRJPC\SalleUrlFormacionsBundle\Entity\EspecialitatContingut is not a valid entity or mapped super class</p> </blockquote> <p>The probem is that sometimes "\" before the vendor name breaks the namespace. It's really strange. </p> <p>Here is how i i link entities between each other: </p> <pre> 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; } </pre> <p>Second entity:</p> <pre> 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; } </pre> <p>Does any one has a clue on how should i link each entity ? </p> <p><strong>PD: Both entities work like charm when they're in the same bundle and same directory.</strong></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload