*/
public static function init(string $name, int $cookieLifetime = 72576000): bool
{
$proceeded = false;
if (session_status() === PHP_SESSION_NONE) {
session_name($name);
session_set_cookie_params($cookieLifetime);
ini_set('session.gc_maxlifetime', $cookieLifetime);
ini_set('session.cookie_lifetime', $cookieLifetime);
session_start();
if (session_status() === PHP_SESSION_DISABLED) {
$message .= 'because its disabled. If you want to use flash mesages, enable sessions first';
$sessionAvailable = false;
} elseif (session_status() === PHP_SESSION_NONE) {
$sessionName = "{$projectName}_$context";
SessionUtils::init($sessionName);
}
if (!$sessionAvailable) {
throw new MissingDataException($message);
}
}
}
} else {
$r = new \ReflectionClass($parameterBag->resolveValue($definition->getClass()));
$service = null === $r->getConstructor() ? $r->newInstance() : $r->newInstanceArgs(array_values($arguments));
if (!$definition->isDeprecated() && 0 < strpos($r->getDocComment(), "\n * @deprecated ")) {
trigger_deprecation('', '', 'The "%s" service relies on the deprecated "%s" class. It should either be deprecated or its implementation upgraded.', $id, $r->name);
}
}
$types[$k] = $v instanceof TypedReference ? $v->getType() : '?';
}
}
$value = new ServiceLocator(\Closure::fromCallable([$this, 'resolveServices']), $refs, $types);
} elseif ($value instanceof Reference) {
$value = $this->doGet((string) $value, $value->getInvalidBehavior(), $inlineServices, $isConstructorArgument);
} elseif ($value instanceof Definition) {
$value = $this->createService($value, $inlineServices, $isConstructorArgument);
} elseif ($value instanceof Parameter) {
$value = $this->getParameter((string) $value);
} elseif ($value instanceof Expression) {
private function doResolveServices($value, array &$inlineServices = [], bool $isConstructorArgument = false)
{
if (\is_array($value)) {
foreach ($value as $k => $v) {
$value[$k] = $this->doResolveServices($v, $inlineServices, $isConstructorArgument);
}
} elseif ($value instanceof ServiceClosureArgument) {
$reference = $value->getValues()[0];
$value = function () use ($reference) {
return $this->resolveServices($reference);
if (null !== $definition->getFile()) {
require_once $parameterBag->resolveValue($definition->getFile());
}
$arguments = $this->doResolveServices($parameterBag->unescapeValue($parameterBag->resolveValue($definition->getArguments())), $inlineServices, $isConstructorArgument);
if (null !== $factory = $definition->getFactory()) {
if (\is_array($factory)) {
$factory = [$this->doResolveServices($parameterBag->resolveValue($factory[0]), $inlineServices, $isConstructorArgument), $factory[1]];
} elseif (!\is_string($factory)) {
$types[$k] = $v instanceof TypedReference ? $v->getType() : '?';
}
}
$value = new ServiceLocator(\Closure::fromCallable([$this, 'resolveServices']), $refs, $types);
} elseif ($value instanceof Reference) {
$value = $this->doGet((string) $value, $value->getInvalidBehavior(), $inlineServices, $isConstructorArgument);
} elseif ($value instanceof Definition) {
$value = $this->createService($value, $inlineServices, $isConstructorArgument);
} elseif ($value instanceof Parameter) {
$value = $this->getParameter((string) $value);
} elseif ($value instanceof Expression) {
* @return mixed The same value with all service references replaced by
* the real service instances and all expressions evaluated
*/
public function resolveServices($value)
{
return $this->doResolveServices($value);
}
private function doResolveServices($value, array &$inlineServices = [], bool $isConstructorArgument = false)
{
if (\is_array($value)) {
$value[$k] = $this->doResolveServices($v, $inlineServices, $isConstructorArgument);
}
} elseif ($value instanceof ServiceClosureArgument) {
$reference = $value->getValues()[0];
$value = function () use ($reference) {
return $this->resolveServices($reference);
};
} elseif ($value instanceof IteratorArgument) {
$value = new RewindableGenerator(function () use ($value, &$inlineServices) {
foreach ($value->getValues() as $k => $v) {
foreach (self::getServiceConditionals($v) as $s) {
foreach ($listeners as &$listener) {
$closure = &$this->optimized[$eventName][];
if (\is_array($listener) && isset($listener[0]) && $listener[0] instanceof \Closure && 2 >= \count($listener)) {
$closure = static function (...$args) use (&$listener, &$closure) {
if ($listener[0] instanceof \Closure) {
$listener[0] = $listener[0]();
$listener[1] = $listener[1] ?? '__invoke';
}
($closure = \Closure::fromCallable($listener))(...$args);
};
} else {
use Radar\Event\ResetCacheEvent;
/* Always reset cache if env is dev */
if ($container->getParameter('project.env') === 'dev') {
$resetCacheEvent = new ResetCacheEvent($container->get('fileCache'), $container->get('projectCache'), $container->get('fileNameToQuestionNameBag'));
$dispatcher->dispatch($resetCacheEvent, $resetCacheEvent::NAME);
$resetTwigCacheEvent = new ForceResetTwigCacheEvent($container->getParameter('twig.path_to_compilation_cache'));
$dispatcher->dispatch($resetTwigCacheEvent, $resetTwigCacheEvent::NAME);
}
$errorHadler->setDefaultLogger($logger);
ErrorHandler::register($errorHadler);
}
/* End error handling */
require 'init.php';
$matcher = new UrlMatcher($routes, new RequestContext());
$dispatcher->addSubscriber(new RouterListener($matcher, new RequestStack()));
$kernel = $container->get('http_kernel');
ErrorException |
---|
ErrorException: Warning: session_name(): Session name cannot be changed after headers have already been sent at /var/www/radar/data/www/radar-survey.ru/Q21-52/src/Radar/Utils/SessionUtils.php:23 at Radar\Utils\SessionUtils::init() (/var/www/radar/data/www/radar-survey.ru/Q21-52/src/Radar/Flash/FlashBag.php:39) at Radar\Flash\FlashBag->__construct() at ReflectionClass->newInstanceArgs() (/var/www/radar/data/www/radar-survey.ru/Q21-52/vendor/symfony/dependency-injection/ContainerBuilder.php:1091) at Symfony\Component\DependencyInjection\ContainerBuilder->createService() (/var/www/radar/data/www/radar-survey.ru/Q21-52/vendor/symfony/dependency-injection/ContainerBuilder.php:597) at Symfony\Component\DependencyInjection\ContainerBuilder->doGet() (/var/www/radar/data/www/radar-survey.ru/Q21-52/vendor/symfony/dependency-injection/ContainerBuilder.php:1214) at Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() (/var/www/radar/data/www/radar-survey.ru/Q21-52/vendor/symfony/dependency-injection/ContainerBuilder.php:1162) at Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() (/var/www/radar/data/www/radar-survey.ru/Q21-52/vendor/symfony/dependency-injection/ContainerBuilder.php:1064) at Symfony\Component\DependencyInjection\ContainerBuilder->createService() (/var/www/radar/data/www/radar-survey.ru/Q21-52/vendor/symfony/dependency-injection/ContainerBuilder.php:597) at Symfony\Component\DependencyInjection\ContainerBuilder->doGet() (/var/www/radar/data/www/radar-survey.ru/Q21-52/vendor/symfony/dependency-injection/ContainerBuilder.php:1214) at Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() (/var/www/radar/data/www/radar-survey.ru/Q21-52/vendor/symfony/dependency-injection/ContainerBuilder.php:1155) at Symfony\Component\DependencyInjection\ContainerBuilder->resolveServices() (/var/www/radar/data/www/radar-survey.ru/Q21-52/vendor/symfony/dependency-injection/ContainerBuilder.php:1167) at Symfony\Component\DependencyInjection\ContainerBuilder->Symfony\Component\DependencyInjection\{closure}() (/var/www/radar/data/www/radar-survey.ru/Q21-52/vendor/symfony/event-dispatcher/EventDispatcher.php:267) at Symfony\Component\EventDispatcher\EventDispatcher::Symfony\Component\EventDispatcher\{closure}() (/var/www/radar/data/www/radar-survey.ru/Q21-52/vendor/symfony/event-dispatcher/EventDispatcher.php:230) at Symfony\Component\EventDispatcher\EventDispatcher->callListeners() (/var/www/radar/data/www/radar-survey.ru/Q21-52/vendor/symfony/event-dispatcher/EventDispatcher.php:59) at Symfony\Component\EventDispatcher\EventDispatcher->dispatch() (/var/www/radar/data/www/radar-survey.ru/Q21-52/init.php:9) at require('/var/www/radar/data/www/radar-survey.ru/Q21-52/init.php') (/var/www/radar/data/www/radar-survey.ru/Q21-52/index.php:47) |