I am trying to write a custom app with a Middleware to interpret some cookies set from other software on the same domain.
I am following the documentation, but the Middleware is not invoked. I have tracked the problem down to the dependency injection closure not being invoked (the one inside the registerService call).
I’m not exactly a fluent PHP developer, so I may misunderstand this service injection stuff. I am creating the application like “new MyApp();”.
namespace OCA\CrowdSSO\AppInfo;
use \OCP\AppFramework\App;
use \OCP\AppFramework\Middleware;
//use \OCA\CrowdSSO\Middlewware\CrowdMiddleWare;
use OCP\Util;
class CrowdMiddleware extends Middleware {
public function beforeController($controller, $methodName){
Util::writeLog('crowdsso','Hello World 2!',Util::DEBUG);
parent::beforeController($controller, $methodName);
}
}
class CrowdSSO extends App {
/**
* Define your dependencies in here
*/
public function __construct(array $urlParams=array()){
parent::__construct('crowdsso', $urlParams);
Util::writeLog('crowdsso','Hello World Constructor!',Util::DEBUG);
$container = $this->getContainer();
$container->registerService('CrowdMiddleware', function($c){
Util::writeLog('crowdsso','Hello World Closure!',Util::DEBUG);
return new CrowdMiddleware();
});
$container->registerMiddleware('CrowdMiddleware');
}
}
$app = new CrowdSSO();