Browse Source

Remove more deprecated features from 3.x

Remove recently added deprecated features.

Refs #11934
Mark Story 7 years ago
parent
commit
287c6e2d13
5 changed files with 23 additions and 105 deletions
  1. 1 1
      src/Controller/Controller.php
  2. 0 37
      src/Core/Plugin.php
  3. 2 4
      src/View/Cell.php
  4. 2 4
      src/View/View.php
  5. 18 59
      tests/TestCase/Core/PluginTest.php

+ 1 - 1
src/Controller/Controller.php

@@ -648,7 +648,7 @@ class Controller implements EventListenerInterface, EventDispatcherInterface
 
         $view = $this->createView();
         $contents = $view->render($template, $layout);
-        $this->setResponse($view->response->withStringBody($contents));
+        $this->setResponse($view->getResponse()->withStringBody($contents));
 
         return $this->response;
     }

+ 0 - 37
src/Core/Plugin.php

@@ -329,43 +329,6 @@ class Plugin
     }
 
     /**
-     * Loads the routes file for a plugin, or all plugins configured to load their respective routes file.
-     *
-     * If you need fine grained control over how routes are loaded for plugins, you
-     * can use {@see Cake\Routing\RouteBuilder::loadPlugin()}
-     *
-     * @param string|null $name name of the plugin, if null will operate on all
-     *   plugins having enabled the loading of routes files.
-     * @return bool
-     * @deprecated 3.6.5 This method is no longer needed when using HttpApplicationInterface based applications.
-     *   This method will be removed in 4.0.0
-     */
-    public static function routes($name = null)
-    {
-        deprecationWarning(
-            'You no longer need to call `Plugin::routes()` after upgrading to use Http\Server. ' .
-            'See https://book.cakephp.org/3.0/en/development/application.html#adding-the-new-http-stack-to-an-existing-application ' .
-            'for upgrade information.'
-        );
-        if ($name === null) {
-            foreach (static::loaded() as $p) {
-                static::routes($p);
-            }
-
-            return true;
-        }
-        $plugin = static::getCollection()->get($name);
-        if (!$plugin->isEnabled('routes')) {
-            return false;
-        }
-
-        return (bool)static::_includeFile(
-            $plugin->getConfigPath() . 'routes.php',
-            true
-        );
-    }
-
-    /**
      * Returns true if the plugin $plugin is already loaded
      * If plugin is null, it will return a list of all loaded plugins
      *

+ 2 - 4
src/View/Cell.php

@@ -62,17 +62,15 @@ abstract class Cell
      * additional information about the request.
      *
      * @var \Cake\Http\ServerRequest
-     * @deprecated 3.7.0 The property will become protected in 4.0.0.
      */
-    public $request;
+    protected $request;
 
     /**
      * An instance of a Response object that contains information about the impending response
      *
      * @var \Cake\Http\Response
-     * @deprecated 3.7.0 The property will become protected in 4.0.0.
      */
-    public $response;
+    protected $response;
 
     /**
      * The helpers this cell uses.

+ 2 - 4
src/View/View.php

@@ -194,17 +194,15 @@ class View implements EventDispatcherInterface
      * additional information about the request.
      *
      * @var \Cake\Http\ServerRequest
-     * @deprecated 3.7.0 The property will become protected in 4.0.0. Use getRequest()/setRequest() instead.
      */
-    public $request;
+    protected $request;
 
     /**
      * Reference to the Response object
      *
      * @var \Cake\Http\Response
-     * @deprecated 3.7.0 The property will become protected in 4.0.0. Use getResponse()/setResponse() instead.
      */
-    public $response;
+    protected $response;
 
     /**
      * The Cache configuration View will use to store cached elements. Changing this will change

+ 18 - 59
tests/TestCase/Core/PluginTest.php

@@ -175,24 +175,6 @@ class PluginTest extends TestCase
     }
 
     /**
-     * Tests loading a plugin with bootstrap file and routes file
-     *
-     * @deprecated
-     * @return void
-     */
-    public function testLoadSingleWithBootstrapAndRoutes()
-    {
-        $this->deprecated(function () {
-            Plugin::load('TestPlugin', ['bootstrap' => true, 'routes' => true]);
-            $this->assertTrue(Plugin::loaded('TestPlugin'));
-            $this->assertEquals('loaded plugin bootstrap', Configure::read('PluginTest.test_plugin.bootstrap'));
-
-            Plugin::routes();
-            $this->assertEquals('loaded plugin routes', Configure::read('PluginTest.test_plugin.routes'));
-        });
-    }
-
-    /**
      * Test load() with path configuration data
      *
      * @return void
@@ -248,24 +230,6 @@ class PluginTest extends TestCase
     }
 
     /**
-     * Test ignoring missing bootstrap/routes file
-     *
-     * @deprecated
-     * @return void
-     */
-    public function testIgnoreMissingFiles()
-    {
-        $this->deprecated(function () {
-            Plugin::loadAll([[
-                'bootstrap' => true,
-                'routes' => true,
-                'ignoreMissing' => true
-            ]]);
-            $this->assertTrue(Plugin::routes());
-        });
-    }
-
-    /**
      * Tests that Plugin::load() throws an exception on unknown plugin
      *
      * @return void
@@ -396,32 +360,27 @@ class PluginTest extends TestCase
      * Tests that Plugin::loadAll() will load all plugins in the configured folder wit defaults
      * and overrides for a plugin
      *
-     * @deprecated
      * @return void
      */
     public function testLoadAllWithDefaultsAndOverride()
     {
-        $this->deprecated(function () {
-            Plugin::loadAll([
-                ['bootstrap' => true, 'ignoreMissing' => true],
-                'TestPlugin' => ['routes' => true],
-                'TestPluginFour' => ['bootstrap' => true, 'classBase' => '']
-            ]);
-            Plugin::routes();
-
-            $expected = [
-                'Company', 'ParentPlugin', 'PluginJs', 'TestPlugin',
-                'TestPluginFour', 'TestPluginTwo', 'TestTheme'
-            ];
-            $this->assertEquals($expected, Plugin::loaded());
-            $this->assertEquals('loaded js plugin bootstrap', Configure::read('PluginTest.js_plugin.bootstrap'));
-            $this->assertEquals('loaded plugin routes', Configure::read('PluginTest.test_plugin.routes'));
-            $this->assertNull(Configure::read('PluginTest.test_plugin.bootstrap'));
-            $this->assertEquals('loaded plugin two bootstrap', Configure::read('PluginTest.test_plugin_two.bootstrap'));
-            $this->assertEquals('loaded plugin four bootstrap', Configure::read('PluginTest.test_plugin_four.bootstrap'));
-
-            // TestPluginThree won't get loaded by loadAll() since it's in a sub directory.
-            $this->assertNull(Configure::read('PluginTest.test_plugin_three.bootstrap'));
-        });
+        Plugin::loadAll([
+            ['bootstrap' => true, 'ignoreMissing' => true],
+            'TestPlugin' => ['routes' => true],
+            'TestPluginFour' => ['bootstrap' => true, 'classBase' => '']
+        ]);
+
+        $expected = [
+            'Company', 'ParentPlugin', 'PluginJs', 'TestPlugin',
+            'TestPluginFour', 'TestPluginTwo', 'TestTheme'
+        ];
+        $this->assertEquals($expected, Plugin::loaded());
+        $this->assertEquals('loaded js plugin bootstrap', Configure::read('PluginTest.js_plugin.bootstrap'));
+        $this->assertNull(Configure::read('PluginTest.test_plugin.bootstrap'));
+        $this->assertEquals('loaded plugin two bootstrap', Configure::read('PluginTest.test_plugin_two.bootstrap'));
+        $this->assertEquals('loaded plugin four bootstrap', Configure::read('PluginTest.test_plugin_four.bootstrap'));
+
+        // TestPluginThree won't get loaded by loadAll() since it's in a sub directory.
+        $this->assertNull(Configure::read('PluginTest.test_plugin_three.bootstrap'));
     }
 }