Make abstract Middleware class public

It doesn't make sense for subclasses to have to implement
all methods.
This commit is contained in:
Thomas Tanghus 2013-10-05 16:59:06 +02:00
parent 485bb100b3
commit c85621a897
5 changed files with 10 additions and 10 deletions

View File

@ -26,7 +26,7 @@ namespace OC\AppFramework\Middleware;
use OC\AppFramework\Controller\Controller;
use OCP\AppFramework\Http\Response;
use OCP\AppFramework\IMiddleWare;
/**
* This class is used to store and run all the middleware in correct order
@ -58,7 +58,7 @@ class MiddlewareDispatcher {
* Adds a new middleware
* @param Middleware $middleware the middleware which will be added
*/
public function registerMiddleware(Middleware $middleWare){
public function registerMiddleware(IMiddleware $middleWare){
array_push($this->middlewares, $middleWare);
}

View File

@ -29,8 +29,8 @@ use OC\AppFramework\Http\Http;
use OC\AppFramework\Http\Request;
use OC\AppFramework\Http\RedirectResponse;
use OC\AppFramework\Utility\MethodAnnotationReader;
use OC\AppFramework\Middleware\Middleware;
use OC\AppFramework\Core\API;
use OCP\AppFramework\Middleware;
use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Http\JSONResponse;

View File

@ -22,7 +22,7 @@
*/
namespace OC\AppFramework\Middleware;
namespace OCP\AppFramework;
use OCP\AppFramework\Http\Response;
@ -33,7 +33,7 @@ use OCP\AppFramework\Http\Response;
* They're modeled after Django's middleware system:
* https://docs.djangoproject.com/en/dev/topics/http/middleware/
*/
abstract class Middleware {
abstract class Middleware implements IMiddleWare {
/**

View File

@ -25,8 +25,8 @@
namespace OC\AppFramework;
use OC\AppFramework\Http\Request;
use OC\AppFramework\Middleware\Middleware;
use OC\AppFramework\Middleware\MiddlewareDispatcher;
use OCP\AppFramework\Middleware;
use OCP\AppFramework\Http\Response;
@ -142,12 +142,12 @@ class MiddlewareDispatcherTest extends \PHPUnit_Framework_TestCase {
public function testAfterExceptionShouldReturnResponseOfMiddleware(){
$response = new Response();
$m1 = $this->getMock('\OC\AppFramework\Middleware\Middleware',
$m1 = $this->getMock('\OCP\AppFramework\Middleware',
array('afterException', 'beforeController'));
$m1->expects($this->never())
->method('afterException');
$m2 = $this->getMock('OC\AppFramework\Middleware\Middleware',
$m2 = $this->getMock('OCP\AppFramework\Middleware',
array('afterException', 'beforeController'));
$m2->expects($this->once())
->method('afterException')
@ -267,7 +267,7 @@ class MiddlewareDispatcherTest extends \PHPUnit_Framework_TestCase {
public function testExceptionShouldRunAfterExceptionOfOnlyPreviouslyExecutedMiddlewares(){
$m1 = $this->getMiddleware();
$m2 = $this->getMiddleware(true);
$m3 = $this->getMock('\OC\AppFramework\Middleware\Middleware');
$m3 = $this->getMock('\OCP\AppFramework\Middleware');
$m3->expects($this->never())
->method('afterException');
$m3->expects($this->never())

View File

@ -25,7 +25,7 @@
namespace OC\AppFramework;
use OC\AppFramework\Http\Request;
use OC\AppFramework\Middleware\Middleware;
use OCP\AppFramework\Middleware;
class ChildMiddleware extends Middleware {};