本文整理汇总了PHP中Drupal\Core\Form\FormState::setRequestMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP FormState::setRequestMethod方法的具体用法?PHP FormState::setRequestMethod怎么用?PHP FormState::setRequestMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Form\FormState
的用法示例。
在下文中一共展示了FormState::setRequestMethod方法的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);
}
示例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();
}
示例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);
}
示例4: testQueueSerialization
/**
* Tests queue injection serialization.
*/
public function testQueueSerialization()
{
$form_state = new FormState();
$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);
}