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


PHP FormStateInterface::getCacheableArray方法代码示例

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


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

示例1: 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

示例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);
     }
     if ($data = $form_state->getCacheableArray()) {
         $this->keyValueExpirableFactory->get('form_state')->setWithExpire($form_build_id, $data, $expire);
     }
 }
开发者ID:aWEBoLabs,项目名称:taxi,代码行数:28,代码来源:FormCache.php

示例3: getCacheableArray

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

示例4: setCache

 /**
  * {@inheritdoc}
  */
 public function setCache($form_build_id, $form, FormStateInterface $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->addBuildInfo('safe_strings', SafeMarkup::getAll());
     if ($data = $form_state->getCacheableArray()) {
         $this->keyValueExpirableFactory->get('form_state')->setWithExpire($form_build_id, $data, $expire);
     }
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:23,代码来源:FormBuilder.php

示例5: testGetCacheableArray

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


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