浏览代码

merged branch stloyd/patch-2 (PR #1514)

Commits
-------

00151db Call container directly (skip unnecesary method call)

Discussion
----------

[Controler] Call container directly

This skip unnecesary call for `Controller::get($id)` .
Fabien Potencier 14 年之前
父节点
当前提交
20fbcbe97e
共有 1 个文件被更改,包括 8 次插入6 次删除
  1. 8 6
      src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php

+ 8 - 6
src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php

@@ -123,7 +123,7 @@ class Controller extends ContainerAware
      */
     public function createForm($type, $data = null, array $options = array())
     {
-        return $this->get('form.factory')->create($type, $data, $options);
+        return $this->container->get('form.factory')->create($type, $data, $options);
     }
 
     /**
@@ -136,7 +136,7 @@ class Controller extends ContainerAware
      */
     public function createFormBuilder($data = null, array $options = array())
     {
-        return $this->get('form.factory')->createBuilder('form', $data, $options);
+        return $this->container->get('form.factory')->createBuilder('form', $data, $options);
     }
 
     /**
@@ -146,21 +146,23 @@ class Controller extends ContainerAware
      */
     public function getRequest()
     {
-        return $this->get('request');
+        return $this->container->get('request');
     }
 
     /**
      * Shortcut to return the Doctrine Registry service.
      *
      * @return Registry
+     *
+     * @throws \LogicException If DoctrineBundle is not available
      */
     public function getDoctrine()
     {
-        if (!$this->has('doctrine')) {
+        if (!$this->container->has('doctrine')) {
             throw new \LogicException('The DoctrineBundle is not installed in your application.');
         }
 
-        return $this->get('doctrine');
+        return $this->container->get('doctrine');
     }
 
     /**
@@ -180,7 +182,7 @@ class Controller extends ContainerAware
      *
      * @param  string $id The service id
      *
-     * @return object  The service
+     * @return object The service
      */
     public function get($id)
     {