Example #1
0
 /**
  * Bootstrap the session.
  *
  * @param Config $config The session config
  */
 public static function bootstrap(Config $config)
 {
     if (!$config->cookie_name) {
         $config->cookie_name = 'session_id';
     }
     if (!$config->id_format) {
         $config->id_format = Handler::DEFAULT_ID_FORMAT;
     }
     // Create and set the session save handler
     static::$handler = new Handler($config);
     session_set_save_handler(static::$handler, true);
     // Set the session name
     session_name($config->cookie_name);
     // Set the cookie parameters
     $app = Application::instance();
     $path = $app->config->base_uri ?: '/';
     $domain = $app->config->domain ?: $_SERVER['HTTP_HOST'];
     $secure = $app->request->isSecure();
     $lifetime = $config->lifetime ?: 2592000;
     session_set_cookie_params($lifetime, $path, $domain, $secure, true);
     // Start the session
     session_start();
     // Register session_write_close() as a shutdown function
     session_register_shutdown();
 }
 /**
  * share gateway
  */
 public static function getHandler()
 {
     if (is_null(static::$handler)) {
         static::$handler = new RequestHandler(new TokenResolver());
     }
     return static::$handler;
 }
Example #3
0
 /**
  * Get the handhandle instance.
  *
  * @return self
  */
 public static function getIns()
 {
     if (!isset(static::$handler)) {
         static::$handler = new self();
     }
     return static::$handler;
 }
Example #4
0
 /**
  * Resolves the facade instance 
  * @return object FormHandler
  */
 public static function resolveFacadeInstance()
 {
     if (is_object(static::$handler)) {
         return static::$handler;
     }
     $decorator = static::getDecorator();
     return static::$handler = new FormHandler($decorator);
 }
Example #5
0
 /**
  * __constructStatic
  *
  * @return void
  */
 public static function __constructStatic()
 {
     static::$handler = new static();
 }
Example #6
0
 /**
  * Return \PDO database handler
  *
  * @return \PDO
  */
 protected static function getHandler()
 {
     if (!isset(static::$handler)) {
         static::$handler = static::connectToDb();
     }
     return static::$handler;
 }
 /**
  * 테마 핸들러를 지정한다.
  *
  * @param ThemeHandler $handler 테마 핸들러
  *
  * @return void
  */
 public static function setHandler(ThemeHandler $handler)
 {
     static::$handler = $handler;
 }
Example #8
0
 /**
  * Load a Template Handler
  * @param  class $handler The template handler class instance
  */
 public static function using(View\Adapter $handler)
 {
     static::$handler = $handler;
 }
 static function setHandler(Handler\IOutputHandler $handler)
 {
     static::$handler = $handler;
 }
Example #10
0
 /**
  * Upload a file
  *
  * @param string $localFile Path to the file
  * @param string $remoteFileName Name of this file on remote server
  * @param string $error Error detail
  *
  * @throws Exception\ServerTypeMustSet
  * @throws Exception\ServerTypeNotSupported
  * @throws Exception\ServerHandlerInterfaceInvalid
  * @throws Exception\TargetFileUnreadable
  *
  * @return mixed Return path on the remote server when success, false otherwise
  */
 public static function upload($localFile, $remoteFileName = '', &$error = '')
 {
     $handler = null;
     if (!is_readable($localFile)) {
         throw new Exception\TargetFileUnreadable($localFile);
     }
     // Create handler instance
     if (!static::$handler) {
         foreach (static::$servers as $serverNo => $server) {
             if (!isset($server['Type'][0])) {
                 throw new Exception\ServerTypeMustSet($serverNo);
             }
             $operatorName = static::getOperator($server['Type']);
             if (!class_exists($operatorName)) {
                 throw new Exception\ServerTypeNotSupported($serverNo);
             }
             $handler = new $operatorName(isset($server['Option']) ? $server['Option'] : array());
             if (!$handler instanceof OperatorImplement) {
                 throw new Exception\ServerHandlerInterfaceInvalid($serverNo);
             }
             if ($result = static::runHandler($handler, $localFile, $remoteFileName, $error)) {
                 static::$handler = $handler;
                 return $result;
             } else {
                 unset($handler);
             }
         }
     } else {
         return static::runHandler(static::$handler, $localFile, $remoteFileName, $error);
     }
     return false;
 }
Example #11
0
 /**
  * Add an argument(sub command) setting.
  *
  * @param   string|AbstractCommand  $command      The argument name or Console object.
  *                                                If we just send a string, the object will auto create.
  * @param   string                  $description  Console description.
  * @param   Option[]                $options      Console options.
  * @param   \Closure                $handler      The closure to execute.
  *
  * @return  AbstractCommand  Return this object to support chaining.
  *
  * @since   2.0
  */
 public function addCommand($command, $description = null, $options = array(), \Closure $handler = null)
 {
     if (!$command instanceof AbstractCommand) {
         $command = new static($command, $this->io, $this);
     }
     // Set argument detail
     $command->setApplication($this->app)->setIO($this->io);
     if ($description !== null) {
         $command->description($description);
     }
     if (count($options)) {
         $command->setOptions($options);
     }
     if ($handler) {
         $command->handler($handler);
     }
     // Set parent
     $command->setParent($this);
     // Set global options to sub command
     /** @var $option Option */
     foreach ($this->globalOptions as $option) {
         $command->addGlobalOption($option);
     }
     $name = $command->getName();
     $this->children[$name] = $command;
     return $command;
 }
Example #12
0
 /**
  * Return instance of the entity manager
  *
  * @return \Doctrine\ORM\EntityManager
  */
 protected static function getHandler()
 {
     if (!isset(static::$handler)) {
         static::$handler = \Doctrine\ORM\EntityManager::create(static::getDSN(), static::getConfig());
         \XLite\Core\Database::registerCustomTypes(static::$handler);
     }
     return static::$handler;
 }
Example #13
0
 public static function init($name = 'alien-session')
 {
     static::$name = $name;
     $handler_class = Config::get('session.handlers')[Config::get('session.handler')];
     static::$handler = new $handler_class();
 }
Example #14
0
 /**
  * @param bool $display
  * @param Logger|null $logger
  * @return Debug
  */
 public static function getHandler($display = true, Logger $logger = null)
 {
     if (null === static::$handler) {
         static::$handler = new static($display, $logger);
     }
     return static::$handler;
 }
Example #15
0
 /**
  * Load a Template Handler
  * @param  class $handler The template handler class instance
  */
 public static function using(&$handler)
 {
     static::$handler = $handler;
 }