disableCache example

Zend_Locale_Data::clearCache($tag);
    }

    /** * Disables the set cache * * @param boolean $flag True disables any set cache, default is false * @return void */
    public static function disableCache($flag)
    {
        Zend_Locale_Data::disableCache($flag);
    }

    /** * Internal function, returns a single locale on detection * * @param string|Zend_Locale $locale (Optional) Locale to work on * @param boolean $strict (Optional) Strict preparation * @throws Zend_Locale_Exception When no locale is set which is only possible when the class was wrong extended * @return string */
    private static function _prepareLocale($locale$strict = false)
    {
case 'locale' :
                    $options['locale'] = Zend_Locale::findLocale($value);
                    break;

                case 'cache' :
                    if ($value instanceof Zend_Cache_Core) {
                        Zend_Locale_Data::setCache($value);
                    }
                    break;

                case 'disablecache' :
                    Zend_Locale_Data::disableCache($value);
                    break;

                case 'precision' :
                    if ($value === NULL) {
                        $value = -1;
                    }

                    if (($value < -1) || ($value > 30)) {
                        throw new Zend_Locale_Exception("'$value' precision is not a whole number less than 30.");
                    }
                    break;

                
/** * {@inheritdoc} */
  public function form(array $form, FormStateInterface $form_state) {
    $view = $this->entity;

    $form['#prefix'] = '<div id="views-preview-wrapper" class="views-preview-wrapper views-admin clearfix">';
    $form['#suffix'] = '</div>';
    $form['#id'] = 'views-ui-preview-form';

    $form_state->disableCache();

    $form['controls']['#attributes'] = ['class' => ['clearfix']];

    $form['controls']['title'] = [
      '#prefix' => '<h2 class="view-preview-form__title">',
      '#markup' => $this->t('Preview'),
      '#suffix' => '</h2>',
    ];

    // Add a checkbox controlling whether or not this display auto-previews.     $form['controls']['live_preview'] = [
      
/** @var \Drupal\views_ui\ViewUI $view */
    $view = $this->entity;
    $display_id = $this->displayID;
    // Do not allow the form to be cached, because $form_state->get('view') can become     // stale between page requests.     // See views_ui_ajax_get_form() for how this affects #ajax.     // @todo To remove this and allow the form to be cacheable:     // - Change $form_state->get('view') to $form_state->getTemporary()['view'].     // - Add a #process function to initialize $form_state->getTemporary()['view']     // on cached form submissions.     // - Use \Drupal\Core\Form\FormStateInterface::loadInclude().     $form_state->disableCache();

    if ($display_id) {
      if (!$view->getExecutable()->setDisplay($display_id)) {
        $form['#markup'] = $this->t('Invalid display id @display', ['@display' => $display_id]);
        return $form;
      }
    }

    $form['#tree'] = TRUE;

    $form['#attached']['library'][] = 'core/drupal.dialog.ajax';
    
/** * {@inheritdoc} */
  public function isCached() {
    return $this->decoratedFormState->isCached();
  }

  /** * {@inheritdoc} */
  public function disableCache() {
    $this->decoratedFormState->disableCache();

    return $this;
  }

  /** * {@inheritdoc} */
  public function setExecuted() {
    $this->decoratedFormState->setExecuted();

    return $this;
  }
$renderer = \Drupal::service('renderer');

    // This won't override settings already in.     if (!$form_state->has('rerender')) {
      $form_state->set('rerender', FALSE);
    }
    $ajax = $form_state->get('ajax');
    // Do not overwrite if the redirect has been disabled.     if (!$form_state->isRedirectDisabled()) {
      $form_state->disableRedirect($ajax);
    }
    $form_state->disableCache();

    // Builds the form in a render context in order to ensure that cacheable     // metadata is bubbled up.     $render_context = new RenderContext();
    $callable = function D) use ($form_class, &$form_state) {
      return \Drupal::formBuilder()->buildForm($form_class$form_state);
    };
    $form = $renderer->executeInRenderContext($render_context$callable);

    if (!$render_context->isEmpty()) {
      BubbleableMetadata::createFromRenderArray($form)
        
public function testSetCachedWithLogicException($cache) {
    $this->decoratedFormState->setCached($cache)
      ->willThrow(\LogicException::class);
    $this->expectException(\LogicException::class);
    $this->formStateDecoratorBase->setCached($cache);
  }

  /** * @covers ::disableCache */
  public function testDisableCache() {
    $this->decoratedFormState->disableCache()
      ->shouldBeCalled();

    $this->assertSame($this->formStateDecoratorBase, $this->formStateDecoratorBase->disableCache());
  }

  /** * @covers ::setExecuted */
  public function testSetExecuted() {
    $this->decoratedFormState->setExecuted()
      ->shouldBeCalled();

    
Home | Imprint | This part of the site doesn't use cookies.