update slim to 3.2.1; no need to override router anymore; update php-events to...

update slim to 3.2.1; no need to override router anymore; update php-events to ver 2; change listeners arguments order
parent bfd9f9ab
This diff is collapsed.
*
!.gitignore
\ No newline at end of file
......@@ -13,11 +13,11 @@ return function (Slim\App $app) {
$container = $app->getContainer();
$events = $container['events'];
$events('on', 'app.autoload', function ($stop, $autoloader) {
$events('on', 'app.autoload', function ($autoloader) {
$autoloader->addPsr4('GrEduLabs\\Application\\', __DIR__ . '/src');
});
$events('on', 'app.services', function ($stop, Slim\Container $container) {
$events('on', 'app.services', function (Slim\Container $container) {
session_name('GrEduLabs');
session_start();
......@@ -30,11 +30,6 @@ return function (Slim\App $app) {
isset($container['settings']['db']['freeze']) ? $container['settings']['db']['freeze'] : true
);
// override default router
$container['router'] = $container->extend('router', function () {
return new GrEduLabs\Application\Router();
});
$container['view'] = function ($c) {
$settings = $c['settings'];
$view = new Slim\Views\Twig(
......@@ -98,7 +93,7 @@ return function (Slim\App $app) {
};
});
$events('on', 'app.bootstrap', function ($stop, $app, $container) {
$events('on', 'app.bootstrap', function ($app, $container) {
$app->get('/', GrEduLabs\Application\Action\Index::class)->setName('index');
$app->get('/about', GrEduLabs\Application\Action\About::class)->setName('about');
});
......
<?php
/**
* gredu_labs.
*
* @link https://github.com/eellak/gredu_labs for the canonical source repository
*
* @copyright Copyright (c) 2008-2015 Greek Free/Open Source Software Society (https://gfoss.ellak.gr/)
* @license GNU GPLv3 http://www.gnu.org/licenses/gpl-3.0-standalone.html
*/
namespace GrEduLabs\Application;
use RuntimeException;
use Slim\Router as BaseRouter;
class Router extends BaseRouter
{
public function getNamedRoute($name)
{
if (is_null($this->namedRoutes)) {
$this->buildNameIndex();
}
foreach ($this->routes as $route) {
$routeName = $route->getName();
if ($routeName && $name === $routeName) {
return $route;
}
}
throw new RuntimeException('Named route does not exist for name: ' . $name);
}
}
......@@ -12,11 +12,11 @@ return function (Slim\App $app) {
$container = $app->getContainer();
$events = $container['events'];
$events('on', 'app.autoload', function ($stop, $autoloader) {
$events('on', 'app.autoload', function ($autoloader) {
$autoloader->addPsr4('GrEduLabs\\ApplicationForm\\', __DIR__ . '/src/');
});
$events('on', 'app.services', function ($stop, $container) {
$events('on', 'app.services', function ($container) {
$container[GrEduLabs\ApplicationForm\Service\ApplicationFormServiceInterface::class] = function ($c) {
return new GrEduLabs\ApplicationForm\Service\ApplicationFormService();
......@@ -77,7 +77,7 @@ return function (Slim\App $app) {
};
});
$events('on', 'app.bootstrap', function ($stop, $app, $container) {
$events('on', 'app.bootstrap', function ($app, $container) {
$container['view']->getEnvironment()->getLoader()->prependPath(__DIR__ . '/templates');
$container['router']->getNamedRoute('school')
->add(GrEduLabs\ApplicationForm\Middleware\SchoolApplicationForm::class);
......
......@@ -71,7 +71,7 @@ return function (Slim\App $app) {
$container = $app->getContainer();
$events = $container['events'];
$events('on', 'app.bootstrap', function ($stop, $app, $container) use ($mimeTypes) {
$events('on', 'app.bootstrap', function ($app, $container) use ($mimeTypes) {
$app->add(function (
ServerRequestInterface $req,
ResponseInterface $res,
......
......@@ -13,11 +13,11 @@ return function (Slim\App $app) {
$container = $app->getContainer();
$events = $container['events'];
$events('on', 'app.autoload', function ($stop, $autoloader) {
$events('on', 'app.autoload', function ($autoloader) {
$autoloader->addPsr4('GrEduLabs\\Authentication\\', __DIR__ . '/src');
});
$events('on', 'app.services', function ($stop, $container) {
$events('on', 'app.services', function ($container) {
$container['authentication_storage'] = function ($c) {
return new GrEduLabs\Authentication\Storage\PhpSession();
};
......@@ -88,7 +88,7 @@ return function (Slim\App $app) {
$container['settings']->set('navigation', $nav);
});
$events('on', 'app.services', function ($stop, $container) {
$events('on', 'app.services', function ($container) {
$container->extend('view', function ($view, $c) {
$view->getEnvironment()->getLoader()->prependPath(__DIR__ . '/templates');
$view->addExtension(new GrEduLabs\Authentication\Twig\Extension\Identity(
......@@ -99,7 +99,7 @@ return function (Slim\App $app) {
});
}, -10);
$events('on', 'app.bootstrap', function ($stop, $app, $container) {
$events('on', 'app.bootstrap', function ($app, $container) {
$app->group('/user', function () {
$this->map(['GET', 'POST'], '/login', GrEduLabs\Authentication\Action\User\Login::class)
->add(GrEduLabs\Application\Middleware\AddCsrfToView::class)
......@@ -117,7 +117,7 @@ return function (Slim\App $app) {
});
});
$events('on', 'authenticate.success', function ($stop, $identity) use ($container) {
$events('on', 'authenticate.success', function ($identity) use ($container) {
if (isset($container['logger'])) {
$container['logger']->info(sprintf(
'Authentication through %s for %s',
......
......@@ -13,11 +13,11 @@ return function (Slim\App $app) {
$container = $app->getContainer();
$events = $container['events'];
$events('on', 'app.autoload', function ($stop, $autoloader) {
$events('on', 'app.autoload', function ($autoloader) {
$autoloader->addPsr4('GrEduLabs\\Authorization\\', __DIR__ . '/src');
});
$events('on', 'app.services', function ($stop, $container) {
$events('on', 'app.services', function ($container) {
$container['settings']->set('determineRouteBeforeAppMiddleware', true);
$container[GrEduLabs\Authorization\Acl::class] = function ($c) {
......@@ -70,7 +70,7 @@ return function (Slim\App $app) {
};
});
$events('on', 'app.services', function ($stop, $container) {
$events('on', 'app.services', function ($container) {
$container->extend('identity_class_resolver', function () {
return function () {
return 'GrEduLabs\\Authorization\\Identity';
......@@ -84,7 +84,7 @@ return function (Slim\App $app) {
});
}, -10);
$events('on', 'app.bootstrap', function ($stop, $app, $container) {
$events('on', 'app.bootstrap', function ($app, $container) {
$container['router']->getNamedRoute('user.login')
->add(GrEduLabs\Authorization\Middleware\RoleProvider::class);
......
......@@ -13,11 +13,11 @@ return function (Slim\App $app) {
$container = $app->getContainer();
$events = $container['events'];
$events('on', 'app.services', function ($stop, $container) {
$events('on', 'app.services', function ($container) {
$container['settings']->set('displayErrorDetails', true);
});
$events('on', 'app.services', function ($stop, $container) {
$events('on', 'app.services', function ($container) {
$container->extend('view', function ($view) {
$view->addExtension(new Twig_Extension_Debug());
$view->getEnvironment()->enableDebug();
......
......@@ -13,11 +13,11 @@ return function (Slim\App $app) {
$container = $app->getContainer();
$events = $container['events'];
$events('on', 'app.autoload', function ($stop, $autoloader) {
$events('on', 'app.autoload', function ($autoloader) {
$autoloader->addPsr4('SchInventory\\', __DIR__ . '/src/');
});
$events('on', 'app.services', function ($stop, $container) {
$events('on', 'app.services', function ($container) {
$container['SchInventory\\Service'] = function ($c) {
$settings = $c['settings'];
......
......@@ -13,7 +13,7 @@ return function (Slim\App $app) {
$container = $app->getContainer();
$events = $container['events'];
$events('on', 'app.services', function ($stop, $container) {
$events('on', 'app.services', function ($container) {
$container['ldap'] = function ($c) {
$settings = $c['settings']['ldap'];
......
......@@ -13,11 +13,11 @@ return function (Slim\App $app) {
$container = $app->getContainer();
$events = $container['events'];
$events('on', 'app.autoload', function ($stop, $autoloader) {
$events('on', 'app.autoload', function ($autoloader) {
$autoloader->addPsr4('SchMM\\', __DIR__ . '/src/');
});
$events('on', 'app.services', function ($stop, $container) {
$events('on', 'app.services', function ($container) {
$container[SchMM\FetchUnit::class] = function ($c) {
$settings = $c['settings'];
......
......@@ -14,11 +14,11 @@ return function (Slim\App $app) {
$events = $container['events'];
$events('on', 'app.autoload', function ($stop, $autoloader) {
$events('on', 'app.autoload', function ($autoloader) {
$autoloader->addPsr4('SchSSO\\', __DIR__ . '/src/');
});
$events('on', 'app.services', function ($stop, $container) {
$events('on', 'app.services', function ($container) {
$container['init_cas'] = $container->protect(function () use ($container) {
$settings = $container['settings']['sso']['phpcas'];
phpCAS::client(
......@@ -95,7 +95,7 @@ return function (Slim\App $app) {
};
});
$events('on', 'app.bootstrap', function ($stop, $app, $container) {
$events('on', 'app.bootstrap', function ($app, $container) {
$container['view']->getEnvironment()->getLoader()->prependPath(__DIR__ . '/templates');
$app->get('/user/login/sso', SchSSO\Action\Login::class)
->setName('user.login.sso');
......@@ -104,13 +104,12 @@ return function (Slim\App $app) {
->setName('user.logout.sso');
});
$events('on', 'app.bootstrap', function ($stop, $app, $container) {
$events('on', 'app.bootstrap', function ($app, $container) {
$container['router']->getNamedRoute('user.login.sso')
->add(GrEduLabs\Authorization\Middleware\RoleProvider::class);
}, -100);
$events('on', 'logout', function (
callable $stop,
GrEduLabs\Authentication\Identity $identity,
$redirect = null
) use (&$container) {
......
......@@ -23,11 +23,11 @@ return function (App $app) {
$container = $app->getContainer();
$events = $container['events'];
$events('on', 'app.autoload', function ($stop, $autoloader) {
$events('on', 'app.autoload', function ($autoloader) {
$autoloader->addPsr4('SchSync\\', __DIR__ . '/src');
});
$events('on', 'app.services', function ($stop, $container) {
$events('on', 'app.services', function ($container) {
$container[CreateUser::class] = function ($c) {
return new CreateUser(
$c->get('authentication_service'),
......@@ -62,7 +62,7 @@ return function (App $app) {
};
});
$events('on', 'app.bootstrap', function ($stop, $app, $container) {
$events('on', 'app.bootstrap', function ($app, $container) {
$container['router']->getNamedRoute('user.login.sso')
->add(CreateUser::class)
->add(CreateSchool::class)
......
......@@ -18,11 +18,11 @@ return function (Slim\App $app) {
$container = $app->getContainer();
$events = $container['events'];
$events('on', 'app.autoload', function ($stop, $autoloader) {
$events('on', 'app.autoload', function ($autoloader) {
$autoloader->addPsr4('GrEduLabs\\Schools\\', __DIR__ . '/src/');
});
$events('on', 'app.services', function ($stop, $container) {
$events('on', 'app.services', function ($container) {
// actions
......@@ -203,7 +203,7 @@ return function (Slim\App $app) {
});
$events('on', 'app.bootstrap', function ($stop, $app, $container) {
$events('on', 'app.bootstrap', function ($app, $container) {
$container['view']->getEnvironment()->getLoader()->prependPath(__DIR__ . '/templates');
$app->group('/school', function () {
......
......@@ -172,7 +172,7 @@
type: 'delete',
dataType: 'json',
data: {
id: that.asset.get('id'),
id: that.asset.get('id')
}
}).done(function () {
that.model.remove(that.asset.get('id'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment