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


PHP FormStateInterface::setFormState方法代码示例

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


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

示例1: loadCachedFormState

 /**
  * Loads the cached form state.
  *
  * @param string $form_build_id
  *   The unique form build ID.
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The current state of the form.
  */
 protected function loadCachedFormState($form_build_id, FormStateInterface $form_state)
 {
     if ($stored_form_state = $this->keyValueExpirableFactory->get('form_state')->get($form_build_id)) {
         // Re-populate $form_state for subsequent rebuilds.
         $form_state->setFormState($stored_form_state);
         // If the original form is contained in include files, load the files.
         // @see \Drupal\Core\Form\FormStateInterface::loadInclude()
         $build_info = $form_state->getBuildInfo();
         $build_info += ['files' => []];
         foreach ($build_info['files'] as $file) {
             if (is_array($file)) {
                 $file += array('type' => 'inc', 'name' => $file['module']);
                 $this->moduleHandler->loadInclude($file['module'], $file['type'], $file['name']);
             } elseif (file_exists($file)) {
                 require_once $this->root . '/' . $file;
             }
         }
         // Retrieve the list of previously known safe strings and store it for
         // this request.
         // @todo Ensure we are not storing an excessively large string list
         //   in: https://www.drupal.org/node/2295823
         $build_info += ['safe_strings' => []];
         SafeMarkup::setMultiple($build_info['safe_strings']);
         unset($build_info['safe_strings']);
         $form_state->setBuildInfo($build_info);
     }
 }
开发者ID:Nikola-xiii,项目名称:d8intranet,代码行数:35,代码来源:FormCache.php

示例2: loadCachedFormState

 /**
  * Loads the cached form state.
  *
  * @param string $form_build_id
  *   The unique form build ID.
  * @param \Drupal\Core\Form\FormStateInterface $form_state
  *   The current state of the form.
  */
 protected function loadCachedFormState($form_build_id, FormStateInterface $form_state)
 {
     if ($stored_form_state = $this->keyValueExpirableFactory->get('form_state')->get($form_build_id)) {
         // Re-populate $form_state for subsequent rebuilds.
         $form_state->setFormState($stored_form_state);
         // If the original form is contained in include files, load the files.
         // @see \Drupal\Core\Form\FormStateInterface::loadInclude()
         $build_info = $form_state->getBuildInfo();
         $build_info += ['files' => []];
         foreach ($build_info['files'] as $file) {
             if (is_array($file)) {
                 $file += array('type' => 'inc', 'name' => $file['module']);
                 $this->moduleHandler->loadInclude($file['module'], $file['type'], $file['name']);
             } elseif (file_exists($file)) {
                 require_once $this->root . '/' . $file;
             }
         }
     }
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:27,代码来源:FormCache.php

示例3: setFormState

 /**
  * {@inheritdoc}
  */
 public function setFormState(array $form_state_additions)
 {
     $this->decoratedFormState->setFormState($form_state_additions);
     return $this;
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:8,代码来源:FormStateDecoratorBase.php

示例4: getCache

 /**
  * {@inheritdoc}
  */
 public function getCache($form_build_id, FormStateInterface &$form_state)
 {
     if ($form = $this->keyValueExpirableFactory->get('form')->get($form_build_id)) {
         $user = $this->currentUser();
         if (isset($form['#cache_token']) && $this->csrfToken->validate($form['#cache_token']) || !isset($form['#cache_token']) && $user->isAnonymous()) {
             if ($stored_form_state = $this->keyValueExpirableFactory->get('form_state')->get($form_build_id)) {
                 // Re-populate $form_state for subsequent rebuilds.
                 $form_state->setFormState($stored_form_state);
                 // If the original form is contained in include files, load the files.
                 // @see form_load_include()
                 $form_state['build_info'] += array('files' => array());
                 foreach ($form_state['build_info']['files'] as $file) {
                     if (is_array($file)) {
                         $file += array('type' => 'inc', 'name' => $file['module']);
                         $this->moduleHandler->loadInclude($file['module'], $file['type'], $file['name']);
                     } elseif (file_exists($file)) {
                         require_once DRUPAL_ROOT . '/' . $file;
                     }
                 }
                 // Retrieve the list of previously known safe strings and store it
                 // for this request.
                 // @todo Ensure we are not storing an excessively large string list
                 //   in: https://www.drupal.org/node/2295823
                 $form_state['build_info'] += array('safe_strings' => array());
                 SafeMarkup::setMultiple($form_state['build_info']['safe_strings']);
                 unset($form_state['build_info']['safe_strings']);
             }
             return $form;
         }
     }
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:34,代码来源:FormBuilder.php

示例5: testSetFormState

 /**
  * @covers ::setFormState
  */
 public function testSetFormState()
 {
     $form_state_additions = ['foo' => 'bar'];
     $this->decoratedFormState->setFormState($form_state_additions)->shouldBeCalled();
     $this->assertSame($this->formStateDecoratorBase, $this->formStateDecoratorBase->setFormState($form_state_additions));
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:9,代码来源:FormStateDecoratorBaseTest.php


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