$eventsManager = new EventsManager(); //$eventsManager->attach('dispatch:beforeDispatch', new SecurityPlugin); //$eventsManager->attach('dispatch:beforeException', new NotFoundPlugin); $dispatcher = new Dispatcher(); $dispatcher->setEventsManager($eventsManager); return $dispatcher; }); //Real-Time notifications checker $di->set('notifications', function () { return new NotificationsChecker(); }, true); //Translation application use Gettext or Native Array $di->set('translation', function () use($di) { $language = $di->get('config')->language; $code = $language->code; if ($di->getCookies()->has('code')) { $code = $di->getCookies()->get('code')->getValue(); } if ($language->gettext) { $translation = new Gettext(['locale' => $code, 'directory' => ROOT_DIR . 'core/lang', 'defaultDomain' => 'messages']); } else { $path = ROOT_DIR . 'core/lang/messages/' . $code . '.php'; if (!file_exists($path)) { $di->getLogger()->error("You must specify a language file for language '{$code}'"); $path = ROOT_DIR . 'core/lang/messages/en.php'; } $translation = new NativeArray(['content' => require_once $path]); } return $translation; }, true); //Queue to deliver e-mails in real-time