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


PHP FormState::setCached方法代码示例

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


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

示例1: testFormCacheDeletionCached

 /**
  * Tests that a cached form is deleted after submit.
  */
 public function testFormCacheDeletionCached()
 {
     $form_id = 'test_form_id';
     $form_build_id = $this->randomMachineName();
     $expected_form = $form_id();
     $expected_form['#build_id'] = $form_build_id;
     $form_arg = $this->getMockForm($form_id, $expected_form);
     $form_arg->expects($this->once())->method('submitForm')->willReturnCallback(function (array &$form, FormStateInterface $form_state) {
         // Mimic EntityForm by cleaning the $form_state upon submit.
         $form_state->cleanValues();
     });
     $this->formCache->expects($this->once())->method('deleteCache')->with($form_build_id);
     $form_state = new FormState();
     $form_state->setRequestMethod('POST');
     $form_state->setCached();
     $this->simulateFormSubmission($form_id, $form_arg, $form_state);
 }
开发者ID:318io,项目名称:318-io,代码行数:20,代码来源:FormBuilderTest.php

示例2: testSetCachedGet

 /**
  * @covers ::setCached
  *
  * @expectedException \LogicException
  * @expectedExceptionMessage Form state caching on GET requests is not allowed.
  */
 public function testSetCachedGet()
 {
     $form_state = new FormState();
     $form_state->setRequestMethod('GET');
     $form_state->setCached();
 }
开发者ID:318io,项目名称:318-io,代码行数:12,代码来源:FormStateTest.php

示例3: testLoggerSerialization

 /**
  * Tests db log injection serialization.
  */
 public function testLoggerSerialization()
 {
     $form_state = new FormState();
     // Forms are only serialized during POST requests.
     $form_state->setRequestMethod('POST');
     $form_state->setCached();
     $form_builder = $this->container->get('form_builder');
     $form_id = $form_builder->getFormId($this, $form_state);
     $form = $form_builder->retrieveForm($form_id, $form_state);
     $form_builder->prepareForm($form_id, $form, $form_state);
     $form_builder->processForm($form_id, $form, $form_state);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:15,代码来源:DbLogFormInjectionTest.php

示例4: testLoggerSerialization

 /**
  * Tests db log injection serialization.
  */
 public function testLoggerSerialization()
 {
     $form_state = new FormState();
     $form_state->setCached();
     $form_builder = $this->container->get('form_builder');
     $form_id = $form_builder->getFormId($this, $form_state);
     $form = $form_builder->retrieveForm($form_id, $form_state);
     $form_builder->prepareForm($form_id, $form, $form_state);
     $form_builder->processForm($form_id, $form, $form_state);
 }
开发者ID:RealLukeMartin,项目名称:drupal8tester,代码行数:13,代码来源:DbLogFormInjectionTest.php


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