本文整理汇总了PHP中Terminus::getCache方法的典型用法代码示例。如果您正苦于以下问题:PHP Terminus::getCache方法的具体用法?PHP Terminus::getCache怎么用?PHP Terminus::getCache使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Terminus
的用法示例。
在下文中一共展示了Terminus::getCache方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetCache
public function testGetCache()
{
setDummyCredentials();
$cache = Terminus::getCache();
setDummyCredentials();
$session = $cache->getData('session');
$this->assertEquals($session->user_uuid, '0ffec038-4410-43d0-a404-46997f672d7a');
}
示例2: testCheckForUpdate
/**
* @vcr utils#checkCurrentVersion
*/
public function testCheckForUpdate()
{
$log_file = getLogFileName();
setOutputDestination($log_file);
Terminus::getCache()->putData('latest_release', ['check_date' => strtotime('8 days ago')]);
Utils\checkForUpdate();
$file_contents = explode("\n", file_get_contents($log_file));
$this->assertFalse(strpos(array_pop($file_contents), 'An update to Terminus is available.'));
resetOutputDestination($log_file);
}
示例3: __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();
}
}
示例4: testSetCache
public function testSetCache()
{
//Default target
$terminus = new Terminus();
$root = Terminus::getCache()->getRoot();
$this->assertTrue(strpos($root, getenv('HOME')) !== false);
//Giving no env var for explicitly set cache dir
putenv('TERMINUS_CACHE_DIR=');
$terminus->setCache();
$root = Terminus::getCache()->getRoot();
$this->assertTrue(strpos($root, getenv('HOME')) !== false);
//Targeting a dir the Windows way
exec('mkdir /tmp/out');
$home = getenv('HOME');
putenv('HOME=0');
putenv('HOMEDRIVE=/tmp');
putenv('HOMEPATH=out');
$terminus->setCache();
$root = Terminus::getCache()->getRoot();
$this->assertTrue(strpos($root, '/tmp/out') !== false);
//Clean-up
putenv("HOME={$home}");
exec("rm -r /tmp/out");
}
示例5: request
/**
* Make a request to the Pantheon API
*
* @param [string] $realm Permissions realm for data request (e.g. user,
* site organization, etc. Can also be "public" to simply pull read-only
* data that is not privileged.
* @param [string] $uuid The UUID of the item in the realm to access
* @param [string] $path API path (URL)
* @param [string] $method HTTP method to use
* @param [mixed] $options A native PHP data structure (e.g. int, string,
* array, or stdClass) to be sent along with the request
* @return [array] $data
*/
public static function request($realm, $uuid, $path = false, $method = 'GET', $options = null)
{
if (!in_array($realm, array('login', 'user', 'public'))) {
Auth::loggedIn();
}
try {
$cache = Terminus::getCache();
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::getConfig('debug')) {
Terminus::log('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());
return $data;
} catch (Guzzle\Http\Exception\BadResponseException $e) {
$response = $e->getResponse();
throw new TerminusException($response->getBody(true));
} catch (Guzzle\Http\Exception\HttpException $e) {
$request = $e->getRequest();
$sanitized_request = TerminusCommand::stripSensitiveData((string) $request, TerminusCommand::$blacklist);
throw new TerminusException('API Request Error. {msg} - Request: {req}', array('req' => $sanitized_request, 'msg' => $e->getMessage()));
} catch (Exception $e) {
throw new TerminusException('API Request Error: {msg}', array('msg' => $e->getMessage()));
}
}
示例6: __construct
public function __construct()
{
$this->file_cache = Terminus::getCache();
}