本文整理汇总了PHP中Chamilo\CoreBundle\Framework\Container::courseDir方法的典型用法代码示例。如果您正苦于以下问题:PHP Container::courseDir方法的具体用法?PHP Container::courseDir怎么用?PHP Container::courseDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chamilo\CoreBundle\Framework\Container
的用法示例。
在下文中一共展示了Container::courseDir方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: classicAction
/**
* @param string $name
* @param Request $request
* @return Response
*/
public function classicAction($name, Request $request)
{
// get.
$_GET = $request->query->all();
// post.
$_POST = $request->request->all();
$rootDir = $this->get('kernel')->getRealRootDir();
//$_REQUEST = $request->request->all();
$mainPath = $rootDir . 'main/';
$fileToLoad = $mainPath . $name;
// Setting legacy values inside the container
/** @var Connection $dbConnection */
$dbConnection = $this->container->get('database_connection');
$em = $this->get('kernel')->getContainer()->get('doctrine.orm.entity_manager');
$database = new \Database($dbConnection, array());
$database->setConnection($dbConnection);
$database->setManager($em);
Container::$container = $this->container;
Container::$dataDir = $this->container->get('kernel')->getDataDir();
Container::$courseDir = $this->container->get('kernel')->getDataDir();
//Container::$configDir = $this->container->get('kernel')->getConfigDir();
$this->container->get('twig')->addGlobal('api_get_cidreq', api_get_cidreq());
//$breadcrumb = $this->container->get('chamilo_core.block.breadcrumb');
if (is_file($fileToLoad) && \Security::check_abs_path($fileToLoad, $mainPath)) {
// Files inside /main need this variables to be set
$is_allowed_in_course = api_is_allowed_in_course();
$is_courseAdmin = api_is_course_admin();
$is_platformAdmin = api_is_platform_admin();
$toolNameFromFile = basename(dirname($fileToLoad));
$charset = 'UTF-8';
// Default values
$_course = api_get_course_info();
$_user = api_get_user_info();
$debug = $this->container->get('kernel')->getEnvironment() == 'dev' ? true : false;
// Loading file
ob_start();
require_once $fileToLoad;
$out = ob_get_contents();
ob_end_clean();
// No browser cache when executing an exercise.
if ($name == 'exercice/exercise_submit.php') {
$responseHeaders = array('cache-control' => 'no-store, no-cache, must-revalidate');
}
$js = isset($htmlHeadXtra) ? $htmlHeadXtra : array();
// $interbreadcrumb is loaded in the require_once file.
$interbreadcrumb = isset($interbreadcrumb) ? $interbreadcrumb : null;
$template = Container::$legacyTemplate;
$defaultLayout = 'layout_one_col.html.twig';
if (!empty($template)) {
$defaultLayout = $template;
}
return $this->render('ChamiloCoreBundle::' . $defaultLayout, array('legacy_breadcrumb' => $interbreadcrumb, 'content' => $out, 'js' => $js));
} else {
// Found does not exist
throw new NotFoundHttpException();
}
}
示例2: classicAction
/**
* @param $name
* @param Request $request
* @return Response
*/
public function classicAction($name, Request $request)
{
// get.
$_GET = $request->query->all();
// post.
$_POST = $request->request->all();
$rootDir = $this->get('kernel')->getRealRootDir();
//$_REQUEST = $request->request->all();
$mainPath = $rootDir . 'main/';
$fileToLoad = $mainPath . $name;
// Legacy inclusions
Container::setSession($request->getSession());
$dbConnection = $this->container->get('database_connection');
$database = new \Database($dbConnection, array());
Container::$urlGenerator = $this->container->get('router');
Container::$security = $this->container->get('security.context');
Container::$translator = $this->container->get('translator');
Container::$assets = $this->container->get('templating.helper.assets');
Container::$rootDir = $this->container->get('kernel')->getRealRootDir();
Container::$logDir = $this->container->get('kernel')->getLogDir();
Container::$dataDir = $this->container->get('kernel')->getDataDir();
Container::$tempDir = $this->container->get('kernel')->getCacheDir();
Container::$courseDir = $this->container->get('kernel')->getDataDir();
//Container::$configDir = $this->container->get('kernel')->getConfigDir();
Container::$htmlEditor = $this->container->get('chamilo_core.html_editor');
Container::$twig = $this->container->get('twig');
if (is_file($fileToLoad) && \Security::check_abs_path($fileToLoad, $mainPath)) {
$toolNameFromFile = basename(dirname($fileToLoad));
$charset = 'UTF-8';
// Default values
$_course = api_get_course_info();
$_user = api_get_user_info();
/*
$text_dir = api_get_text_direction();
$is_platformAdmin = api_is_platform_admin();
$_cid = api_get_course_id();*/
$debug = $this->container->get('kernel')->getEnvironment() == 'dev' ? true : false;
// Loading file
ob_start();
require_once $fileToLoad;
$out = ob_get_contents();
ob_end_clean();
// No browser cache when executing an exercise.
if ($name == 'exercice/exercise_submit.php') {
$responseHeaders = array('cache-control' => 'no-store, no-cache, must-revalidate');
}
$js = isset($htmlHeadXtra) ? $htmlHeadXtra : array();
// $interbreadcrumb is loaded in the require_once file.
$interbreadcrumb = isset($interbreadcrumb) ? $interbreadcrumb : null;
//$this->getTemplate()->setBreadcrumb($interbreadcrumb);
//$breadCrumb = $this->getTemplate()->getBreadCrumbLegacyArray();
//$menu = $this->parseLegacyBreadCrumb($breadCrumb);
//$this->getTemplate()->assign('new_breadcrumb', $menu);
//$this->getTemplate()->parseResources();
/*if (isset($tpl)) {
$response = $app['twig']->render($app['default_layout']);
} else {
$this->getTemplate()->assign('content', $out);
$response = $app['twig']->render($app['default_layout']);
}*/
return $this->render('ChamiloCoreBundle:Legacy:index.html.twig', array('content' => $out, 'js' => $js));
} else {
throw new NotFoundHttpException();
}
}
示例3: onKernelRequest
/**
* @param GetResponseEvent $event
*/
public function onKernelRequest(GetResponseEvent $event)
{
$kernel = $event->getKernel();
$request = $event->getRequest();
$session = $request->getSession();
/** @var ContainerInterface $container */
$container = $this->container;
// Setting container
Container::setContainer($container);
// Setting session.
Container::setSession($request->getSession());
// Setting database.
$dbConnection = $container->get('database_connection');
// Setting DB connection and Doctrine Manager.
$database = new \Database();
$database->setConnection($dbConnection);
$entityManager = $container->get('doctrine')->getManager();
$database->setManager($entityManager);
// Setting course tool chain (in order to create tools to a course)
\CourseManager::setToolList($container->get('chamilo_course.tool_chain'));
\CourseManager::setEntityManager($entityManager);
\CourseManager::setCourseManager($container->get('chamilo_core.manager.course'));
\CourseManager::setCourseSettingsManager($container->get('chamilo_course.settings.manager'));
Container::$mailer = $container->get('mailer');
// Setting legacy properties.
Container::$urlGenerator = $container->get('router');
Container::$security = $container->get('security.context');
Container::$translator = $container->get('translator');
// Setting paths.
Container::$rootDir = $container->get('kernel')->getRealRootDir();
Container::$logDir = $container->get('kernel')->getLogDir();
Container::$dataDir = $container->get('kernel')->getDataDir();
Container::$tempDir = $container->get('kernel')->getCacheDir();
Container::$courseDir = $container->get('kernel')->getDataDir();
//Container::$configDir = $container->get('kernel')->getConfigDir();
Container::$assets = $container->get('templating.helper.assets');
Container::$roles = $container->get('security.role_hierarchy');
// Setting editor
Container::$htmlEditor = $container->get('chamilo_core.html_editor');
if (!defined('DEFAULT_DOCUMENT_QUOTA')) {
$default_quota = api_get_setting('document.default_document_quotum');
// Just in case the setting is not correctly set
if (empty($default_quota)) {
$default_quota = 100000000;
}
define('DEFAULT_DOCUMENT_QUOTA', $default_quota);
}
// Access URL (multiple URL)
/** @var \Sonata\PageBundle\Model\SnapshotPageProxy $page */
$page = $request->get('page');
if (isset($page) && !is_numeric($page)) {
$siteId = $page->getSite()->getId();
$request->getSession()->set('url_info', $page->getSite());
} else {
$siteId = 1;
}
$request->getSession()->set('url_id', $siteId);
/*
// Loading portal settings from DB.
$settingsRefreshInfo = $em->getRepository('ChamiloCoreBundle:SettingsCurrent')->findOneByVariable('settings_latest_update');
$settingsLatestUpdate = !empty($settingsRefreshInfo) ? $settingsRefreshInfo->getSelectedValue() : null;
$settings = $session->get('_setting');
if (empty($settings)) {
api_set_settings_and_plugins();
} else {
if (isset($settings['settings_latest_update']) &&
$settings['settings_latest_update'] != $settingsLatestUpdate
) {
api_set_settings_and_plugins();
}
}*/
}
示例4: onKernelRequest
/**
* @param GetResponseEvent $event
*/
public function onKernelRequest(GetResponseEvent $event)
{
$request = $event->getRequest();
$session = $request->getSession();
/** @var ContainerInterface $container */
$container = $this->container;
// Setting container
Container::setContainer($container);
// Setting database.
$connection = $container->get('database_connection');
// Setting DB connection and Doctrine Manager.
$database = new \Database();
$database->setConnection($connection);
$entityManager = $container->get('doctrine')->getManager();
$database->setManager($entityManager);
\CourseManager::setEntityManager($entityManager);
\CourseManager::setCourseSettingsManager($container->get('chamilo_course.settings.manager'));
// Legacy way of detect current access_url
$installed = $this->container->getParameter('installed');
$urlId = 1;
if (!empty($installed)) {
$access_urls = api_get_access_urls();
$root_rel = api_get_self();
$root_rel = substr($root_rel, 1);
$pos = strpos($root_rel, '/');
$root_rel = substr($root_rel, 0, $pos);
$protocol = (!empty($_SERVER['HTTPS']) && strtoupper($_SERVER['HTTPS']) != 'OFF' ? 'https' : 'http') . '://';
//urls with subdomains (HTTP_HOST is preferred - see #6764)
if (empty($_SERVER['HTTP_HOST'])) {
if (empty($_SERVER['SERVER_NAME'])) {
$request_url_root = $protocol . 'localhost/';
} else {
$request_url_root = $protocol . $_SERVER['SERVER_NAME'] . '/';
}
} else {
$request_url_root = $protocol . $_SERVER['HTTP_HOST'] . '/';
}
//urls with subdirs
$request_url_sub = $request_url_root . $root_rel . '/';
// You can use subdirs as multi-urls, but in this case none of them can be
// the root dir. The admin portal should be something like https://host/adm/
// At this time, subdirs will still hold a share cookie, so not ideal yet
// see #6510
$urlId = 1;
foreach ($access_urls as $details) {
if ($request_url_sub == $details['url']) {
$urlId = $details['id'];
break;
//found one match with subdir, get out of foreach
}
// Didn't find any? Now try without subdirs
if ($request_url_root == $details['url']) {
$urlId = $details['id'];
break;
//found one match, get out of foreach
}
}
}
$session->set('access_url_id', $urlId);
// Setting course tool chain (in order to create tools to a course)
\CourseManager::setToolList($container->get('chamilo_course.tool_chain'));
\CourseManager::setCourseManager($container->get('chamilo_core.manager.course'));
// Setting legacy properties.
Container::$dataDir = $container->get('kernel')->getDataDir();
Container::$courseDir = $container->get('kernel')->getDataDir();
}