当前位置: 首页>>代码示例>>PHP>>正文


PHP Session::instance方法代码示例

本文整理汇总了PHP中Terminus\Session::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::instance方法的具体用法?PHP Session::instance怎么用?PHP Session::instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Terminus\Session的用法示例。


在下文中一共展示了Session::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loggedIn

 /**
  * Determines if user is logged in
  *
  * @return [boolean] True if user is logged in
  */
 public static function loggedIn()
 {
     if (Session::instance()->getValue('session', false) === false) {
         throw new TerminusException('Please login first with `terminus auth login`');
     }
     return true;
 }
开发者ID:andrefy,项目名称:cli,代码行数:12,代码来源:Auth.php

示例2: __construct

 public function __construct()
 {
     # Load commonly used data from cache.
     $this->cache = Terminus::get_cache();
     $this->session = Session::instance();
     $this->sites = $this->cache->get_data('sites');
 }
开发者ID:xwp,项目名称:pantheon-cli,代码行数:7,代码来源:class-terminus-command.php

示例3: __construct

 /**
  * Instantiates object, sets cache and session
  *
  * @return [TerminusCommand] $this
  */
 public function __construct()
 {
     //Load commonly used data from cache
     $this->cache = Terminus::get_cache();
     $this->logger = Terminus::get_logger();
     $this->outputter = Terminus::get_outputter();
     $this->session = Session::instance();
 }
开发者ID:newtoid,项目名称:cli,代码行数:13,代码来源:class-terminus-command.php

示例4: __construct

 /**
  * Instantiates object, sets cache and session
  *
  * @return [TerminusCommand] $this
  */
 public function __construct()
 {
     //Load commonly used data from cache
     $this->cache = Terminus::getCache();
     $this->logger = Terminus::getLogger();
     $this->outputter = Terminus::getOutputter();
     $this->session = Session::instance();
     if (!Terminus::isTest()) {
         $this->checkForUpdate();
     }
 }
开发者ID:andrefy,项目名称:cli,代码行数:16,代码来源:class-terminus-command.php

示例5: __construct

 /**
  * Instantiates object, sets cache and session
  *
  * @param array $options Elements as follow:
  *        FileCache cache
  *        Logger    Logger
  *        Outputter Outputter
  *        Session   Session
  * @return TerminusCommand
  */
 public function __construct(array $options = [])
 {
     $this->cache = new FileCache();
     $this->runner = $options['runner'];
     $this->session = Session::instance();
     $this->logger = $this->runner->getLogger();
     $this->outputter = $this->runner->getOutputter();
     $this->loadHelpers();
     if (!Utils\isTest()) {
         Utils\checkForUpdate($this->log());
     }
 }
开发者ID:sammys,项目名称:terminus,代码行数:22,代码来源:TerminusCommand.php

示例6: fillCookieJar

 /**
  * Sets up and fills a cookie jar
  *
  * @param [array] $params Request data to fill jar with
  * @return [GuzzleHttp\Cookie\CookieJar] $jar
  */
 static function fillCookieJar($params)
 {
     $jar = new CookieJar();
     $cookies = array();
     if ($session = Session::instance()->get('session', false)) {
         $cookies['X-Pantheon-Session'] = $session;
     }
     if (isset($params['cookies'])) {
         $cookies = array_merge($cookies, $params['cookies']);
     }
     $jar->fromArray($cookies, '');
     return $jar;
 }
开发者ID:RobLoach,项目名称:cli,代码行数:19,代码来源:Request.php

示例7: getData

 public static function getData()
 {
     $session = Session::instance();
     return $session->data;
 }
开发者ID:jalama,项目名称:cli,代码行数:5,代码来源:Session.php

示例8: setInstanceData

 /**
  * Saves the session data to a cookie
  *
  * @param \stdClass $data Session data to save
  * @return bool Always true
  */
 private function setInstanceData(\stdClass $data)
 {
     if (!isset($data->machine_token)) {
         $machine_token = (array) Session::instance()->get('machine_token');
     } else {
         $machine_token = $data->machine_token;
     }
     $session = array('user_uuid' => $data->user_id, 'session' => $data->session, 'session_expire_time' => $data->expires_at);
     if ($machine_token && is_string($machine_token)) {
         $session['machine_token'] = $machine_token;
     }
     Session::instance()->setData($session);
     return true;
 }
开发者ID:dalin-,项目名称:cli,代码行数:20,代码来源:Auth.php

示例9: __construct

 /**
  * Object constructor, saves cache to cache property
  *
  * @return [SitesCache] $this
  */
 public function __construct()
 {
     $this->cache = Terminus::getCache();
     $this->cachekey = Session::instance()->get('user_uuid', '') . '_sites';
     $this->request = new Request();
 }
开发者ID:4aficiona2,项目名称:cli,代码行数:11,代码来源:SitesCache.php

示例10: doLogin

 /**
  * Execute the login based on email,password
  *
  * @param $email string (required)
  * @param $password string (required)
  * @package Terminus
  * @version 0.04-alpha
  * @return string
  */
 private function doLogin($email, $password)
 {
     if (Terminus::is_test()) {
         $data = array('user_uuid' => '77629472-3050-457c-8c3d-32b2cabf992b', 'session' => '77629472-3050-457c-8c3d-32b2cabf992b:7dc42f40-65f8-11e4-b314-bc764e100eb1:ZHR0TgtQYsKcOOwMOd0tk', 'session_expire_time' => '1417727066', 'email' => 'wink@getpantheon.com');
         return $data;
     }
     $options = array('body' => json_encode(array('email' => $email, 'password' => $password)), 'headers' => array('Content-type' => 'application/json'));
     $response = Terminus_Command::request('login', '', '', 'POST', $options);
     if (!$response or '200' != @$response['info']['http_code']) {
         \Terminus::error("[auth_error]: unsuccessful login");
     }
     // Prepare credentials for storage.
     $data = array('user_uuid' => $response['data']->user_id, 'session' => $response['data']->session, 'session_expire_time' => $response['data']->expires_at, 'email' => $email);
     // creates a session instance
     Session::instance()->setData($data);
     return $data;
 }
开发者ID:mikevanwinkle,项目名称:cli,代码行数:26,代码来源:auth.php

示例11: doLoginFromSessionToken

 /**
  * Execute the login based on an existing session token
  *
  * @param $session_token string (required)
  * @return array
  */
 private function doLoginFromSessionToken($session_token)
 {
     $options = array('headers' => array('Content-type' => 'application/json'), 'cookies' => array('X-Pantheon-Session' => $session_token));
     # Temporarily disable the cache for this GET call
     $response = TerminusCommand::request('user', '', '', 'GET', $options);
     if (!$response or '200' != @$response['info']['http_code']) {
         $this->failure('Session token not valid');
     }
     // Prepare credentials for storage.
     $data = array('user_uuid' => $response['data']->id, 'session' => $session_token, 'session_expire_time' => 0, 'email' => $response['data']->email);
     // creates a session instance
     Session::instance()->setData($data);
     return $data;
 }
开发者ID:andrefy,项目名称:cli,代码行数:20,代码来源:auth.php

示例12: loadAllCommands

 /**
  * Includes every command file in the commands directory
  *
  * @param CompositeCommand $parent The parent command to add the new commands to
  *
  * @return void
  */
 private static function loadAllCommands(CompositeCommand $parent)
 {
     // Create a list of directories where commands might live.
     $directories = array();
     // Add the directory of core commands first.
     $directories[] = TERMINUS_ROOT . '/php/Terminus/Commands';
     // Find the command directories from the third party plugins directory.
     foreach (self::getUserPlugins() as $dir) {
         $directories[] = "{$dir}/Commands/";
     }
     // Include all class files in the command directories.
     foreach ($directories as $cmd_dir) {
         if ($cmd_dir && file_exists($cmd_dir)) {
             $iterator = new \DirectoryIterator($cmd_dir);
             foreach ($iterator as $file) {
                 if ($file->isFile() && $file->isReadable() && $file->getExtension() == 'php') {
                     include_once $file->getPathname();
                 }
             }
         }
     }
     // Find the defined command classes and add them to the given base command.
     $classes = get_declared_classes();
     $options = ['cache' => self::getCache(), 'logger' => self::getLogger(), 'outputter' => self::getOutputter(), 'session' => Session::instance()];
     foreach ($classes as $class) {
         $reflection = new \ReflectionClass($class);
         if ($reflection->isSubclassOf('Terminus\\Commands\\TerminusCommand')) {
             Dispatcher\CommandFactory::create($reflection->getName(), $parent, $options);
         }
     }
 }
开发者ID:RazzYoshi,项目名称:cli,代码行数:38,代码来源:Terminus.php

示例13: setInstanceData

 /**
  * Saves the session data to a cookie
  *
  * @param [array] $data Session data to save
  * @return [boolean] Always true
  */
 private function setInstanceData($data)
 {
     if (!isset($data->refresh)) {
         $refresh = (array) Session::instance()->get('refresh');
     } else {
         $refresh = $data->refresh;
     }
     $session = array('user_uuid' => $data->user_id, 'session' => $data->session, 'session_expire_time' => $data->expires_at);
     if ($refresh && is_string($refresh)) {
         $session['refresh'] = $refresh;
     }
     Session::instance()->setData($session);
     return true;
 }
开发者ID:Zacker,项目名称:cli,代码行数:20,代码来源:Auth.php

示例14: testInstance

 public function testInstance()
 {
     $session = Session::instance();
     $this->assertInstanceOf('Terminus\\Session', $session);
 }
开发者ID:karudonaldson,项目名称:terminus,代码行数:5,代码来源:test-session.php

示例15: getValue

 /**
  * Returnes session data indicated by the key
  *
  * @param [string] $key Name of session property to retrieve
  * @return [mixed] $session_property
  */
 public static function getValue($key)
 {
     $session = Session::instance();
     $session_property = $session->get($key);
     return $session_property;
 }
开发者ID:4aficiona2,项目名称:cli,代码行数:12,代码来源:Session.php


注:本文中的Terminus\Session::instance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。