Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ services:
- setKernel: [ '@kernel' ]
- setMessengerBus: [ '@messenger.bus.default' ]
- setValidator: [ '@validator' ]
- setSessionFactory: [ '@session.factory' ]

cocur_slugify:
lowercase: true
Expand Down
10 changes: 6 additions & 4 deletions public/main/inc/global.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,21 @@
}

$container = $kernel->getContainer();
Container::setContainer($container);
$session = Container::getLegacyHelper()->getSession();
$request = Request::create('/');
$request->setSession($session);
$container->get('request_stack')->push($request);
Container::setLegacyServices($container);
$router = $container->get('router');
$context = $router->getContext();
$router->setContext($context);
Database::setManager($container->get('doctrine.orm.entity_manager'));

$cliOptions = getopt('', ['url:']);
if (!empty($cliOptions['url'])) {
$baseUrl = $cliOptions['url'];
$context->setBaseUrl($baseUrl);
}

echo "CLI mode: EntityManager initialized.\n";

} else {
$kernel = new Chamilo\Kernel($env, $debug);
// Loading Request from Sonata. In order to use Sonata Pages Bundle.
Expand Down
15 changes: 15 additions & 0 deletions src/CoreBundle/ServiceHelper/ContainerHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

namespace Chamilo\CoreBundle\ServiceHelper;

use Symfony\Component\HttpFoundation\Session\SessionFactoryInterface;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\HttpKernel\KernelInterface;
use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
Expand All @@ -19,6 +21,7 @@ class ContainerHelper
private KernelInterface $kernel;
private MessageBusInterface $messengerBus;
private ValidatorInterface $validator;
private SessionFactoryInterface $sessionFactory;

public function getAuthorizationChecker(): AuthorizationCheckerInterface
{
Expand Down Expand Up @@ -69,4 +72,16 @@ public function setValidator(ValidatorInterface $validator): void
{
$this->validator = $validator;
}

public function getSession(): SessionInterface
{
return $this->sessionFactory->createSession();
}

public function setSessionFactory(SessionFactoryInterface $sessionFactory): ContainerHelper
{
$this->sessionFactory = $sessionFactory;

return $this;
}
}
Loading