Doctrine 2.4를 사용하여 다음과 같은 것이 가능한지 궁금합니다.Doctrine2의 프록시 생성에 대한 영향
/** * @ORM\Entity * @ORM\Table */ class SomeEntity { /** * @ORM\Id * @ORM\Column(type="bigint") * @ORM\GeneratedValue */ protected $some_really_long_named_id; public function getSomeReallyLongNamedId() { return $this->some_really_long_named_id; } }
우리가 IT에서 일을하고 우리가 게으른 때문에, 나는이 방법을 추가 :
한다고 가정 우리는 다음과 같습니다 엔티티가
public function getId() { return $this->some_really_long_named_id; }
이 엔티티가 프록시되고 이 엔티티의 프록시에 getId()
을 호출하면 엔티티가 지연로드됩니다. 우리가 getSomeReallyLongNamedId()
에 전화 할 때 그런 일이 일어나지 않는 이상 이상합니다.
분명히 Doctrine의 프록시 개체 안에 어떤 마법과 관련이 있습니다. 생성 된 프록시 방법은 다음과 같이 :
/** * {@inheritDoc} */ public function getId() { $this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', array()); return parent::getId(); } /** * {@inheritDoc} */ public function getSomeReallyLongNamedId() { if ($this->__isInitialized__ === false) { return parent::getSomeReallyLongNamedId(); } $this->__initializer__ && $this->__initializer__->__invoke($this, 'getSomeReallyLongNamedId', array()); return parent::getSomeReallyLongNamedId(); }
getId()
메서드를 호출 할 때, 그것은 게으른 부하를 의미하지 않는다는 것을 확인하기 위해 ProxyGenerator
에 영향을 미칠 수있는 방법이 있습니까?
IdGetter 주석에 대한 참조를 찾을 수 없습니다. 이 [기능 요청] (http://www.doctrine-project.org/jira/browse/DDC-687)이 구현되어 있음을 명시합니다. 그러나 현재의 [annotation class directory] (https://github.com/doctrine/doctrine2/tree/master/lib/Doctrine/ORM/Mapping)에는 언급이 없습니다. 작동하지 않습니다. 내 사건이 다르기 때문에 아마 : 나는 기본 getId 메소드 외에 두 번째 getter를 사용하고있다. – hvtilborg