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


PHP StylePluginBase::preRender方法代码示例

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


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

示例1: render

 /**
  * Render 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 string|null
  *   Return the output of the rendered view or NULL if something failed in the process.
  */
 public function render($display_id = NULL)
 {
     $this->execute($display_id);
     // Check to see if the build failed.
     if (!empty($this->build_info['fail'])) {
         return;
     }
     if (!empty($this->build_info['denied'])) {
         return;
     }
     $exposed_form = $this->display_handler->getPlugin('exposed_form');
     $exposed_form->preRender($this->result);
     $module_handler = \Drupal::moduleHandler();
     // @TODO In the longrun, it would be great to execute a view without
     //   the theme system at all. See https://www.drupal.org/node/2322623.
     $active_theme = \Drupal::theme()->getActiveTheme();
     $themes = array_keys($active_theme->getBaseThemes());
     $themes[] = $active_theme->getName();
     // Check for already-cached output.
     if (!empty($this->live_preview)) {
         $cache = FALSE;
     } else {
         /** @var \Drupal\views\Plugin\views\cache\CachePluginBase $cache */
         $cache = $this->display_handler->getPlugin('cache');
     }
     // Run preRender for the pager as it might change the result.
     if (!empty($this->pager)) {
         $this->pager->preRender($this->result);
     }
     // Initialize the style plugin.
     $this->initStyle();
     if (!isset($this->response)) {
         // Set the response so other parts can alter it.
         $this->response = new Response('', 200);
     }
     // Give field handlers the opportunity to perform additional queries
     // using the entire resultset prior to rendering.
     if ($this->style_plugin->usesFields()) {
         foreach ($this->field as $id => $handler) {
             if (!empty($this->field[$id])) {
                 $this->field[$id]->preRender($this->result);
             }
         }
     }
     $this->style_plugin->preRender($this->result);
     // Let each area handler have access to the result set.
     $areas = array('header', 'footer');
     // Only call preRender() on the empty handlers if the result is empty.
     if (empty($this->result)) {
         $areas[] = 'empty';
     }
     foreach ($areas as $area) {
         foreach ($this->{$area} as $handler) {
             $handler->preRender($this->result);
         }
     }
     // Let modules modify the view just prior to rendering it.
     $module_handler->invokeAll('views_pre_render', array($this));
     // Let the themes play too, because pre render is a very themey thing.
     foreach ($themes as $theme_name) {
         $function = $theme_name . '_views_pre_render';
         if (function_exists($function)) {
             $function($this);
         }
     }
     $this->display_handler->output = $this->display_handler->render();
     $exposed_form->postRender($this->display_handler->output);
     if ($cache) {
         $cache->postRender($this->display_handler->output);
     }
     // Let modules modify the view output after it is rendered.
     $module_handler->invokeAll('views_post_render', array($this, &$this->display_handler->output, $cache));
     // Let the themes play too, because post render is a very themey thing.
     foreach ($themes as $theme_name) {
         $function = $theme_name . '_views_post_render';
         if (function_exists($function)) {
             $function($this);
         }
     }
     return $this->display_handler->output;
 }
开发者ID:nsp15,项目名称:Drupal8,代码行数:93,代码来源:ViewExecutable.php

示例2: render

 /**
  * Render 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 string|null
  *   Return the output of the rendered view or NULL if something failed in the process.
  */
 public function render($display_id = NULL)
 {
     $this->execute($display_id);
     // Check to see if the build failed.
     if (!empty($this->build_info['fail'])) {
         return;
     }
     if (!empty($this->build_info['denied'])) {
         return;
     }
     $exposed_form = $this->display_handler->getPlugin('exposed_form');
     $exposed_form->preRender($this->result);
     $module_handler = \Drupal::moduleHandler();
     // Check for already-cached output.
     if (!empty($this->live_preview)) {
         $cache = FALSE;
     } else {
         $cache = $this->display_handler->getPlugin('cache');
     }
     if ($cache && $cache->cacheGet('output')) {
     } else {
         if ($cache) {
             $cache->cacheStart();
         }
         // Run preRender for the pager as it might change the result.
         if (!empty($this->pager)) {
             $this->pager->preRender($this->result);
         }
         // Initialize the style plugin.
         $this->initStyle();
         if (!isset($this->response)) {
             // Set the response so other parts can alter it.
             $this->response = new Response('', 200);
         }
         // Give field handlers the opportunity to perform additional queries
         // using the entire resultset prior to rendering.
         if ($this->style_plugin->usesFields()) {
             foreach ($this->field as $id => $handler) {
                 if (!empty($this->field[$id])) {
                     $this->field[$id]->preRender($this->result);
                 }
             }
         }
         $this->style_plugin->preRender($this->result);
         // Let each area handler have access to the result set.
         $areas = array('header', 'footer');
         // Only call preRender() on the empty handlers if the result is empty.
         if (empty($this->result)) {
             $areas[] = 'empty';
         }
         foreach ($areas as $area) {
             foreach ($this->{$area} as $handler) {
                 $handler->preRender($this->result);
             }
         }
         // Let modules modify the view just prior to rendering it.
         $module_handler->invokeAll('views_pre_render', array($this));
         // Let the themes play too, because pre render is a very themey thing.
         if (isset($GLOBALS['base_theme_info']) && isset($GLOBALS['theme'])) {
             foreach ($GLOBALS['base_theme_info'] as $base) {
                 $module_handler->invoke($base->getName(), 'views_pre_render', array($this));
             }
             $module_handler->invoke($GLOBALS['theme'], 'views_pre_render', array($this));
         }
         $this->display_handler->output = $this->display_handler->render();
         if ($cache) {
             $cache->cacheSet('output');
         }
     }
     $exposed_form->postRender($this->display_handler->output);
     if ($cache) {
         $cache->postRender($this->display_handler->output);
     }
     // Let modules modify the view output after it is rendered.
     $module_handler->invokeAll('views_post_render', array($this, &$this->display_handler->output, $cache));
     // Let the themes play too, because post render is a very themey thing.
     if (isset($GLOBALS['base_theme_info']) && isset($GLOBALS['theme'])) {
         foreach ($GLOBALS['base_theme_info'] as $base) {
             $module_handler->invoke($base->getName(), 'views_post_render', array($this));
         }
         $module_handler->invoke($GLOBALS['theme'], 'views_post_render', array($this));
     }
     return $this->display_handler->output;
 }
开发者ID:alnutile,项目名称:drunatra,代码行数:96,代码来源:ViewExecutable.php


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