Skip to content
Snippets Groups Projects
Commit 30ad2577 authored by Bertrand Gauthier's avatar Bertrand Gauthier
Browse files

Suppression de la dépendance avec unicaen/console.

parent d12214d8
No related branches found
No related tags found
No related merge requests found
Pipeline #24443 passed
......@@ -5,6 +5,7 @@ CHANGELOG
-----
- Suppression du ConsoleController utilisé par une seule appli pour lancer une ligne SQL.
- Suppression de la dépendance avec unicaen/console.
6.0.10
-----
......
......@@ -17,13 +17,10 @@ use Laminas\Validator\AbstractValidator;
use Laminas\View\Helper\Navigation;
use Laminas\View\HelperPluginManager;
use Locale;
use Unicaen\Console\Console;
use Unicaen\Console\View\ExceptionStrategy as ConsoleExceptionStrategy;
use UnicaenApp\Controller\Plugin\MessengerPluginFactory;
use UnicaenApp\Controller\Plugin\Upload\UploaderPluginFactory;
use UnicaenApp\Mvc\Listener\MaintenanceListener;
use UnicaenApp\Mvc\Listener\ModalListener;
use UnicaenApp\Mvc\View\Http\ExceptionStrategy;
use UnicaenApp\Mvc\View\Http\ExceptionStrategy as HttpExceptionStrategy;
use UnicaenApp\Options\ModuleOptions;
......@@ -93,15 +90,13 @@ class Module implements
$eventManager = $application->getEventManager();
/** @var HttpExceptionStrategy|ConsoleExceptionStrategy $baseExceptionStrategy */
if ($e->getRequest() instanceof HttpRequest) {
/** @var HttpExceptionStrategy $baseExceptionStrategy */
$baseExceptionStrategy = $services->get('HttpExceptionStrategy');
} else {
$baseExceptionStrategy = $services->get('ConsoleExceptionStrategy');
}
$exceptionStrategy = new ExceptionStrategy();
$exceptionStrategy = new HttpExceptionStrategy();
$exceptionStrategy->setDisplayExceptions($baseExceptionStrategy->displayExceptions());
$exceptionStrategy->attach($eventManager);
}
/* Démarrage des mouchards en fonction de la configuration... */
$services->get('MouchardService')->createMouchardsFromConfig();
......@@ -148,7 +143,7 @@ class Module implements
*/
public function bootstrapSession($e)
{
if (Console::isConsole()) {
if (Util::isConsole()) {
return;
}
......@@ -174,7 +169,7 @@ class Module implements
*/
public function appendSessionRefreshJs(EventInterface $e)
{
if (Console::isConsole()) {
if (Util::isConsole()) {
return;
}
......
......@@ -8,8 +8,8 @@ use Laminas\Mvc\Application;
use Laminas\Mvc\MvcEvent;
use Laminas\Stdlib\ResponseInterface as Response;
use Laminas\View\Model\ViewModel;
use Unicaen\Console\Console;
use UnicaenApp\Exception\ExceptionInterface;
use UnicaenApp\Util;
/**
* Stratégie permettant d'afficher proprement un message d'erreur lorsqu'une exception est levée
......@@ -61,7 +61,7 @@ class ExceptionStrategy extends \Laminas\Mvc\View\Http\ExceptionStrategy
}
// Do nothing if the request is console type
if (Console::isConsole()) {
if (Util::isConsole()) {
return;
}
......
......@@ -23,7 +23,12 @@ class Util
*/
static protected $microtime;
/**
* Allow overriding whether or not we're in a console env. If set, and
* boolean, returns that value from isConsole().
* @var bool
*/
protected static $isConsole;
/**
* Transforme en tableau simple une collection d'objets spécifiée sous forme d'un itérateur.
......@@ -776,15 +781,19 @@ class Util
return $content;
}
/**
* Détermine si on est en mode console ou non
* Check if running in a console environment (CLI)
*
* By default, returns value of PHP_SAPI global constant. If $isConsole is
* set, and a boolean value, that value will be returned.
*
* @return bool
*/
static public function isConsole(): bool
public static function isConsole()
{
return PHP_SAPI == 'cli';
if (null === static::$isConsole) {
static::$isConsole = (PHP_SAPI == 'cli');
}
return static::$isConsole;
}
}
......@@ -5,7 +5,7 @@ namespace UnicaenApp\View\Helper;
use Psr\Container\ContainerInterface;
use Laminas\ServiceManager\FactoryInterface;
use Laminas\ServiceManager\ServiceLocatorInterface;
use Unicaen\Console\Console;
use UnicaenApp\Util;
/**
* Description of AppLinkFactory
......@@ -22,7 +22,7 @@ class AppLinkFactory implements FactoryInterface
public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
{
$sl = $container;
$router = Console::isConsole() ? 'HttpRouter' : 'Router';
$router = Util::isConsole() ? 'HttpRouter' : 'Router';
$match = $sl->get('application')->getMvcEvent()->getRouteMatch();
$helper = new AppLink();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment