あなたのサービスの依存関係でDoctrine Entity Managerを1つだけ使用する必要があります。 しかし、あなたはあなたのIDEでコードヒントを持つようにしたい場合は、あなたがこの
class SomeServiceWithDoctrineDependency
{
/** @var YourFirstObjectRepository */
protected $firstRepo;
/** @var YourSecondObjectRepository */
protected $secondRepo;
/** @var YourThirdObjectRepository */
protected $thirdRepo;
public function __construct(EntityManagerInterface $entityManager)
{
$this->firstRepo = $entityManager->getRepository('First:Repo');
$this->secondRepo = $entityManager->getRepository('Second:Repo');
$this->thirdRepo = $entityManager->getRepository('Third:Repo');
}
public function getCodeHint()
{
// You get hint here for find method
// $this->thirdRepo()->find()...
}
}
リポジトリ注入などのphpdocのアノテーションでそれを行うことができますがダウンして手を獲得します。本当の問題は、4つのリポジトリに依存するクラスが多すぎる可能性が高いことです。 – Cerad
私はそれが過度に思われることに同意します。しかし、おそらく、reposのいくつかは、formElement、formElementOption、formElementFilterなどの組み合わせでマージする必要があるかもしれません。だから、その多くは正規化されている可能性があります。しかし、私はコメントに感謝します。 – mr12086