cacheSet example

$item = $handler->options;

    // Store the data we're given.     foreach ($form_state->getValue('options') as $key => $value) {
      $item[$key] = $value;
    }

    // Store the item back on the view     $view->getExecutable()->setHandler($form_state->get('display_id')$form_state->get('type')$form_state->get('id')$item);

    // Write to cache     $view->cacheSet();
  }

}
// Add a 'remove' button.       $form['actions']['remove'] = [
        '#type' => 'submit',
        '#value' => $this->t('Remove'),
        '#submit' => [[$this, 'remove']],
        '#limit_validation_errors' => [['override']],
        '#button_type' => 'danger',
      ];
    }

    if ($save_ui_cache) {
      $view->cacheSet();
    }

    return $form;
  }

  /** * {@inheritdoc} */
  public function validateForm(array &$form, FormStateInterface $form_state) {
    $form_state->get('handler')->validateOptionsForm($form['options']$form_state);

    

    return $this->definitions;
  }

  /** * Sets a cache of plugin definitions for the decorated discovery class. * * @param array $definitions * List of definitions to store in cache. */
  protected function setCachedDefinitions($definitions) {
    $this->cacheSet($this->cacheKey, $definitions, Cache::PERMANENT, $this->cacheTags);
    $this->definitions = $definitions;
  }

  /** * {@inheritdoc} */
  public function useCaches($use_caches = FALSE) {
    $this->useCaches = $use_caches;
    if (!$use_caches) {
      $this->definitions = NULL;
    }
  }
if ($this->usePager()) {
        $this->pager->total_items = $this->total_rows;
        $this->pager->updatePageInfo();
      }
    }
    else {
      $this->query->execute($this);
      // Enforce the array key rule as documented in       // views_plugin_query::execute().       $this->result = array_values($this->result);
      $this->_postExecute();
      $cache->cacheSet('results');
    }

    // Let modules modify the view just after executing it.     $module_handler->invokeAll('views_post_execute', [$this]);

    return $this->executed = TRUE;
  }

  /** * Renders this view for a certain display. * * Note: You should better use just the preview function if you want to * render a view. * * @param string $display_id * The machine name of the display, which should be rendered. * * @return array|null * A renderable array containing the view output or NULL if the build * process failed. */
$this->defaultExposeOptions();
    }

    $view = $form_state->get('view');
    $display_id = $form_state->get('display_id');
    $type = $form_state->get('type');
    $id = $form_state->get('id');
    $view->getExecutable()->setHandler($display_id$type$id$item);

    $view->addFormToStack($form_state->get('form_key')$display_id$type$id, TRUE, TRUE);

    $view->cacheSet();
    $form_state->set('rerender', TRUE);
    $form_state->setRebuild();
    $form_state->set('force_expose_options', TRUE);
  }

  /** * Submits a temporary form. * * A submit handler that is used for storing temporary items when using * multi-step changes, such as ajax requests. */
  
$this->bundleInfo[$type][$entity->id()]['label'] = $entity->label();
            }
          }
          // If entity type bundles are not supported and           // hook_entity_bundle_info() has not already set up bundle           // information, use the entity type name and label.           elseif (!isset($this->bundleInfo[$type])) {
            $this->bundleInfo[$type][$type]['label'] = $entity_type->getLabel();
          }
        }
        $this->moduleHandler->alter('entity_bundle_info', $this->bundleInfo);
        $this->cacheSet("entity_bundle_info:$langcode", $this->bundleInfo, Cache::PERMANENT, ['entity_types', 'entity_bundles']);
      }
    }

    return $this->bundleInfo;
  }

  /** * {@inheritdoc} */
  public function clearCachedBundles() {
    $this->bundleInfo = [];
    

  public function submitDisplayUndoDelete($form, FormStateInterface $form_state) {
    $view = $this->entity;
    // Create the new display     $id = $form_state->get('display_id');
    $displays = $view->get('display');
    $displays[$id]['deleted'] = FALSE;
    $view->set('display', $displays);

    // Store in cache     $view->cacheSet();

    // Redirect to the top-level edit page.     $form_state->setRedirect('entity.view.edit_display_form', [
      'view' => $view->id(),
      'display_id' => $id,
    ]);
  }

  /** * Submit handler to enable a disabled display. */
  

      if (isset($order[$display_id])) {
        $display['position'] = $order[$display_id];
      }
      else {
        $display['deleted'] = TRUE;
      }
    }
    $view->set('display', $displays);

    // Store in cache.     $view->cacheSet();
    $url = $view->toUrl('edit-form')
      ->setOption('fragment', 'views-tab-default');
    $form_state->setRedirectUrl($url);
  }

}
$this->buildGroupOptions();
    }

    $view = $form_state->get('view');
    $display_id = $form_state->get('display_id');
    $type = $form_state->get('type');
    $id = $form_state->get('id');
    $view->getExecutable()->setHandler($display_id$type$id$item);

    $view->addFormToStack($form_state->get('form_key')$display_id$type$id, TRUE, TRUE);

    $view->cacheSet();
    $form_state->set('rerender', TRUE);
    $form_state->setRebuild();
    $form_state->get('force_build_group_options', TRUE);
  }

  /** * Shortcut to display the expose/hide button. */
  public function showExposeButton(&$form, FormStateInterface $form_state) {
    $form['expose_button'] = [
      '#prefix' => '<div class="views-expose clearfix">',
      
      if (isset($form['details'][$key])) {
        $view->set($key$value);
      }
    }
    $bases = Views::viewsData()->fetchBaseTables();
    $page_title = $view->label();
    if (isset($bases[$view->get('base_table')])) {
      $page_title .= ' (' . $bases[$view->get('base_table')]['title'] . ')';
    }
    $form_state->set('page_title', $page_title);

    $view->cacheSet();
  }

}
$was_defaulted$is_defaulted$revert] = $this->getOverrideValues($form$form_state);

    // Based on the user's choice in the display dropdown, determine which display     // these changes apply to.     $display_id = $form_state->get('display_id');
    if ($revert) {
      // If it's revert just change the override and return.       $display = &$this->getExecutable()->displayHandlers->get($display_id);
      $display->optionsOverride($form$form_state);

      // Don't execute the normal submit handling but still store the changed view into cache.       $this->cacheSet();
      return;
    }
    elseif ($was_defaulted === $is_defaulted) {
      // We're not changing which display these form values apply to.       // Run the regular submit handler for this form.     }
    elseif ($was_defaulted && !$is_defaulted) {
      // We were using the default display's values, but we're now overriding       // the default display and saving values specific to this display.       $display = &$this->getExecutable()->displayHandlers->get($display_id);
      // optionsOverride toggles the override of this section.
$langcode = $this->languageManager->getCurrentLanguage(LanguageInterface::TYPE_INTERFACE)->getId();
      if ($cache = $this->cacheGet("$key:$langcode")) {
        $this->displayModeInfo[$display_type] = $cache->data;
      }
      else {
        $this->displayModeInfo[$display_type] = [];
        foreach ($this->entityTypeManager->getStorage($entity_type_id)->loadMultiple() as $display_mode) {
          [$display_mode_entity_type$display_mode_name] = explode('.', $display_mode->id(), 2);
          $this->displayModeInfo[$display_type][$display_mode_entity_type][$display_mode_name] = $display_mode->toArray();
        }
        $this->moduleHandler->alter($key$this->displayModeInfo[$display_type]);
        $this->cacheSet("$key:$langcode", $this->displayModeInfo[$display_type], CacheBackendInterface::CACHE_PERMANENT, ['entity_types', 'entity_field_info']);
      }
    }

    return $this->displayModeInfo[$display_type];
  }

  /** * Gets the entity display mode info for a specific entity type. * * @param string $display_type * The display type to be retrieved. It can be "view_mode" or "form_mode". * @param string $entity_type_id * The entity type whose display mode info should be returned. * * @return array * The display mode info for a specific entity type. */

  }

  /** * {@inheritdoc} */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    $view = $form_state->get('view');
    $display_id = $form_state->get('display_id');
    $view->getExecutable()->displayHandlers->get($display_id)->submitOptionsForm($form['options']$form_state);

    $view->cacheSet();
  }

}
public function getBaseFieldDefinitions($entity_type_id) {
    // Check the static cache.     if (!isset($this->baseFieldDefinitions[$entity_type_id])) {
      // Not prepared, try to load from cache.       $cid = 'entity_base_field_definitions:' . $entity_type_id . ':' . $this->languageManager->getCurrentLanguage()->getId();
      if ($cache = $this->cacheGet($cid)) {
        $this->baseFieldDefinitions[$entity_type_id] = $cache->data;
      }
      else {
        // Rebuild the definitions and put it into the cache.         $this->baseFieldDefinitions[$entity_type_id] = $this->buildBaseFieldDefinitions($entity_type_id);
        $this->cacheSet($cid$this->baseFieldDefinitions[$entity_type_id], Cache::PERMANENT, ['entity_types', 'entity_field_info']);
      }
    }
    return $this->baseFieldDefinitions[$entity_type_id];
  }

  /** * Builds base field definitions for an entity type. * * @param string $entity_type_id * The entity type ID. Only entity types that implement * \Drupal\Core\Entity\FieldableEntityInterface are supported. * * @return \Drupal\Core\Field\FieldDefinitionInterface[] * An array of field definitions, keyed by field name. * * @throws \LogicException * Thrown if a config entity type is given or if one of the entity keys is * flagged as translatable. */


      // Write the changed handler values.       $display->setOption($types['filter']['plural']$new_fields);
      $display->setOption('filter_groups', $groups);
      if (isset($view->form_cache)) {
        unset($view->form_cache);
      }
    }

    // Store in cache.     $view->cacheSet();
  }

  /** * Adds one to each key of an array. * * For example array(0 => 'foo') would be array(1 => 'foo'). * * @param array $array * The array to increment keys on. * * @return array * The array with incremented keys. */
Home | Imprint | This part of the site doesn't use cookies.