瀏覽代碼

[FrameworkBundle] Adding a check for the existence of the Doctrine service

Ryan Weaver 14 年之前
父節點
當前提交
172c956b73
共有 1 個文件被更改,包括 4 次插入0 次删除
  1. 4 0
      src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php

+ 4 - 0
src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php

@@ -144,6 +144,10 @@ class Controller extends ContainerAware
      */
     public function getDoctrine()
     {
+        if (!$this->has('doctrine')) {
+            throw new \LogicException('The DoctrineBundle is not installed in your application.');
+        }
+
         return $this->get('doctrine');
     }