hasParameter($parameter)) { return self::$container->getParameter($parameter); } return false; } /** * @return string */ public static function getEnvironment() { return self::$container->get('kernel')->getEnvironment(); } /** * @return RoleHierarchy */ public static function getRoles() { return self::$container->get('security.role_hierarchy'); } /** * @return string */ public static function getLogDir() { return self::$container->get('kernel')->getLogDir(); } /** * @return string */ public static function getTempDir() { return self::$container->get('kernel')->getCacheDir().'/'; } /** * @return string */ public static function getRootDir() { if (isset(self::$container)) { return self::$container->get('kernel')->getRealRootDir(); } return str_replace('\\', '/', realpath(__DIR__.'/../../../')).'/'; } /** * @return string */ public static function getUrlAppend() { return self::$container->get('kernel')->getUrlAppend(); } /** * @return string */ public static function isInstalled() { return self::$container->get('kernel')->isInstalled(); } /** * @return string */ public static function getDataDir() { return self::$dataDir; } /** * @return string */ public static function getCourseDir() { return self::$courseDir; } /** * @return \Twig_Environment */ public static function getTwig() { return self::$container->get('twig'); } /** * @return \Symfony\Bundle\TwigBundle\TwigEngine */ public static function getTemplating() { return self::$container->get('templating'); } /** * @return Editor */ public static function getHtmlEditor() { return self::$container->get('chamilo_core.html_editor'); } /** * @return \Symfony\Bundle\FrameworkBundle\Routing\Router */ public static function getUrlGenerator() { return self::$container->get('router'); } /** * @return object|Request */ public static function getRequest() { if (!empty(self::$request)) { return self::$request; } return self::$container->get('request'); } public static function setRequest($request) { self::$request = $request; } /** * @return Session|false */ public static function getSession() { if (self::$container && self::$container->has('session')) { return self::$container->get('session'); } return false; } /** * @return AuthorizationChecker */ public static function getAuthorizationChecker() { return self::$container->get('security.authorization_checker'); } /** * @return object|\Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage */ public static function getTokenStorage() { return self::$container->get('security.token_storage'); } /** * @return TranslatorInterface */ public static function getTranslator() { if (isset(self::$translator)) { return self::$translator; } if (self::$container) { return self::$container->get('translator.default'); } return false; } /** * @return CoreAssetsHelper */ public static function getAsset() { return self::$container->get('templating.helper.assets'); } /** * @return \Swift_Mailer */ public static function getMailer() { return self::$container->get('mailer'); } /** * @return \Elao\WebProfilerExtraBundle\TwigProfilerEngine */ public static function getTemplate() { return self::$container->get('templating'); } /** * @return SettingsManager */ public static function getSettingsManager() { return self::$settingsManager; } /** * @param SettingsManager $manager */ public static function setSettingsManager($manager) { self::$settingsManager = $manager; } /** * @return \Chamilo\CourseBundle\Manager\SettingsManager */ public static function getCourseSettingsManager() { return self::$container->get('chamilo_course.settings.manager'); } /** * @return \Doctrine\ORM\EntityManager */ public static function getEntityManager() { return \Database::getManager(); } /** * @return UserManager */ public static function getUserManager() { return self::$userManager; } /** * @param UserManager */ public static function setUserManager($manager) { self::$userManager = $manager; } /** * @return SiteManager */ public static function getSiteManager() { return self::$siteManager; } /** * @param UserManager */ public static function setSiteManager($manager) { self::$siteManager = $manager; } /** * @return \Sonata\UserBundle\Entity\GroupManager */ public static function getGroupManager() { return self::$container->get('fos_user.group_manager'); } /** * @return \Symfony\Component\HttpKernel\Debug\TraceableEventDispatcher */ public static function getEventDispatcher() { return self::$container->get('event_dispatcher'); } /** * @return \Symfony\Component\Form\FormFactory */ public static function getFormFactory() { return self::$container->get('form.factory'); } /** * @param string $message * @param string $type error|success|warning|danger */ public static function addFlash($message, $type = 'success') { $session = self::getSession(); $session->getFlashBag()->add($type, $message); } /** * @return object|\Symfony\Cmf\Component\Routing\ChainRouter */ public static function getRouter() { return self::$container->get('router'); } /** * @return \Chamilo\CourseBundle\ToolChain */ public static function getToolChain() { return self::$container->get('chamilo_course.tool_chain'); } /** * @param ContainerInterface $container */ public static function setLegacyServices($container) { \Database::setConnection($container->get('doctrine.dbal.default_connection')); \Database::setManager($container->get('doctrine.orm.entity_manager')); Container::setSettingsManager($container->get('chamilo.settings.manager')); Container::setUserManager($container->get('sonata.user.user_manager')); Container::setSiteManager($container->get('sonata.page.manager.site')); Container::$session = $container->get('session'); } }