本文整理汇总了PHP中Drupal::keyValueExpirable方法的典型用法代码示例。如果您正苦于以下问题:PHP Drupal::keyValueExpirable方法的具体用法?PHP Drupal::keyValueExpirable怎么用?PHP Drupal::keyValueExpirable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal
的用法示例。
在下文中一共展示了Drupal::keyValueExpirable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testKeyValueExpirable
/**
* Tests the keyValueExpirable() method.
*/
public function testKeyValueExpirable()
{
$keyvalue = $this->getMockBuilder('Drupal\\Core\\KeyValueStore\\KeyValueExpirableFactory')->disableOriginalConstructor()->getMock();
$keyvalue->expects($this->once())->method('get')->with('test_collection')->will($this->returnValue(TRUE));
$this->setMockContainerService('keyvalue.expirable', $keyvalue);
$this->assertNotNull(\Drupal::keyValueExpirable('test_collection'));
}
示例2: testLocaleUpdateNotDevelopmentRelease
public function testLocaleUpdateNotDevelopmentRelease()
{
// Set available Drupal releases for test.
$available = array('title' => 'Drupal core', 'short_name' => 'drupal', 'type' => 'project_core', 'api_version' => '8.x', 'project_status' => 'unsupported', 'link' => 'https://www.drupal.org/project/drupal', 'terms' => '', 'releases' => array('8.0.0-alpha110' => array('name' => 'drupal 8.0.0-alpha110', 'version' => '8.0.0-alpha110', 'tag' => '8.0.0-alpha110', 'version_major' => '8', 'version_minor' => '0', 'version_patch' => '0', 'version_extra' => 'alpha110', 'status' => 'published', 'release_link' => 'https://www.drupal.org/node/2316617', 'download_link' => 'http://ftp.drupal.org/files/projects/drupal-8.0.0-alpha110.tar.gz', 'date' => '1407344628', 'mdhash' => '9d71afdd0ce541f2ff5ca2fbbca00df7', 'filesize' => '9172832', 'files' => '', 'terms' => array()), '8.0.0-alpha100' => array('name' => 'drupal 8.0.0-alpha100', 'version' => '8.0.0-alpha100', 'tag' => '8.0.0-alpha100', 'version_major' => '8', 'version_minor' => '0', 'version_patch' => '0', 'version_extra' => 'alpha100', 'status' => 'published', 'release_link' => 'https://www.drupal.org/node/2316617', 'download_link' => 'http://ftp.drupal.org/files/projects/drupal-8.0.0-alpha100.tar.gz', 'date' => '1407344628', 'mdhash' => '9d71afdd0ce541f2ff5ca2fbbca00df7', 'filesize' => '9172832', 'files' => '', 'terms' => array())));
$available['last_fetch'] = REQUEST_TIME;
\Drupal::keyValueExpirable('update_available_releases')->setWithExpire('drupal', $available, 10);
$projects = locale_translation_build_projects();
$this->verbose($projects['drupal']->info['version']);
$this->assertEqual($projects['drupal']->info['version'], '8.0.0-alpha110', 'The first release with the same major release number which is not a development release.');
}
示例3: getAvailableReleases
/**
* Obtains release info for all installed projects via update.module.
*
* @see update_get_available().
* @see \Drupal\update\Controller\UpdateController::updateStatusManually()
*/
protected function getAvailableReleases()
{
// Force to invalidate some caches that are only cleared
// when visiting update status report page. This allow to detect changes in
// .info.yml files.
\Drupal::keyValueExpirable('update')->deleteMultiple(array('update_project_projects', 'update_project_data'));
// From update_get_available(): Iterate all projects and create a fetch task
// for those we have no information or is obsolete.
$available = \Drupal::keyValueExpirable('update_available_releases')->getAll();
$update_projects = \Drupal::service('update.manager')->getProjects();
foreach ($update_projects as $key => $project) {
if (empty($available[$key])) {
\Drupal::service('update.processor')->createFetchTask($project);
continue;
}
if ($project['info']['_info_file_ctime'] > $available[$key]['last_fetch']) {
$available[$key]['fetch_status'] = UPDATE_FETCH_PENDING;
}
if (empty($available[$key]['releases'])) {
$available[$key]['fetch_status'] = UPDATE_FETCH_PENDING;
}
if (!empty($available[$key]['fetch_status']) && $available[$key]['fetch_status'] == UPDATE_FETCH_PENDING) {
\Drupal::service('update.processor')->createFetchTask($project);
}
}
// Set a batch to process all pending tasks.
$batch = array('operations' => array(array(array(\Drupal::service('update.manager'), 'fetchDataBatch'), array())), 'finished' => 'update_fetch_data_finished', 'file' => drupal_get_path('module', 'update') . '/update.fetch.inc');
batch_set($batch);
drush_backend_batch_process();
// Clear any error set by a failed update fetch task. This avoid rollbacks.
drush_clear_error();
return \Drupal::keyValueExpirable('update_available_releases')->getAll();
}
示例4: runSubscribeBatch
public static function runSubscribeBatch(SubscriptionInterface $subscription)
{
switch ($subscription->getState()) {
case 'subscribing':
$mode = 'subscribe';
break;
case 'unsubscribing':
$mode = 'unsubscribe';
// The subscription has been deleted, store it for a bit to handle the
// response.
$id = $subscription->getToken() . ':' . $subscription->id();
\Drupal::keyValueExpirable('feeds_push_unsubscribe')->setWithExpire($id, $subscription, 3600);
break;
default:
throw new \LogicException('A subscription was found in an invalid state.');
}
$args = ['feeds_subscription_id' => $subscription->id(), 'feeds_push_token' => $subscription->getToken()];
$callback = \Drupal::url('entity.feeds_feed.subscribe', $args, ['absolute' => TRUE]);
$post_body = ['hub.callback' => $callback, 'hub.mode' => $mode, 'hub.topic' => $subscription->getTopic(), 'hub.secret' => $subscription->getSecret()];
$response = static::retry($subscription, $post_body);
// Response failed.
if (!$response || $response->getStatusCode() != 202) {
switch ($subscription->getState()) {
case 'subscribing':
// Deleting the subscription will make it re-subscribe on the next
// import.
$subscription->delete();
break;
case 'unsubscribing':
// Unsubscribe failed. The hub should give up eventually.
break;
}
}
}