mirror of
https://github.com/typemill/typemill.git
synced 2025-07-31 19:30:40 +02:00
Version 1.1.0 Introducing Plugins, Event-Dispatcher and CookieConsent
This commit is contained in:
32
system/Middleware/OldInputMiddleware.php
Normal file
32
system/Middleware/OldInputMiddleware.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Typemill\Middleware;
|
||||
|
||||
use Slim\Views\Twig;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
class OldInputMiddleware
|
||||
{
|
||||
protected $view;
|
||||
|
||||
public function __construct(Twig $view)
|
||||
{
|
||||
$this->view = $view;
|
||||
}
|
||||
|
||||
public function __invoke(Request $request, Response $response, $next)
|
||||
{
|
||||
if(isset($_SESSION['old']))
|
||||
{
|
||||
$this->view->getEnvironment()->addGlobal('old', $_SESSION['old']);
|
||||
}
|
||||
if(!empty($request->getParams()))
|
||||
{
|
||||
$_SESSION['old'] = $request->getParams();
|
||||
}
|
||||
|
||||
$response = $next($request, $response);
|
||||
return $response;
|
||||
}
|
||||
}
|
30
system/Middleware/ValidationErrorsMiddleware.php
Normal file
30
system/Middleware/ValidationErrorsMiddleware.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace Typemill\Middleware;
|
||||
|
||||
use Slim\Views\Twig;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
|
||||
class ValidationErrorsMiddleware
|
||||
{
|
||||
protected $view;
|
||||
|
||||
public function __construct(Twig $view)
|
||||
{
|
||||
$this->view = $view;
|
||||
}
|
||||
|
||||
public function __invoke(Request $request, Response $response, $next)
|
||||
{
|
||||
if(isset($_SESSION['errors']))
|
||||
{
|
||||
$this->view->getEnvironment()->addGlobal('errors', $_SESSION['errors']);
|
||||
|
||||
unset($_SESSION['errors']);
|
||||
}
|
||||
|
||||
$response = $next($request, $response);
|
||||
return $response;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user