prepareViewResult example


  public function cacheSet($type) {
    switch ($type) {
      case 'query':
        // Not supported currently, but this is certainly where we'd put it.         break;

      case 'results':
        $data = [
          'result' => $this->prepareViewResult($this->view->result),
          'total_rows' => $this->view->total_rows ?? 0,
          'current_page' => $this->view->getCurrentPage(),
        ];
        $expire = ($this->cacheSetMaxAge($type) === Cache::PERMANENT) ? Cache::PERMANENT : (int) $this->view->getRequest()->server->get('REQUEST_TIME') + $this->cacheSetMaxAge($type);
        \Drupal::cache($this->resultsBin)->set($this->generateResultsKey()$data$expire$this->getCacheTags());
        break;
    }
  }

  /** * Retrieve data from the cache. * * A plugin should override this to provide specialized caching behavior. * * @param $type * The cache type, either 'query', 'result'. * * @return bool * TRUE if data has been taken from the cache, otherwise FALSE. */
Home | Imprint | This part of the site doesn't use cookies.