isCached example

$this->request->setMethod('POST');
    $form_state->setRequestMethod('POST');

    // Rebuild the form, and assert that the build ID has not changed.     $form_state->setRebuild();
    $input['form_id'] = $form_id;
    $form_state->setUserInput($input);
    $form_state->addRebuildInfo('copy', ['#build_id' => TRUE]);
    $this->formBuilder->processForm($form_id$form$form_state);
    $this->assertSame($original_build_id$form['#build_id']);
    $this->assertTrue($form_state->isCached());

    // Rebuild the form again, and assert that there is a new build ID.     $form_state->setRebuildInfo([]);
    $form = $this->formBuilder->buildForm($form_arg$form_state);
    $this->assertNotSame($original_build_id$form['#build_id']);
    $this->assertTrue($form_state->isCached());
  }

  /** * Tests the rebuildForm() method for a GET submission. */
  
$template->assign('sCampaign', $this->getMailingDetails($mailing['id']), true);
        $template->assign('sConfig', Shopware()->Config());
        $template->assign('sBasefile', Shopware()->Config()->get('BaseFile'));
        $template->assign('theme', $config);

        $templatePath = 'newsletter/index/' . $mailing['template'];

        if (!empty($mailing['plaintext'])) {
            $templatePath = 'newsletter/alt/' . $mailing['template'];
        }

        if (!$template->isCached($templatePath)) {
            $template->assign('sMailing', $mailing);
            $template->assign('sStart', ($shop->getSecure() ? 'https://' : 'http://') . $shop->getHost() . $shop->getBaseUrl());
            $template->assign('sUserGroup', Shopware()->System()->sUSERGROUP);
            $template->assign('sUserGroupData', Shopware()->System()->sUSERGROUPDATA);
            $template->assign('sMainCategories', Shopware()->Modules()->Categories()->sGetMainCategories());
        }

        return $template;
    }

    /** * @deprecated in 5.6, will be private in 5.8 * * Returns mailing data using the mailing id. * * @param int $id * * @return array */
    // the original #action needs to be retained.     if (isset($old_form['#action']) && !empty($rebuild_info['copy']['#action'])) {
      $form['#action'] = $old_form['#action'];
    }

    $this->prepareForm($form_id$form$form_state);

    // Caching is normally done in self::processForm(), but what needs to be     // cached is the $form structure before it passes through     // self::doBuildForm(), so we need to do it here.     // @todo For Drupal 8, find a way to avoid this code duplication.     if ($form_state->isCached()) {
      $this->setCache($form['#build_id']$form$form_state);
    }

    // Clear out all group associations as these might be different when     // re-rendering the form.     $form_state->setGroups([]);

    // Return a fully built form that is ready for rendering.     return $this->doBuildForm($form_id$form$form_state);
  }

  
->shouldBeCalled();

    $this->assertSame($this->formStateDecoratorBase, $this->formStateDecoratorBase->setCached($cache));
  }

  /** * @covers ::isCached * * @dataProvider providerSingleBooleanArgument */
  public function testIsCached($cache) {
    $this->decoratedFormState->isCached()
      ->willReturn($cache)
      ->shouldBeCalled();
    $this->assertSame($cache$this->formStateDecoratorBase->isCached());
  }

  /** * @covers ::setCached * * @dataProvider providerSingleBooleanArgument */
  public function testSetCachedWithLogicException($cache) {
    

  public function setCached($cache = TRUE) {
    $this->decoratedFormState->setCached($cache);

    return $this;
  }

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

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

    return $this;
  }

  

  public function testIsCached($cache_key$no_cache_key$expected) {
    $form_state = (new FormState())->setFormState([
      'cache' => $cache_key,
      'no_cache' => $no_cache_key,
    ]);

    $form_state->setMethod('POST');
    $this->assertSame($expected$form_state->isCached());

    $form_state->setMethod('GET');
    $this->assertSame($expected$form_state->isCached());
  }

  /** * Provides test data for testIsCached(). */
  public function providerTestIsCached() {
    $data = [];
    $data[] = [
      

        }
        if ((!$this->caching || $_template->has_nocache_code || $_template->source->recompiled) && !$no_output_filter && (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))) {
            $_output = Smarty_Internal_Filter_Handler::runFilter('output', $_output$_template);
        }
        if (isset($this->error_reporting)) {
            error_reporting($_smarty_old_error_level);
        }
        // display or fetch         if ($display) {
            if ($this->caching && $this->cache_modified_check) {
                $_isCached = $_template->isCached() && !$_template->has_nocache_code;
                $_last_modified_date = @substr($_SERVER['HTTP_IF_MODIFIED_SINCE'], 0, strpos($_SERVER['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3);
                if ($_isCached && $_template->cached->timestamp <= strtotime($_last_modified_date)) {
                    switch (PHP_SAPI) {
                        case 'cgi':         // php-cgi < 5.3                         case 'cgi-fcgi':    // php-cgi >= 5.3                         case 'fpm-fcgi':    // php-fpm >= 5.3.3                         header('Status: 304 Not Modified');
                        break;

                        case 'cli':
                        if (/* ^phpunit */!empty($_SERVER['SMARTY_PHPUNIT_DISABLE_HEADERS'])/* phpunit$ */) {
                            
/** * test to see if valid cache exists for this template * * @param string $tpl_file name of template file * @param string $cache_id * @param string $compile_id * @return boolean */
    public function is_cached($tpl_file$cache_id = null, $compile_id = null)
    {
        return $this->isCached($tpl_file$cache_id$compile_id);
    }

    /** * clear all the assigned template variables. */
    public function clear_all_assign()
    {
        $this->clearAllAssign();
    }

    /** * clears compiled version of specified template resource, * or all compiled template files if one is not specified. * This function is for advanced use only, not normally needed. * * @param string $tpl_file * @param string $compile_id * @param string $exp_time * @return boolean results of {@link smarty_core_rm_auto()} */
Home | Imprint | This part of the site doesn't use cookies.