ozee31 / cakephp-cors

A CakePHP (3.3+) plugin for activate cors domain in your application
MIT License
43 stars 31 forks source link

Update plugin to Cake 4.x #24

Closed chrisShick closed 4 years ago

chrisShick commented 4 years ago

I have done a little bit of tinkering and have all the existing tests passing. @ozee31 double check that this works as intended.

rchavik commented 4 years ago

I think we also need this:

diff --git a/config/bootstrap.php b/config/bootstrap.php
index 203ff7d..e72638c 100644
--- a/config/bootstrap.php
+++ b/config/bootstrap.php
@@ -1,8 +1,8 @@
 <?php
 use Cake\Event\EventManager;
 use Cake\Core\Configure;
-use Cake\Routing\Middleware\RoutingMiddleware;
-use Cors\Routing\Middleware\CorsMiddleware;
+use Cake\Middleware\RoutingMiddleware;
+use Cors\Middleware\CorsMiddleware;
ozee31 commented 4 years ago

Thank you. I'll test it within the week.

rchavik commented 4 years ago

Also need to update AppExceptionRenderer. Here's updated diff on top @chrisShick's PR:

diff --git a/config/bootstrap.php b/config/bootstrap.php
index 203ff7d..e72638c 100644
--- a/config/bootstrap.php
+++ b/config/bootstrap.php
@@ -1,8 +1,8 @@
 <?php
 use Cake\Event\EventManager;
 use Cake\Core\Configure;
-use Cake\Routing\Middleware\RoutingMiddleware;
-use Cors\Routing\Middleware\CorsMiddleware;
+use Cake\Middleware\RoutingMiddleware;
+use Cors\Middleware\CorsMiddleware;

 /**
  * Configuration
diff --git a/src/Error/AppExceptionRenderer.php b/src/Error/AppExceptionRenderer.php
index fd56188..a218534 100644
--- a/src/Error/AppExceptionRenderer.php
+++ b/src/Error/AppExceptionRenderer.php
@@ -1,6 +1,7 @@
 <?php
 namespace Cors\Error;

+use Cake\Controller\Controller;
 use Cake\Core\Configure;
 use Cors\Middleware\CorsMiddleware;

@@ -16,7 +17,7 @@ class AppExceptionRenderer extends BaseExceptionRenderer
      *
      * @return \Cake\Controller\Controller
      */
-    protected function _getController()
+    protected function _getController() : Controller
     {
         $controller = parent::_getController();
         $cors = new CorsMiddleware();