浏览代码

better deprecation handling for Sonata\AdminBundle\Controller\CoreController::getRequest()

Oskar Stark 8 年之前
父节点
当前提交
44567f4e5a
共有 2 个文件被更改,包括 11 次插入2 次删除
  1. 7 2
      Controller/CoreController.php
  2. 4 0
      UPGRADE-3.x.md

+ 7 - 2
Controller/CoreController.php

@@ -120,13 +120,18 @@ class CoreController extends Controller
      *
      *
      * NEXT_MAJOR: remove this method.
      * NEXT_MAJOR: remove this method.
      *
      *
-     * @deprecated Use the Request action argument. This method will be removed
-     *             in SonataAdminBundle 4.0 and the action methods adjusted
+     * @deprecated since 3.0, to be removed in 4.0 and action methods will be adjusted.
+     *             Use Symfony\Component\HttpFoundation\Request as an action argument.
      *
      *
      * @return Request
      * @return Request
      */
      */
     public function getRequest()
     public function getRequest()
     {
     {
+        @trigger_error('The '.__METHOD__.' method is deprecated since 3.0 and will be removed in 4.0.'.
+            ' Inject the Symfony\Component\HttpFoundation\Request into the actions instead.',
+            E_USER_DEPRECATED
+        );
+
         if ($this->container->has('request_stack')) {
         if ($this->container->has('request_stack')) {
             return $this->container->get('request_stack')->getCurrentRequest();
             return $this->container->get('request_stack')->getCurrentRequest();
         }
         }

+ 4 - 0
UPGRADE-3.x.md

@@ -1,6 +1,10 @@
 UPGRADE 3.x
 UPGRADE 3.x
 ===========
 ===========
 
 
+## Deprecated Sonata\AdminBundle\Controller\CoreController::getRequest()
+
+Inject `Symfony\Component\HttpFoundation\Request` in your actions directly as an argument.
+
 UPGRADE FROM 3.10 to 3.11
 UPGRADE FROM 3.10 to 3.11
 =========================
 =========================