當前位置: 首頁>>代碼示例>>PHP>>正文


PHP SafeMarkup::getAll方法代碼示例

本文整理匯總了PHP中Drupal\Component\Utility\SafeMarkup::getAll方法的典型用法代碼示例。如果您正苦於以下問題:PHP SafeMarkup::getAll方法的具體用法?PHP SafeMarkup::getAll怎麽用?PHP SafeMarkup::getAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Drupal\Component\Utility\SafeMarkup的用法示例。


在下文中一共展示了SafeMarkup::getAll方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: startTestSuite

 /**
  * {@inheritdoc}
  */
 public function startTestSuite(\PHPUnit_Framework_TestSuite $suite)
 {
     // Use a static so we only do this test once after all the data providers
     // have run.
     static $tested = FALSE;
     if ($suite->getName() !== '' && !$tested) {
         $tested = TRUE;
         if (!empty(SafeMarkup::getAll())) {
             throw new \RuntimeException('SafeMarkup string list polluted by data providers');
         }
     }
 }
開發者ID:ravindrasingh22,項目名稱:Drupal-8-rc,代碼行數:15,代碼來源:SafeMarkupSideEffects.php

示例2: setCache

 /**
  * {@inheritdoc}
  */
 public function setCache($form_build_id, $form, FormStateInterface $form_state)
 {
     // 6 hours cache life time for forms should be plenty.
     $expire = 21600;
     // Ensure that the form build_id embedded in the form structure is the same
     // as the one passed in as a parameter. This is an additional safety measure
     // to prevent legacy code operating directly with
     // \Drupal::formBuilder()->getCache() and \Drupal::formBuilder()->setCache()
     // from accidentally overwriting immutable form state.
     if (isset($form['#build_id']) && $form['#build_id'] != $form_build_id) {
         $this->logger->error('Form build-id mismatch detected while attempting to store a form in the cache.');
         return;
     }
     // Cache form structure.
     if (isset($form)) {
         if ($this->currentUser->isAuthenticated()) {
             $form['#cache_token'] = $this->csrfToken->get();
         }
         unset($form['#build_id_old']);
         $this->keyValueExpirableFactory->get('form')->setWithExpire($form_build_id, $form, $expire);
     }
     // Cache form state.
     if ($this->configFactory->get('system.performance')->get('cache.page.use_internal') && $this->isPageCacheable()) {
         $form_state->addBuildInfo('immutable', TRUE);
     }
     // Store the known list of safe strings for form re-use.
     // @todo Ensure we are not storing an excessively large string list in:
     //   https://www.drupal.org/node/2295823
     $form_state->addBuildInfo('safe_strings', SafeMarkup::getAll());
     if ($data = $form_state->getCacheableArray()) {
         $this->keyValueExpirableFactory->get('form_state')->setWithExpire($form_build_id, $data, $expire);
     }
 }
開發者ID:Nikola-xiii,項目名稱:d8intranet,代碼行數:36,代碼來源:FormCache.php

示例3: testLoadCachedFormStateWithSafeStrings

 /**
  * @covers ::loadCachedFormState
  */
 public function testLoadCachedFormStateWithSafeStrings()
 {
     $this->assertEmpty(SafeMarkup::getAll());
     $form_build_id = 'the_form_build_id';
     $form_state = new FormState();
     $cached_form = ['#cache_token' => NULL];
     $this->formCacheStore->expects($this->once())->method('get')->with($form_build_id)->willReturn($cached_form);
     $this->account->expects($this->once())->method('isAnonymous')->willReturn(TRUE);
     $cached_form_state = ['build_info' => ['safe_strings' => ['a_safe_string' => ['html' => TRUE]]]];
     $this->formStateCacheStore->expects($this->once())->method('get')->with($form_build_id)->willReturn($cached_form_state);
     $this->formCache->getCache($form_build_id, $form_state);
 }
開發者ID:nsp15,項目名稱:Drupal8,代碼行數:15,代碼來源:FormCacheTest.php

示例4: setCache

 /**
  * {@inheritdoc}
  */
 public function setCache($form_build_id, $form, $form_state)
 {
     // 6 hours cache life time for forms should be plenty.
     $expire = 21600;
     // Cache form structure.
     if (isset($form)) {
         if ($this->currentUser()->isAuthenticated()) {
             $form['#cache_token'] = $this->csrfToken->get();
         }
         $this->keyValueExpirableFactory->get('form')->setWithExpire($form_build_id, $form, $expire);
     }
     // Cache form state.
     // Store the known list of safe strings for form re-use.
     // @todo Ensure we are not storing an excessively large string list in:
     //   https://www.drupal.org/node/2295823
     $form_state['build_info']['safe_strings'] = SafeMarkup::getAll();
     if ($data = array_diff_key($form_state, array_flip($this->getUncacheableKeys()))) {
         $this->keyValueExpirableFactory->get('form_state')->setWithExpire($form_build_id, $data, $expire);
     }
 }
開發者ID:alnutile,項目名稱:drunatra,代碼行數:23,代碼來源:FormBuilder.php


注:本文中的Drupal\Component\Utility\SafeMarkup::getAll方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。