dependency = $dependency; } public function findSomething(Directory $directory) { $dependency = $this->getDependency(); // Your DQL. } private function getDependency() { if (!$this->dependency instanceof Dependency) { throw \LogicException('Missing Dependency'); } return $this->dependency; } }