本文整理汇总了PHP中Drupal\Core\Cache\Cache::getBins方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::getBins方法的具体用法?PHP Cache::getBins怎么用?PHP Cache::getBins使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Cache\Cache
的用法示例。
在下文中一共展示了Cache::getBins方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
module_load_include('inc', 'sociallogin');
$data = get_authentication($form_state->getValue('api_key'), $form_state->getValue('api_secret'));
if (isset($data['status']) && $data['status'] != 'status') {
drupal_set_message($data['message'], $data['status']);
return FALSE;
}
parent::SubmitForm($form, $form_state);
$this->config('sociallogin.settings')->set('sso_site_name', $form_state->getValue('sso_site_name'))->set('api_key', $form_state->getValue('api_key'))->set('api_secret', $form_state->getValue('api_secret'))->set('username_option', $form_state->getValue('username_option'))->set('login_redirection', $form_state->getValue('login_redirection'))->set('register_redirection', $form_state->getValue('register_redirection'))->set('custom_login_url', $form_state->getValue('custom_login_url'))->set('custom_register_url', $form_state->getValue('custom_register_url'))->set('enable_linking', $form_state->getValue('enable_linking'))->set('linking_text', $form_state->getValue('linking_text'))->save();
if (count(\Drupal::moduleHandler()->getImplementations('add_extra_sociallogin_config_settings')) > 0) {
// Call all modules that implement the hook, and let them make changes to $variables.
$config_data = \Drupal::moduleHandler()->invokeAll('add_extra_sociallogin_config_settings');
}
if (isset($config_data) && is_array($config_data)) {
foreach ($config_data as $key => $value) {
$this->config('sociallogin.settings')->set($value, $form_state->getValue($value))->save();
}
}
drupal_set_message(t('Social Login settings have been saved.'), 'status');
//Clear page cache
foreach (Cache::getBins() as $service_id => $cache_backend) {
if ($service_id == 'dynamic_page_cache') {
$cache_backend->deleteAll();
}
}
}
示例2: getCaches
/**
* Auxiliary function to get all available drupal caches.
*
* @return array The all available drupal caches
*/
public function getCaches()
{
if (!$this->caches) {
foreach (Cache::getBins() as $name => $bin) {
$this->caches[$name] = $bin;
}
}
return $this->caches;
}
示例3: init
/**
* Clear cache tables.
*/
public function init()
{
$module_handler = \Drupal::moduleHandler();
$module_handler->invokeAll('cache_flush');
// Flush drupal cache tables.
foreach (Cache::getBins() as $service_id => $cache_backend) {
$cache_backend->deleteAll();
}
// Clear all plugin caches.
\Drupal::service('plugin.cache_clearer')->clearCachedDefinitions();
$this->prepare();
}
示例4: testFlushAllCaches
/**
* Tests drupal_flush_all_caches().
*/
function testFlushAllCaches()
{
// Create cache entries for each flushed cache bin.
$bins = Cache::getBins();
$this->assertTrue($bins, 'Cache::getBins() returned bins to flush.');
foreach ($bins as $bin => $cache_backend) {
$cid = 'test_cid_clear' . $bin;
$cache_backend->set($cid, $this->defaultValue);
}
// Remove all caches then make sure that they are cleared.
drupal_flush_all_caches();
foreach ($bins as $bin => $cache_backend) {
$cid = 'test_cid_clear' . $bin;
$this->assertFalse($this->checkCacheExists($cid, $this->defaultValue, $bin), format_string('All cache entries removed from @bin.', array('@bin' => $bin)));
}
}
示例5: refreshVariables
/**
* Refreshes in-memory configuration and state information.
*
* Useful after a page request is made that changes configuration or state in
* a different thread.
*
* In other words calling a settings page with $this->drupalPostForm() with a
* changed value would update configuration to reflect that change, but in the
* thread that made the call (thread running the test) the changed values
* would not be picked up.
*
* This method clears the cache and loads a fresh copy.
*/
protected function refreshVariables()
{
// Clear the tag cache.
\Drupal::service('cache_tags.invalidator')->resetChecksums();
foreach (Cache::getBins() as $backend) {
if (is_callable(array($backend, 'reset'))) {
$backend->reset();
}
}
$this->container->get('config.factory')->reset();
$this->container->get('state')->resetCache();
}
示例6: refreshVariables
/**
* Refreshes in-memory configuration and state information.
*
* Useful after a page request is made that changes configuration or state in
* a different thread.
*
* In other words calling a settings page with $this->submitForm() with a
* changed value would update configuration to reflect that change, but in the
* thread that made the call (thread running the test) the changed values
* would not be picked up.
*
* This method clears the cache and loads a fresh copy.
*/
protected function refreshVariables()
{
// Clear the tag cache.
// @todo Replace drupal_static() usage within classes and provide a
// proper interface for invoking reset() on a cache backend:
// https://www.drupal.org/node/2311945.
drupal_static_reset('Drupal\\Core\\Cache\\CacheBackendInterface::tagCache');
drupal_static_reset('Drupal\\Core\\Cache\\DatabaseBackend::deletedTags');
drupal_static_reset('Drupal\\Core\\Cache\\DatabaseBackend::invalidatedTags');
foreach (Cache::getBins() as $backend) {
if (is_callable(array($backend, 'reset'))) {
$backend->reset();
}
}
$this->container->get('config.factory')->reset();
$this->container->get('state')->resetCache();
}
示例7: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, array &$form_state)
{
foreach ($this->mapper->getConfigNames() as $name) {
$this->languageManager->getLanguageConfigOverride($this->language->id, $name)->delete();
}
// Flush all persistent caches.
$this->moduleHandler->invokeAll('cache_flush');
foreach (Cache::getBins() as $service_id => $cache_backend) {
$cache_backend->deleteAll();
}
drupal_set_message($this->t('@language translation of %label was deleted', array('%label' => $this->mapper->getTitle(), '@language' => $this->language->name)));
$form_state['redirect_route'] = $this->getCancelUrl();
}
示例8: uninstall
//.........这里部分代码省略.........
// The dependent module does not exist.
return FALSE;
}
// Skip already uninstalled modules.
if (isset($installed_modules[$dependent]) && !isset($module_list[$dependent]) && $dependent != $profile) {
$module_list[$dependent] = $dependent;
}
}
}
}
// Use the validators and throw an exception with the reasons.
if ($reasons = $this->validateUninstall($module_list)) {
foreach ($reasons as $reason) {
$reason_message[] = implode(', ', $reason);
}
throw new ModuleUninstallValidatorException(format_string('The following reasons prevents the modules from being uninstalled: @reasons', array('@reasons' => implode(', ', $reason_message))));
}
// Set the actual module weights.
$module_list = array_map(function ($module) use($module_data) {
return $module_data[$module]->sort;
}, $module_list);
// Sort the module list by their weights.
asort($module_list);
$module_list = array_keys($module_list);
// Only process modules that are enabled. A module is only enabled if it is
// configured as enabled. Custom or overridden module handlers might contain
// the module already, which means that it might be loaded, but not
// necessarily installed.
foreach ($module_list as $module) {
// Clean up all entity bundles (including fields) of every entity type
// provided by the module that is being uninstalled.
// @todo Clean this up in https://www.drupal.org/node/2350111.
$entity_manager = \Drupal::entityManager();
foreach ($entity_manager->getDefinitions() as $entity_type_id => $entity_type) {
if ($entity_type->getProvider() == $module) {
foreach (array_keys($entity_manager->getBundleInfo($entity_type_id)) as $bundle) {
$entity_manager->onBundleDelete($bundle, $entity_type_id);
}
}
}
// Allow modules to react prior to the uninstallation of a module.
$this->moduleHandler->invokeAll('module_preuninstall', array($module));
// Uninstall the module.
module_load_install($module);
$this->moduleHandler->invoke($module, 'uninstall');
// Remove all configuration belonging to the module.
\Drupal::service('config.manager')->uninstall('module', $module);
// Notify interested components that this module's entity types are being
// deleted. For example, a SQL-based storage handler can use this as an
// opportunity to drop the corresponding database tables.
// @todo Clean this up in https://www.drupal.org/node/2350111.
foreach ($entity_manager->getDefinitions() as $entity_type) {
if ($entity_type->getProvider() == $module) {
$entity_manager->onEntityTypeDelete($entity_type);
}
}
// Remove the schema.
drupal_uninstall_schema($module);
// Remove the module's entry from the config.
\Drupal::configFactory()->getEditable('core.extension')->clear("module.{$module}")->save();
// Update the module handler to remove the module.
// The current ModuleHandler instance is obsolete with the kernel rebuild
// below.
$module_filenames = $this->moduleHandler->getModuleList();
unset($module_filenames[$module]);
$this->moduleHandler->setModuleList($module_filenames);
// Remove any potential cache bins provided by the module.
$this->removeCacheBins($module);
// Clear the static cache of system_rebuild_module_data() to pick up the
// new module, since it merges the installation status of modules into
// its statically cached list.
drupal_static_reset('system_rebuild_module_data');
// Clear plugin manager caches.
\Drupal::getContainer()->get('plugin.cache_clearer')->clearCachedDefinitions();
// Update the kernel to exclude the uninstalled modules.
$this->updateKernel($module_filenames);
// Update the theme registry to remove the newly uninstalled module.
drupal_theme_rebuild();
// Modules can alter theme info, so refresh theme data.
// @todo ThemeHandler cannot be injected into ModuleHandler, since that
// causes a circular service dependency.
// @see https://drupal.org/node/2208429
\Drupal::service('theme_handler')->refreshInfo();
\Drupal::logger('system')->info('%module module uninstalled.', array('%module' => $module));
$schema_store = \Drupal::keyValue('system.schema');
$schema_store->delete($module);
}
\Drupal::service('router.builder')->setRebuildNeeded();
drupal_get_installed_schema_version(NULL, TRUE);
// Let other modules react.
$this->moduleHandler->invokeAll('modules_uninstalled', array($module_list));
// Flush all persistent caches.
// Any cache entry might implicitly depend on the uninstalled modules,
// so clear all of them explicitly.
$this->moduleHandler->invokeAll('cache_flush');
foreach (Cache::getBins() as $service_id => $cache_backend) {
$cache_backend->deleteAll();
}
return TRUE;
}
示例9: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
$sl_config = \Drupal::config('sociallogin.settings');
$apiKey = $sl_config->get('api_key');
$apiSecret = $sl_config->get('api_secret');
if ($apiKey == '') {
$apiKey = '';
$apiSecret = '';
}
module_load_include('inc', 'sociallogin');
$data = get_authentication($apiKey, $apiSecret);
if (isset($data['status']) && $data['status'] != 'status') {
drupal_set_message($data['message'], $data['status']);
return FALSE;
}
// parent::SubmitForm($form, $form_state);
$values = $form_state->getValues();
$inputs = $form_state->getUserInput();
$sharerearrange = default_sharing_networks('share_rearrange_providers');
$verticalshareproviders = default_sharing_networks('share_rearrange_providers');
$sharing_rearrange = array();
$vertical_share_rearrange = array();
$this->config('socialshare.settings')->set('enable_horizontal', $values['enable_horizontal'])->set('enable_vertical', $values['enable_vertical'])->set('label', $values['label'])->set('horizontal_images', $values['horizontal_images'])->set('vertical_images', $values['vertical_images'])->set('counter_providers', $values['counter_providers'])->set('counter_rearrange', $values['counter_providers'])->set('share_providers', isset($inputs['share_rearrange']) ? $inputs['share_rearrange'] : $sharerearrange)->set('share_rearrange', isset($inputs['share_rearrange']) ? $inputs['share_rearrange'] : $sharerearrange)->set('vertical_counter_rearrange', $values['vertical_counter_providers'])->set('vertical_counter_providers', $values['vertical_counter_providers'])->set('vertical_share_providers', isset($inputs['vertical_share_rearrange']) ? $inputs['vertical_share_rearrange'] : $verticalshareproviders)->set('vertical_share_rearrange', isset($inputs['vertical_share_rearrange']) ? $inputs['vertical_share_rearrange'] : $verticalshareproviders)->set('vertical_position', $values['vertical_position'])->set('position_top', $values['position_top'])->set('position_bottom', $values['position_bottom'])->set('show_pages', $values['show_pages'])->set('show_exceptpages', $values['show_exceptpages'])->set('vertical_show_pages', $values['vertical_show_pages'])->set('vertical_show_exceptpages', $values['vertical_show_exceptpages'])->set('opensocialshare_email_message', $values['opensocialshare_email_message'])->set('opensocialshare_email_subject', $values['opensocialshare_email_subject'])->set('opensocialshare_is_email_content_read_only', $values['opensocialshare_is_email_content_read_only'])->set('opensocialshare_is_shorten_url', $values['opensocialshare_is_shorten_url'])->set('opensocialshare_facebook_app_id', $values['opensocialshare_facebook_app_id'])->set('opensocialshare_is_total_share', $values['opensocialshare_is_total_share'])->set('opensocialshare_is_open_single_window', $values['opensocialshare_is_open_single_window'])->set('opensocialshare_popup_window', $values['opensocialshare_popup_window'])->set('opensocialshare_popup_window_size_height', $values['opensocialshare_popup_window_size_height'])->set('opensocialshare_popup_window_size_width', $values['opensocialshare_popup_window_size_width'])->set('opensocialshare_twitter_mention', $values['opensocialshare_twitter_mention'])->set('opensocialshare_twitter_hash_tags', $values['opensocialshare_twitter_hash_tags'])->set('opensocialshare_is_mobile_friendly', $values['opensocialshare_is_mobile_friendly'])->set('opensocialshare_custom_options', $values['opensocialshare_custom_options'])->save();
drupal_set_message(t('Social Share settings have been saved.'), 'status');
//Clear page cache
foreach (Cache::getBins() as $service_id => $cache_backend) {
if ($service_id == 'dynamic_page_cache') {
$cache_backend->deleteAll();
}
}
}
示例10: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
$sl_config = \Drupal::config('sociallogin.settings');
$apiKey = $sl_config->get('api_key');
$apiSecret = $sl_config->get('api_secret');
if ($apiKey == '') {
$apiKey = '';
$apiSecret = '';
}
module_load_include('inc', 'sociallogin');
$data = get_authentication($apiKey, $apiSecret);
if (isset($data['status']) && $data['status'] != 'status') {
drupal_set_message($data['message'], $data['status']);
return FALSE;
}
parent::SubmitForm($form, $form_state);
$this->config('socialprofiledata.settings')->set('profile_selection', $form_state->getValue('profile_selection'))->set('show_profile', $form_state->getValue('show_profile'))->save();
$socialprofiledata_profile_selection = explode(',', implode(',', $form_state->getValue('profile_selection', '')));
module_load_include('inc', 'socialprofiledata', 'socialprofiledata.sql');
if (in_array('basic_profile_data', $socialprofiledata_profile_selection)) {
$this->socialprofiledata_check_table_exists_and_create('loginradius_basic_profile_data');
$this->socialprofiledata_check_table_exists_and_create('loginradius_emails');
}
if (in_array('extended_profile_data', $socialprofiledata_profile_selection)) {
$extended_profile_data_array = array('loginradius_extended_profile_data', 'loginradius_positions', 'loginradius_companies', 'loginradius_education', 'loginradius_phone_numbers', 'loginradius_IMaccounts', 'loginradius_addresses', 'loginradius_sports', 'loginradius_inspirational_people', 'loginradius_skills', 'loginradius_current_status', 'loginradius_certifications', 'loginradius_courses', 'loginradius_volunteer', 'loginradius_recommendations_received', 'loginradius_languages', 'loginradius_patents', 'loginradius_favorites', 'loginradius_books', 'loginradius_games', 'loginradius_television_show', 'loginradius_movies');
if (is_array($extended_profile_data_array)) {
foreach ($extended_profile_data_array as $table_name) {
$this->socialprofiledata_check_table_exists_and_create($table_name);
}
}
}
$create_table = array('extended_location_data' => 'loginradius_extended_location_data', 'followed_companies_on' => 'loginradius_linkedin_companies', 'facebook_profile_likes' => 'loginradius_facebook_likes', 'facebook_profile_events' => 'loginradius_facebook_events', 'status_message' => 'loginradius_status', 'facebook_posts' => 'loginradius_facebook_posts', 'twitter_mentions' => 'loginradius_twitter_mentions', 'lr_groups' => 'loginradius_groups', 'lr_contacts' => 'loginradius_contacts');
foreach ($create_table as $table_key => $table_name) {
$this->socialprofiledata_check_table_selected_in_database($table_key, $table_name, $socialprofiledata_profile_selection);
}
drupal_set_message(t('Social Profile data settings have been saved.'), 'status');
//Clear page cache
foreach (Cache::getBins() as $service_id => $cache_backend) {
if ($service_id == 'dynamic_page_cache') {
$cache_backend->deleteAll();
}
}
}
示例11: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
$sl_config = \Drupal::config('sociallogin.settings');
$apiKey = $sl_config->get('api_key');
$apiSecret = $sl_config->get('api_secret');
if ($apiKey == '') {
$apiKey = '';
$apiSecret = '';
}
module_load_include('inc', 'sociallogin');
$data = get_authentication($apiKey, $apiSecret);
if (isset($data['status']) && $data['status'] != 'status') {
drupal_set_message($data['message'], $data['status']);
return FALSE;
}
// parent::SubmitForm($form, $form_state);
\Drupal\Core\Database\Database::getConnection()->delete('config')->condition('name', 'sociallogin.settings')->execute();
$this->config('sociallogin.settings')->set('interface_label', $form_state->getValue('interface_label'))->set('interface_size', $form_state->getValue('interface_size'))->set('interface_columns', $form_state->getValue('interface_columns'))->set('interface_bgcolor', $form_state->getValue('interface_bgcolor'))->set('login_form', $form_state->getValue('login_form'))->set('register_form', $form_state->getValue('register_form'))->set('commenting_form', $form_state->getValue('commenting_form'))->set('widget_location', $form_state->getValue('widget_location'))->set('admin_login', $form_state->getValue('admin_login'))->set('force_registration', $form_state->getValue('force_registration'))->set('email_required', $form_state->getValue('email_required'))->set('popup_title', $form_state->getValue('popup_title'))->set('popup_status', $form_state->getValue('popup_status'))->set('popup_error', $form_state->getValue('popup_error'))->set('welcome_email', $form_state->getValue('welcome_email'))->set('welcome_email_message', $form_state->getValue('welcome_email_message'))->set('update_user_profile', $form_state->getValue('update_user_profile'))->set('skip_email_verification', $form_state->getValue('skip_email_verification'))->set('user_fields', $form_state->getValue('user_fields'))->set('sociallogin_debug_mode', $form_state->getValue('sociallogin_debug_mode'))->save();
if (count(\Drupal::moduleHandler()->getImplementations('add_extra_config_settings')) > 0) {
// Call all modules that implement the hook, and let them make changes to $variables.
$data = \Drupal::moduleHandler()->invokeAll('add_extra_config_settings');
}
if (isset($data) && is_array($data)) {
foreach ($data as $key => $value) {
$this->config('sociallogin.settings')->set($value, $form_state->getValue($value))->save();
}
}
drupal_set_message(t('Settings have been saved.'), 'status');
//Clear page cache
foreach (Cache::getBins() as $service_id => $cache_backend) {
if ($service_id == 'dynamic_page_cache') {
$cache_backend->deleteAll();
}
}
}
示例12: submitForm
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state)
{
$config = \Drupal::configFactory()->getEditable('exclude_node_title.settings');
$values = $form_state->getValues();
foreach ($values['content_type'] as $node_type => $value) {
$config->set('content_types.' . $node_type, $values['content_type'][$node_type]['content_type_value']);
$modes = array_filter($values['content_type'][$node_type]['content_type_modes']);
$modes = array_keys($modes);
$config->set('content_type_modes.' . $node_type, $modes);
}
$config->set('search', $values['exclude_node_title_search'])->save();
parent::submitForm($form, $form_state);
foreach (Cache::getBins() as $service_id => $cache_backend) {
$cache_backend->deleteAll();
}
}
示例13: drupal_rebuild
/**
* @Todo: Remove when issue https://www.drupal.org/node/2556025 get resolved
*
* Rebuilds all caches even when Drupal itself does not work.
*
* @param \Composer\Autoload\ClassLoader $class_loader
* The class loader.
* @param \Symfony\Component\HttpFoundation\Request $request
* The current request.
*
* @see rebuild.php
*/
public function drupal_rebuild($class_loader, \Symfony\Component\HttpFoundation\Request $request)
{
// Remove Drupal's error and exception handlers; they rely on a working
// service container and other subsystems and will only cause a fatal error
// that hides the actual error.
restore_error_handler();
restore_exception_handler();
// Force kernel to rebuild php cache.
\Drupal\Core\PhpStorage\PhpStorageFactory::get('twig')->deleteAll();
// Bootstrap up to where caches exist and clear them.
$kernel = new \Drupal\Core\DrupalKernel('prod', $class_loader);
$kernel->setSitePath(\Drupal\Core\DrupalKernel::findSitePath($request));
// Invalidate the container.
$kernel->invalidateContainer();
// Prepare a NULL request.
$kernel->prepareLegacyRequest($request);
foreach (Cache::getBins() as $bin) {
$bin->deleteAll();
}
// Disable recording of cached pages.
\Drupal::service('page_cache_kill_switch')->trigger();
drupal_flush_all_caches();
// Restore Drupal's error and exception handlers.
// @see \Drupal\Core\DrupalKernel::boot()
set_error_handler('_drupal_error_handler');
set_exception_handler('_drupal_exception_handler');
}