양식이 하나 있고 한 열에 Entity
유형이 있지만이 엔티티에 다른 연결이 있습니다. 행동양식 클래스 및 Doctrine Fixtures에서 Doctrine 연결 변경
내가
$em->getDoctrine()->getEntityManager('name')
어떻게 폼 클래스의 연결을 변경 할 수 있습니까?
아마도 엔티티 클래스에서 연결을 변경할 수 있습니다.
내가 여기 답 :
http://symfony.com/doc/2.0/reference/forms/types/entity.html#em
을 발견하지만 난 데이터기구 클래스의 연결을 변경하는 방법이
orm:
default_entity_manager: default
entity_managers:
owner:
connection: owner
mappings:
RealestateCoreBundle:
Entity: MyEntity
처럼 는 UPDATED?
나는 시도 :
<?php
namespace Realestate\CoreBundle\DataFixtures\ORM;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Realestate\CoreBundle\Entity\Owner;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class OwnerFixtures implements FixtureInterface, ContainerAwareInterface
{
private $container;
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}
public function load($manager)
{
$this->container->get('doctrine')->getEntityManager('owner');
for ($i = 0; $i < 100; $i++) {
$owner = new Owner();
$owner->setName('name-' . $i);
$owner->setTelephone(mt_rand(100000, 999999));
$manager->persist($owner);
}
$manager->flush();
}
}
그러나 didnt 한 일 :(
$ 컨테이너 -> get ('doctrine') -> getEntityManager ('manager_name'); ' doest work – rtyshyk
참 ... 당신의 조명기가 컨테이너 인식을하는 한 '$ this-> container-> get ('doctrine ') -> getEntityManager ('manager_name '); 링크를 클릭하십시오. 이 방법을 원한다면 중요한 비트입니다. 당신의 조명기는 반드시'ContainerAwareInterface'를 구현해야합니다. 관리자의 이름을 명령 줄에 전달하는 것이 더 쉬운 방법 일 수 있습니다. – Kasheen
업데이트 질문. – rtyshyk