44 lines
1.4 KiB
PHP
44 lines
1.4 KiB
PHP
<?php
|
|
namespace app\modules\site;
|
|
|
|
use Piko\Module\Event\CreateControllerEvent;
|
|
use Piko\Controller\Event\BeforeActionEvent;
|
|
use app\lib\Vite;
|
|
|
|
class Module extends \Piko\Module
|
|
{
|
|
public function bootstrap()
|
|
{
|
|
// Instanciate once i18n to setup the language config
|
|
$this->application->getComponent('Piko\I18n');
|
|
|
|
$user = $this->application->getComponent('Piko\User');
|
|
assert($user instanceof \Piko\User);
|
|
|
|
// Pass some parameters to the View component
|
|
$view = $this->application->getComponent('Piko\View');
|
|
$view->params['user'] = $user;
|
|
$view->params['language'] = $this->application->language;
|
|
// $view->attachBehavior('vite', 'app\lib\Vite::vite');
|
|
$vite = new Vite($view);
|
|
$vite->loadEntry('main.js');
|
|
|
|
$userModule = $this->application->getModule('user');
|
|
assert ($userModule instanceof \app\modules\user\Module);
|
|
|
|
$userModule->on(CreateControllerEvent::class, function(CreateControllerEvent $event) {
|
|
$event->controller->on(BeforeActionEvent::class, function (BeforeActionEvent $event) {
|
|
|
|
$action = $event->actionId;
|
|
|
|
switch($action) {
|
|
case 'login':
|
|
$event->controller->layout = 'minimal';
|
|
break;
|
|
}
|
|
|
|
});
|
|
});
|
|
}
|
|
}
|