当前位置: 首页>>代码示例>>PHP>>正文


PHP FormState::getCacheableArray方法代码示例

本文整理汇总了PHP中Drupal\Core\Form\FormState::getCacheableArray方法的典型用法代码示例。如果您正苦于以下问题:PHP FormState::getCacheableArray方法的具体用法?PHP FormState::getCacheableArray怎么用?PHP FormState::getCacheableArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\Core\Form\FormState的用法示例。


在下文中一共展示了FormState::getCacheableArray方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testSetCacheWithSafeStrings

 /**
  * @covers ::setCache
  */
 public function testSetCacheWithSafeStrings()
 {
     // A call to SafeMarkup::set() is appropriate in this test as a way to add a
     // string to the safe list in the simplest way possible. Normally, avoid it.
     SafeMarkup::set('a_safe_string');
     $form_build_id = 'the_form_build_id';
     $form = ['#form_id' => 'the_form_id'];
     $form_state = new FormState();
     $this->formCacheStore->expects($this->once())->method('setWithExpire')->with($form_build_id, $form, $this->isType('int'));
     $form_state_data = $form_state->getCacheableArray();
     $form_state_data['build_info']['safe_strings'] = ['a_safe_string' => ['html' => TRUE]];
     $this->formStateCacheStore->expects($this->once())->method('setWithExpire')->with($form_build_id, $form_state_data, $this->isType('int'));
     $this->formCache->setCache($form_build_id, $form, $form_state);
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:17,代码来源:FormCacheTest.php

示例2: testSetCacheImmutableForm

 /**
  * @covers ::setCache
  */
 public function testSetCacheImmutableForm()
 {
     $form_build_id = 'the_form_build_id';
     $form = ['#form_id' => 'the_form_id'];
     $form_state = new FormState();
     $this->formCacheStore->expects($this->once())->method('setWithExpire')->with($form_build_id, $form, $this->isType('int'));
     $form_state_data = $form_state->getCacheableArray();
     $form_state_data['build_info']['safe_strings'] = [];
     // Ensure that the form is marked immutable.
     $form_state_data['build_info']['immutable'] = TRUE;
     $this->formStateCacheStore->expects($this->once())->method('setWithExpire')->with($form_build_id, $form_state_data, $this->isType('int'));
     // Rebuild the FormCache with a config factory that will return a config
     // object with the internal page cache enabled.
     $this->configFactory = $this->getConfigFactoryStub(['system.performance' => ['cache.page.use_internal' => TRUE]]);
     $this->formCache = $this->getMockBuilder('Drupal\\Core\\Form\\FormCache')->setConstructorArgs([$this->keyValueExpirableFactory, $this->moduleHandler, $this->account, $this->csrfToken, $this->logger, $this->configFactory, $this->requestStack, $this->requestPolicy])->setMethods(['isPageCacheable'])->getMock();
     $this->formCache->expects($this->once())->method('isPageCacheable')->willReturn(TRUE);
     $this->formCache->setCache($form_build_id, $form, $form_state);
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:21,代码来源:FormCacheTest.php

示例3: testSetCacheAuthUser

 /**
  * @covers ::setCache
  */
 public function testSetCacheAuthUser()
 {
     $form_build_id = 'the_form_build_id';
     $form = [];
     $form_state = new FormState();
     $cache_token = 'the_cache_token';
     $form_data = $form;
     $form_data['#cache_token'] = $cache_token;
     $this->formCacheStore->expects($this->once())->method('setWithExpire')->with($form_build_id, $form_data, $this->isType('int'));
     $form_state_data = $form_state->getCacheableArray();
     $this->formStateCacheStore->expects($this->once())->method('setWithExpire')->with($form_build_id, $form_state_data, $this->isType('int'));
     $this->csrfToken->expects($this->once())->method('get')->willReturn($cache_token);
     $this->account->expects($this->once())->method('isAuthenticated')->willReturn(TRUE);
     $this->formCache->setCache($form_build_id, $form, $form_state);
 }
开发者ID:isramv,项目名称:camp-gdl,代码行数:18,代码来源:FormCacheTest.php


注:本文中的Drupal\Core\Form\FormState::getCacheableArray方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。