本文整理汇总了PHP中Terminus\Session::getValue方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::getValue方法的具体用法?PHP Session::getValue怎么用?PHP Session::getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Terminus\Session
的用法示例。
在下文中一共展示了Session::getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAliases
/**
* Requests API data and returns aliases
*
* @return string
*/
private function getAliases()
{
$request = new Request();
$user = new User();
$path = 'drush_aliases';
$method = 'GET';
$response = $request->request('users', Session::getValue('user_id'), $path, $method);
eval(str_replace('<?php', '', $response['data']->drush_aliases));
$formatted_aliases = substr($response['data']->drush_aliases, 0, -1);
$sites_object = new Sites();
$sites = $sites_object->all();
foreach ($sites as $site) {
$environments = $site->environments->all();
foreach ($environments as $environment) {
$key = $site->get('name') . '.' . $environment->get('id');
if (isset($aliases[$key])) {
break;
}
try {
$formatted_aliases .= PHP_EOL . " \$aliases['{$key}'] = ";
$formatted_aliases .= $this->constructAlias($environment);
} catch (TerminusException $e) {
continue;
}
}
}
$formatted_aliases .= PHP_EOL;
return $formatted_aliases;
}
示例2: whoami
/**
* Find out what user you are logged in as.
*/
public function whoami()
{
if (Session::getValue('user_uuid')) {
$this->output()->outputValue(Session::getValue('user_uuid'), 'You are authenticated as');
} else {
$this->failure('You are not logged in.');
}
}
示例3: whoami
/**
* Find out what user you are logged in as.
*/
public function whoami()
{
if (Session::getValue('email')) {
Terminus::line("You are authenticated as " . Session::getValue('email'));
} else {
Terminus::line("You are not logged in.");
}
}
示例4: testGetValue
public function testGetValue()
{
//Extant value
$session = Session::getValue('session');
$this->assertTrue(strpos($session, '0ffec038-4410-43d0-a404-46997f672d7a') !== false);
//Invalid look-up
$invalid = Session::getValue('invalid');
$this->assertFalse($invalid);
}
示例5: __construct
/**
* Object constructor
*
* @param [stdClass] $attributes Attributes of this model
* @param [array] $options Options to set as $this->key
* @return [User] $this
*/
public function __construct($attributes, $options = array())
{
if (!isset($options['id'])) {
$options['id'] = Session::getValue('user_uuid');
}
parent::__construct($attributes, $options);
$this->workflows = new Workflows(array('owner' => $this));
$this->instruments = new Instruments(array('user' => $this));
$this->setProfile();
}
示例6: __construct
public function __construct($id = null)
{
if (null === $id) {
$this->id = Session::getValue('user_uuid');
} else {
$this->id = $id;
}
$this->getProfile();
self::$instance = $this;
return $this;
}
示例7: hello
/**
* Say hello
*/
public function hello($args, $assoc_args)
{
if (Session::getValue('user_uuid')) {
$user = Session::getUser();
$user->fetch();
$data = $user->serialize();
$this->log()->info("Hello, {name}!", array('name' => $data['firstname']));
} else {
$this->log()->info("Hello, Anonymous!");
}
}
示例8: fetch_user_organizations
public function fetch_user_organizations()
{
$response = Terminus_Command::paged_request('users/' . Session::getValue('user_uuid') . '/memberships/organizations');
$data = array();
foreach ($response['data'] as $membership) {
if ($membership->role != 'unprivileged') {
$data[$membership->id] = $membership->organization->profile->name;
}
}
return $data;
}
示例9: __construct
public function __construct($id = null)
{
if (null === $id) {
$this->id = Session::getValue('user_uuid');
} else {
$this->id = $id;
}
$this->workflows = new Workflows(array('owner' => $this, 'owner_type' => 'user'));
$this->getProfile();
self::$instance = $this;
return $this;
}
示例10: __construct
/**
* Object constructor
*
* @param object $attributes Attributes of this model
* @param array $options Options to set as $this->key
*/
public function __construct($attributes = null, array $options = array())
{
if (!isset($options['id'])) {
$options['id'] = Session::getValue('user_uuid');
}
parent::__construct($attributes, $options);
if (isset($attributes->profile)) {
$this->profile = $attributes->profile;
}
$this->workflows = new Workflows(array('owner' => $this));
$this->instruments = new Instruments(array('user' => $this));
$this->organizations = new UserOrganizationMemberships(array('user' => $this));
}
示例11: hydrate
private function hydrate()
{
$request = Terminus_Command::request('users', Session::getValue('user_uuid'), 'sites', 'GET', array('hydrated' => true));
$sites = $request['data'];
foreach ($sites as $site_id => $site_data) {
// we need to skip sites that are in the build process still
if (!isset($site_data->information)) {
continue;
}
$site_data->id = $site_id;
$this->sites[$site_data->information->name] = $site_data;
}
return $this;
}
示例12: request
/**
* Make a request to the Dashbord's internal API.
*
* @param $realm
* Permissions realm for data request: currently "user" or "site" but in the
* future this could also be "organization" or another high-level business
* object (e.g. "product" for managing your app). Can also be "public" to
* simply pull read-only data that is not privileged.
*
* @param $uuid
* The UUID of the item in the realm you want to access.
*
* @param $method
* HTTP method (verb) to use.
*
* @param $data
* A native PHP data structure (int, string, arary or simple object) to be
* sent along with the request. Will be encoded as JSON for you.
*/
public static function request($realm, $uuid, $path = FALSE, $method = 'GET', $options = NULL)
{
if (!in_array($realm, array('login', 'user', 'public')) and !Terminus::is_test()) {
Auth::loggedIn();
}
try {
$cache = Terminus::get_cache();
// combine session realm uuid and path to get a unique key
// @todo need cache "groups"
$cachekey = md5(Session::getValue('user_uuid') . $uuid . $realm . $path);
$data = $cache->get_data($cachekey);
// check the request cache
if ("GET" == $method and !Terminus::get_config('nocache') and !getenv('CLI_TEST_MODE') and !empty($data)) {
if (Terminus::get_config('debug')) {
Logger::debug('CacheKey: ' . $cachekey);
}
return (array) $data;
}
// for some methods we'll assume the cache should be invalidated
if (in_array($method, array("POST", "PUT", "DELETE"))) {
$cache->flush(null, 'session');
}
if (!in_array($realm, array('login', 'user'))) {
$options['cookies'] = array('X-Pantheon-Session' => Session::getValue('session'));
$options['verify'] = false;
}
$url = Endpoint::get(array('realm' => $realm, 'uuid' => $uuid, 'path' => $path));
if (Terminus::get_config('debug')) {
Logger::debug('Request URL: ' . $url);
}
$resp = Request::send($url, $method, $options);
$json = $resp->getBody(TRUE);
$data = array('info' => $resp->getInfo(), 'headers' => $resp->getRawHeaders(), 'json' => $json, 'data' => json_decode($json), 'status_code' => $resp->getStatusCode());
$cache->put_data($cachekey, $data);
return $data;
} catch (Guzzle\Http\Exception\BadResponseException $e) {
$response = $e->getResponse();
\Terminus::error("%s", $response->getBody(TRUE));
} catch (Guzzle\Http\Exception\HttpException $e) {
$request = $e->getRequest();
//die(Terminus_Command::stripSensitiveData());
$sanitized_request = Terminus_Command::stripSensitiveData((string) $request, Terminus_Command::$_blacklist);
\Terminus::error("Request %s had failed: %s", array($sanitized_request, $e->getMessage()));
} catch (Exception $e) {
\Terminus::error("Unrecognised request failure: %s", $e->getMessage());
}
}
示例13: addSiteToCache
/**
* Adds site with given site ID to cache
*
* @param [string] $site_id UUID of site to add to cache
* @return [void]
*/
public function addSiteToCache($site_id)
{
if (count($this->models) == 0) {
$this->rebuildCache();
} else {
$site = new Site($this->objectify(array('id' => $site_id)), array('collection' => $this));
$site->fetch();
$cache_membership = $site->info();
if ($org_id) {
$org = new Organization(null, array('id' => $org_id));
$cache_membership['membership'] = array('id' => $org_id, 'name' => $org->profile->name, 'type' => 'organization');
} else {
$user_id = Session::getValue('user_uuid');
$cache_membership['membership'] = array('id' => $user_id, 'name' => 'Team', 'type' => 'team');
}
$this->sites_cache->add($cache_membership);
}
}
示例14: whoami
/**
* Find out what user you are logged in as.
*/
public function whoami()
{
if (Session::getValue('user_uuid')) {
$user = Session::getUser();
$user->fetch();
$data = $user->serialize();
$this->output()->outputRecord($data);
} else {
$this->failure('You are not logged in.');
}
}
示例15: simple_request
/**
* Simplified request method for Pantheon API
*
* @param [string] $path API path (URL)
* @param [array] $options Options for the request
* [string] method GET is default
* [mixed] data Native PHP data structure (e.g. int, string array, or
* simple object) to be sent along with the request. Will be encoded as
* JSON for you.
* @return [array] $data
*/
public static function simple_request($path, $options = array())
{
$req_options = array();
$method = 'get';
if (isset($options['method'])) {
$method = $options['method'];
}
if (isset($options['data'])) {
$req_options['body'] = json_encode($options['data']);
$req_options['headers'] = array('Content-type' => 'application/json');
}
$url = 'https://' . TERMINUS_HOST . '/api/' . $path;
if (Session::getValue('session')) {
$req_options['cookies'] = array('X-Pantheon-Session' => Session::getValue('session'));
$req_options['verify'] = false;
}
try {
$resp = Request::send($url, $method, $req_options);
} catch (Guzzle\Http\Exception\BadResponseException $e) {
\Terminus::error('Request Failure: %s', $e->getMessage());
return;
}
$json = $resp->getBody(true);
$data = array('info' => $resp->getInfo(), 'headers' => $resp->getRawHeaders(), 'json' => $json, 'data' => json_decode($json), 'status_code' => $resp->getStatusCode());
return $data;
}