Example #1
0
 public function __construct(\SessionHandlerInterface $handler = null, SessionParams $params = null)
 {
     parent::__construct();
     if ($this->isDisabled()) {
         throw new \RuntimeException("Sessions are not enabled on this server");
     }
     if ($this->isOpen()) {
         throw new \RuntimeException("Session is already open, ensure session.auto_start is disabled");
     }
     // Prevent session-fixation
     // See: http://en.wikipedia.org/wiki/Session_fixation
     ini_set("session.session.use_only_cookies", 1);
     // Use the SHA-1 hashing algorithm
     ini_set("session.hash_function", 1);
     // Increase character-range of the session ID to help prevent brute-force attacks
     ini_set("session.hash_bits_per_character", 6);
     if (null === $handler) {
         $handler = new \SessionHandler();
     }
     if (null === $params) {
         $params = new SessionParams();
     }
     register_shutdown_function(function () {
         if ($this->isOpen()) {
             $this->close();
         }
     });
     $this->setHandler($handler)->setParams($params);
 }
Example #2
0
 public function __construct($name, Services $services = null, $environment = self::ENVIRONMENT_PROD, $debugMode = false, $rootDir = null)
 {
     parent::__construct();
     if (null === $rootDir) {
         $rootDir = __DIR__ . "/../../../../";
     }
     if (null === $services) {
         $services = new Services();
     }
     $this->setRootDir($rootDir)->setName($name)->setServices($services)->setEnvironment($environment)->setDebugMode($debugMode);
     (new ExceptionHandler($this))->register();
     (new ErrorHandler($this))->register();
 }
Example #3
0
 public function __construct(Application $application, $level = Logger::DEBUG, $bubble = true, \DateTime $requestDateTime = null, Records $records = null, Processors $processors = null, FormatterInterface $formatter = null)
 {
     parent::__construct();
     if (null === $requestDateTime) {
         $requestDateTime = new \DateTime();
     }
     if (null === $records) {
         $records = new Records();
     }
     if (null === $processors) {
         $processors = new Processors();
     }
     if (null === $formatter) {
         $formatter = new ConsoleFormatter();
     }
     $this->setApplication($application)->setLevel($level)->setBubble($bubble)->setRequestDateTime($requestDateTime)->setRecords($records)->setProcessors($processors)->setFormatter($formatter);
     $application->before("handle", [$this, "beforeHandleEvent"])->before("send", [$this, "beforeSendEvent"]);
 }