本文整理汇总了PHP中drupal_static_reset函数的典型用法代码示例。如果您正苦于以下问题:PHP drupal_static_reset函数的具体用法?PHP drupal_static_reset怎么用?PHP drupal_static_reset使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了drupal_static_reset函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testKeyEnumKeys
/**
* Test enumeration of anonymous and authenticated keys.
*/
public function testKeyEnumKeys()
{
global $base_root;
variable_set('authcache_roles', array());
$expect = array($base_root);
$result = authcache_enum_keys();
$this->assertEqual($expect, $result);
drupal_static_reset();
// Test anonymous and authenticated roles.
variable_set('authcache_roles', array(DRUPAL_ANONYMOUS_RID => DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID => DRUPAL_AUTHENTICATED_RID));
$result = authcache_enum_keys();
$anonymous_key = array_pop($result);
$this->assertEqual($base_root, $anonymous_key);
// Expect 1 additional key for authenticated users.
$this->assertEqual(1, count($result));
drupal_static_reset();
// Test additional roles.
$rid1 = $this->drupalCreateRole(array());
$rid2 = $this->drupalCreateRole(array());
variable_set('authcache_roles', array(DRUPAL_ANONYMOUS_RID => DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID => DRUPAL_AUTHENTICATED_RID, $rid1 => $rid1, $rid2 => $rid2));
$result = authcache_enum_keys();
$anonymous_key = array_pop($result);
$this->assertEqual($base_root, $anonymous_key);
// Expect 4 keys for authenticated users:
// * Only authenticated rid
// * Only rid1
// * Only rid2
// * rid1 and rid2
$this->assertEqual(4, count($result));
}
示例2: iShouldSeeAValidCatalogXml
/**
* @Then I should see a valid catalog xml
*/
public function iShouldSeeAValidCatalogXml()
{
// Change /catalog.xml path to /catalog during tests. The '.' on the filename breaks tests on CircleCI's server.
$dcat = open_data_schema_map_api_load('dcat_v1_1');
if ($dcat->endpoint !== 'catalog') {
$dcat->endpoint = 'catalog';
drupal_write_record('open_data_schema_map', $dcat, 'id');
drupal_static_reset('open_data_schema_map_api_load_all');
menu_rebuild();
}
// Change /catalog.json path to /catalogjson during tests. The '.' on the filename breaks tests on CircleCI's server.
$dcat_json = open_data_schema_map_api_load('dcat_v1_1_json');
if ($dcat_json->endpoint !== 'catalogjson') {
$dcat_json->endpoint = 'catalogjson';
drupal_write_record('open_data_schema_map', $dcat_json, 'id');
drupal_static_reset('open_data_schema_map_api_load_all');
menu_rebuild();
}
// Get base URL.
$url = $this->getMinkParameter('base_url') ? $this->getMinkParameter('base_url') : "http://127.0.0.1::8888";
$url_xml = $url . '/catalog';
$url_json = $url . '/catalogjson';
$this->visitPath($url_xml);
$this->assertSession()->statusCodeEquals('200');
// Validate DCAT.
$results = open_data_schema_dcat_process_validate($url_json, TRUE);
if ($results['errors']) {
throw new \Exception(sprintf('catalog.xml is not valid.'));
}
}
示例3: downloadModules
private function downloadModules(DrupalStyle $io, $modules, $latest, $path = null, $resultList = [])
{
if (!$resultList) {
$resultList = ['invalid' => [], 'uninstalled' => [], 'dependencies' => []];
}
drupal_static_reset('system_rebuild_module_data');
$validator = $this->getApplication()->getValidator();
$missingModules = $validator->getMissingModules($modules);
$invalidModules = [];
if ($missingModules) {
$io->info(sprintf($this->trans('commands.module.install.messages.getting-missing-modules'), implode(', ', $missingModules)));
foreach ($missingModules as $missingModule) {
$version = $this->releasesQuestion($io, $missingModule, $latest);
if ($version) {
$this->downloadProject($io, $missingModule, $version, 'module', $path);
} else {
$invalidModules[] = $missingModule;
unset($modules[array_search($missingModule, $modules)]);
}
$this->getApplication()->getSite()->discoverModules();
}
}
$unInstalledModules = $validator->getUninstalledModules($modules);
$dependencies = $this->calculateDependencies($unInstalledModules);
$resultList = ['invalid' => array_unique(array_merge($resultList['invalid'], $invalidModules)), 'uninstalled' => array_unique(array_merge($resultList['uninstalled'], $unInstalledModules)), 'dependencies' => array_unique(array_merge($resultList['dependencies'], $dependencies))];
if (!$dependencies) {
return $resultList;
}
return $this->downloadModules($io, $dependencies, $latest, $path, $resultList);
}
示例4: setUp
protected function setUp()
{
parent::setUp();
// Set up an additional language.
$this->langcodes = array(language_default()->getId(), 'es');
ConfigurableLanguage::createFromLangcode('es')->save();
// Create a content type.
$this->bundle = $this->randomMachineName();
$this->contentType = $this->drupalCreateContentType(array('type' => $this->bundle));
// Enable translation for the current entity type and ensure the change is
// picked up.
content_translation_set_config('node', $this->bundle, 'enabled', TRUE);
drupal_static_reset();
\Drupal::entityManager()->clearCachedBundles();
\Drupal::service('router.builder')->rebuild();
// Add a translatable field to the content type.
entity_create('field_storage_config', array('field_name' => 'field_test_text', 'entity_type' => 'node', 'type' => 'text', 'cardinality' => 1, 'translatable' => TRUE))->save();
entity_create('field_config', array('entity_type' => 'node', 'field_name' => 'field_test_text', 'bundle' => $this->bundle, 'label' => 'Test text-field'))->save();
entity_get_form_display('node', $this->bundle, 'default')->setComponent('field_test_text', array('type' => 'text_textfield', 'weight' => 0))->save();
// Enable content translation.
$configuration = array('langcode' => language_default()->getId(), 'language_show' => TRUE);
language_save_default_configuration('node', $this->bundle, $configuration);
// Create a translator user.
$permissions = array('access contextual links', 'administer nodes', "edit any {$this->bundle} content", 'translate any entity');
$this->translator = $this->drupalCreateUser($permissions);
}
示例5: testGetPluralFormat
/**
* Tests locale_get_plural() and format_plural() functionality.
*/
public function testGetPluralFormat()
{
// Import some .po files with formulas to set up the environment.
// These will also add the languages to the system.
$this->importPoFile($this->getPoFileWithSimplePlural(), array('langcode' => 'fr'));
$this->importPoFile($this->getPoFileWithComplexPlural(), array('langcode' => 'hr'));
// Attempt to import some broken .po files as well to prove that these
// will not overwrite the proper plural formula imported above.
$this->importPoFile($this->getPoFileWithMissingPlural(), array('langcode' => 'fr', 'overwrite_options[not_customized]' => TRUE));
$this->importPoFile($this->getPoFileWithBrokenPlural(), array('langcode' => 'hr', 'overwrite_options[not_customized]' => TRUE));
// Reset static caches from locale_get_plural() to ensure we get fresh data.
drupal_static_reset('locale_get_plural');
drupal_static_reset('locale_get_plural:plurals');
drupal_static_reset('locale');
// Expected plural translation strings for each plural index.
$plural_strings = array('en' => array(0 => '1 hour', 1 => '@count hours'), 'fr' => array(0 => '@count heure', 1 => '@count heures'), 'hr' => array(0 => '@count sat', 1 => '@count sata', 2 => '@count sati'), 'hu' => array(0 => '1 hour', -1 => '@count hours'));
// Expected plural indexes precomputed base on the plural formulas with
// given $count value.
$plural_tests = array('en' => array(1 => 0, 0 => 1, 5 => 1, 123 => 1, 235 => 1), 'fr' => array(1 => 0, 0 => 0, 5 => 1, 123 => 1, 235 => 1), 'hr' => array(1 => 0, 21 => 0, 0 => 2, 2 => 1, 8 => 2, 123 => 1, 235 => 2), 'hu' => array(1 => -1, 21 => -1, 0 => -1));
foreach ($plural_tests as $langcode => $tests) {
foreach ($tests as $count => $expected_plural_index) {
// Assert that the we get the right plural index.
$this->assertIdentical(locale_get_plural($count, $langcode), $expected_plural_index, 'Computed plural index for ' . $langcode . ' for count ' . $count . ' is ' . $expected_plural_index);
// Assert that the we get the right translation for that. Change the
// expected index as per the logic for translation lookups.
$expected_plural_index = $count == 1 ? 0 : $expected_plural_index;
$expected_plural_string = str_replace('@count', $count, $plural_strings[$langcode][$expected_plural_index]);
$this->assertIdentical(format_plural($count, '1 hour', '@count hours', array(), array('langcode' => $langcode)), $expected_plural_string, 'Plural translation of 1 hours / @count hours for count ' . $count . ' in ' . $langcode . ' is ' . $expected_plural_string);
}
}
}
示例6: __construct
public function __construct($order_id)
{
$args = func_get_args();
array_shift($args);
$page_id = array_shift($args);
$order = commerce_order_load($order_id);
if (!$order) {
$this->setErrors("Order {$order_id} does not exist.");
$this->setInitialized(FALSE);
return;
}
$checkout_page = NULL;
drupal_static_reset();
$checkout_pages = commerce_checkout_pages();
if (is_null($page_id)) {
$checkout_page = reset($checkout_pages);
} elseif (!empty($checkout_pages[$page_id])) {
$checkout_page = $checkout_pages[$page_id];
}
if (is_null($checkout_page)) {
$this->setErrors("Checkout page not defined correctly.");
$this->setInitialized(FALSE);
}
$this->includeFile('inc', 'commerce_checkout', 'includes/commerce_checkout.pages');
parent::__construct('commerce_checkout_form_' . $checkout_page['page_id'], $order, $checkout_page);
$this->page_id = $checkout_page['page_id'];
$this->order_id = $order_id;
}
示例7: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new DrupalStyle($input, $output);
$modules = $input->getArgument('module');
$latest = $input->getOption('latest');
$this->getDrupalHelper()->loadLegacyFile('core/includes/bootstrap.inc');
$resultList = $this->downloadModules($io, $modules, $latest);
$invalidModules = $resultList['invalid'];
$unInstalledModules = $resultList['uninstalled'];
if ($invalidModules) {
foreach ($invalidModules as $invalidModule) {
unset($modules[array_search($invalidModule, $modules)]);
$io->error(sprintf('Invalid module name: %s', $invalidModule));
}
}
if (!$unInstalledModules) {
$io->warning($this->trans('commands.module.install.messages.nothing'));
return 0;
}
try {
$io->comment(sprintf($this->trans('commands.module.install.messages.installing'), implode(', ', $unInstalledModules)));
$moduleInstaller = $this->getModuleInstaller();
drupal_static_reset('system_rebuild_module_data');
$moduleInstaller->install($unInstalledModules, true);
$io->success(sprintf($this->trans('commands.module.install.messages.success'), implode(', ', $unInstalledModules)));
} catch (\Exception $e) {
$io->error($e->getMessage());
return 1;
}
$this->getChain()->addCommand('cache:rebuild', ['cache' => 'all']);
}
示例8: testNewAndRemoveSearchPage
/**
* Asserts that we create a new search page and remove it again
*/
function testNewAndRemoveSearchPage()
{
// Create a new search page
$this->drupalLogin($this->admin_user);
$this->drupalGet('admin/config/search/apachesolr/search-pages');
$this->assertText(t('Add search page'), t('Create new search page link is available'));
$this->clickLink(t('Add search page'));
$this->assertText(t('The human-readable name of the search page configuration.'), t('Search page creation page succesfully added'));
$edit = array('page_id' => 'solr_testingsuite', 'env_id' => 'solr', 'label' => 'Test Search Page', 'description' => 'Test Description', 'page_title' => 'Test Title', 'search_path' => 'search/searchdifferentpath');
$this->drupalPost($this->getUrl(), $edit, t('Save configuration'));
$this->assertResponse(200);
// Make sure the menu is recognized
drupal_static_reset('apachesolr_search_page_load');
menu_cache_clear_all();
menu_rebuild();
$this->drupalGet('admin/config/search/apachesolr/search-pages');
$this->assertText(t('Test Search Page'), t('Search Page was succesfully created'));
// Remove the same environment
$this->clickLink(t('Delete'));
$this->assertText(t('search page configuration will be deleted.This action cannot be undone.'), t('Delete confirmation page was succesfully loaded'));
$this->drupalPost($this->getUrl(), array(), t('Delete page'));
$this->assertResponse(200);
drupal_static_reset('apachesolr_search_page_load');
$this->drupalGet('admin/config/search/apachesolr/search-pages');
$this->assertNoText(t('Test Search Page'), t('Search Environment was succesfully deleted'));
}
示例9: setLanguageNegotiation
/**
* Set language negotiation.
*
* @param string $language_negotiation
* Language negotiation name.
* @param string $type
* Language type.
*
* @see language_types_configurable()
*/
public function setLanguageNegotiation($language_negotiation, $type = LANGUAGE_TYPE_INTERFACE)
{
include_once DRUPAL_ROOT . '/includes/language.inc';
$negotiation = array($language_negotiation => -10, 'language-default' => 10);
// Reset available language provider.
drupal_static_reset("language_negotiation_info");
language_negotiation_set($type, $negotiation);
}
示例10: setUpBeforeClass
public static function setUpBeforeClass()
{
// Change /data.json path to /json during tests.
$data_json = open_data_schema_map_api_load('data_json_1_1');
$data_json->endpoint = 'json';
drupal_write_record('open_data_schema_map', $data_json, 'id');
drupal_static_reset('open_data_schema_map_api_load_all');
menu_rebuild();
}
示例11: createProtectedUser
/**
* Creates a protected user.
*
* @param array $protections
* (optional) The active protections.
* Defaults to an empty array.
*
* @return object
* The created user.
*/
protected function createProtectedUser(array $protections = array())
{
// Create a user.
$account = $this->drupalCreateUser();
// Protect this user.
$protection_rule = $this->createProtectionRule($account->id(), $protections, 'user');
$protection_rule->save();
// Reset available permissions.
drupal_static_reset('checkPermissions');
return $account;
}
示例12: enableTranslation
/**
* Enables translations where it needed.
*/
protected function enableTranslation()
{
// Enable translation for the current entity type and ensure the change is
// picked up.
\Drupal::service('content_translation.manager')->setEnabled('node', 'article', TRUE);
\Drupal::service('content_translation.manager')->setEnabled('taxonomy_term', $this->vocabulary->id(), TRUE);
drupal_static_reset();
\Drupal::entityManager()->clearCachedDefinitions();
\Drupal::service('router.builder')->rebuild();
\Drupal::service('entity.definition_update_manager')->applyUpdates();
}
示例13: resetCache
/**
* {@inheritdoc}
*/
public function resetCache(array $ids = NULL) {
drupal_static_reset('taxonomy_term_count_nodes');
$this->parents = array();
$this->parentsAll = array();
$this->children = array();
$this->treeChildren = array();
$this->treeParents = array();
$this->treeTerms = array();
$this->trees = array();
parent::resetCache($ids);
}
示例14: resetCache
/**
* {@inheritdoc}
*/
public function resetCache(array $ids = NULL)
{
drupal_static_reset('taxonomy_term_count_nodes');
drupal_static_reset('taxonomy_get_tree');
drupal_static_reset('taxonomy_get_tree:parents');
drupal_static_reset('taxonomy_get_tree:terms');
drupal_static_reset('taxonomy_term_load_parents');
drupal_static_reset('taxonomy_term_load_parents_all');
drupal_static_reset('taxonomy_term_load_children');
parent::resetCache($ids);
}
示例15: testThemeTableNoStickyHeaders
/**
* If $sticky is FALSE, no tableheader.js should be included.
*/
function testThemeTableNoStickyHeaders()
{
$header = array('one', 'two', 'three');
$rows = array(array(1, 2, 3), array(4, 5, 6), array(7, 8, 9));
$attributes = array();
$caption = NULL;
$colgroups = array();
$table = array('#type' => 'table', '#header' => $header, '#rows' => $rows, '#attributes' => $attributes, '#caption' => $caption, '#colgroups' => $colgroups, '#sticky' => FALSE);
$this->render($table);
$js = _drupal_add_js();
$this->assertFalse(isset($js['core/misc/tableheader.js']), 'tableheader.js not found.');
$this->assertNoRaw('sticky-enabled');
drupal_static_reset('_drupal_add_js');
}