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


PHP ViewExecutable::setArguments方法代码示例

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


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

示例1: getGallery

 /**
  * {@inheritdoc}
  */
 protected function getGallery()
 {
     $this->view->setDisplay($this->displayName);
     $this->view->setArguments($this->viewArgs);
     $rendered_view = $this->view->render();
     // Make sure that the Juicebox is actually built.
     if (!empty($rendered_view['#rows']['#gallery']) && $rendered_view['#rows']['#gallery'] instanceof JuiceboxGalleryInterface && $rendered_view['#rows']['#gallery']->getId()) {
         return $rendered_view['#rows']['#gallery'];
     }
     throw new \Exception(t('Cannot build Juicebox XML for view-based gallery.'));
 }
开发者ID:pulibrary,项目名称:recap,代码行数:14,代码来源:JuiceboxXmlControllerViewsStyle.php

示例2: renderPreview

 public function renderPreview($display_id, $args = array())
 {
     // Save the current path so it can be restored before returning from this function.
     $old_q = current_path();
     // Determine where the query and performance statistics should be output.
     $config = \Drupal::config('views.settings');
     $show_query = $config->get('ui.show.sql_query.enabled');
     $show_info = $config->get('ui.show.preview_information');
     $show_location = $config->get('ui.show.sql_query.where');
     $show_stats = $config->get('ui.show.performance_statistics');
     if ($show_stats) {
         $show_stats = $config->get('ui.show.sql_query.where');
     }
     $combined = $show_query && $show_stats;
     $rows = array('query' => array(), 'statistics' => array());
     $output = '';
     $errors = $this->executable->validate();
     $this->executable->destroy();
     if (empty($errors)) {
         $this->ajax = TRUE;
         $this->executable->live_preview = TRUE;
         // AJAX happens via HTTP POST but everything expects exposed data to
         // be in GET. Copy stuff but remove ajax-framework specific keys.
         // If we're clicking on links in a preview, though, we could actually
         // have some input in the query parameters, so we merge request() and
         // query() to ensure we get it all.
         $exposed_input = array_merge(\Drupal::request()->request->all(), \Drupal::request()->query->all());
         foreach (array('view_name', 'view_display_id', 'view_args', 'view_path', 'view_dom_id', 'pager_element', 'view_base_path', 'ajax_html_ids', 'ajax_page_state', 'form_id', 'form_build_id', 'form_token') as $key) {
             if (isset($exposed_input[$key])) {
                 unset($exposed_input[$key]);
             }
         }
         $this->executable->setExposedInput($exposed_input);
         if (!$this->executable->setDisplay($display_id)) {
             return t('Invalid display id @display', array('@display' => $display_id));
         }
         $this->executable->setArguments($args);
         // Store the current view URL for later use:
         if ($this->executable->display_handler->getOption('path')) {
             $path = $this->executable->getUrl();
         }
         // Make view links come back to preview.
         $this->override_path = 'admin/structure/views/view/' . $this->id() . '/preview/' . $display_id;
         // Also override the current path so we get the pager.
         $original_path = current_path();
         $q = _current_path($this->override_path);
         if ($args) {
             $q .= '/' . implode('/', $args);
             _current_path($q);
         }
         // Suppress contextual links of entities within the result set during a
         // Preview.
         // @todo We'll want to add contextual links specific to editing the View, so
         //   the suppression may need to be moved deeper into the Preview pipeline.
         views_ui_contextual_links_suppress_push();
         $show_additional_queries = $config->get('ui.show.additional_queries');
         Timer::start('entity.view.preview_form');
         if ($show_additional_queries) {
             $this->startQueryCapture();
         }
         // Execute/get the view preview.
         $preview = $this->executable->preview($display_id, $args);
         $preview = drupal_render($preview);
         if ($show_additional_queries) {
             $this->endQueryCapture();
         }
         $this->render_time = Timer::stop('entity.view.preview_form');
         views_ui_contextual_links_suppress_pop();
         // Reset variables.
         unset($this->override_path);
         _current_path($original_path);
         // Prepare the query information and statistics to show either above or
         // below the view preview.
         if ($show_info || $show_query || $show_stats) {
             // Get information from the preview for display.
             if (!empty($this->executable->build_info['query'])) {
                 if ($show_query) {
                     $query_string = $this->executable->build_info['query'];
                     // Only the sql default class has a method getArguments.
                     $quoted = array();
                     if ($this->executable->query instanceof Sql) {
                         $quoted = $query_string->getArguments();
                         $connection = Database::getConnection();
                         foreach ($quoted as $key => $val) {
                             if (is_array($val)) {
                                 $quoted[$key] = implode(', ', array_map(array($connection, 'quote'), $val));
                             } else {
                                 $quoted[$key] = $connection->quote($val);
                             }
                         }
                     }
                     $rows['query'][] = array(array('data' => array('#type' => 'inline_template', '#template' => "<strong>{% trans 'Query' %}</strong>")), array('data' => array('#type' => 'inline_template', '#template' => '<pre>{{ query }}</pre>', '#context' => array('query' => strtr($query_string, $quoted)))));
                     if (!empty($this->additionalQueries)) {
                         $queries = '<strong>' . t('These queries were run during view rendering:') . '</strong>';
                         foreach ($this->additionalQueries as $query) {
                             if ($queries) {
                                 $queries .= "\n";
                             }
                             $query_string = strtr($query['query'], $query['args']);
                             $queries .= t('[@time ms] @query', array('@time' => round($query['time'] * 100000, 1) / 100000.0, '@query' => $query_string));
//.........这里部分代码省略.........
开发者ID:anyforsoft,项目名称:csua_d8,代码行数:101,代码来源:ViewUI.php

示例3: attachTo

 /**
  * Attach to another view.
  */
 public function attachTo(ViewExecutable $view, $display_id)
 {
     $displays = $this->getOption('displays');
     if (empty($displays[$display_id])) {
         return;
     }
     if (!$this->access()) {
         return;
     }
     $args = $this->getOption('inherit_arguments') ? $this->view->args : array();
     $view->setArguments($args);
     $view->setDisplay($this->display['id']);
     if ($this->getOption('inherit_pager')) {
         $view->display_handler->usesPager = $this->view->displayHandlers->get($display_id)->usesPager();
         $view->display_handler->setOption('pager', $this->view->displayHandlers->get($display_id)->getOption('pager'));
     }
     $attachment = $view->executeDisplay($this->display['id'], $args);
     switch ($this->getOption('attachment_position')) {
         case 'before':
             $this->view->attachment_before[] = $attachment;
             break;
         case 'after':
             $this->view->attachment_after[] = $attachment;
             break;
         case 'both':
             $this->view->attachment_before[] = $attachment;
             $this->view->attachment_after[] = $attachment;
             break;
     }
 }
开发者ID:anatalsceo,项目名称:en-classe,代码行数:33,代码来源:Attachment.php

示例4: attachTo

 /**
  * {@inheritdoc}
  */
 public function attachTo(ViewExecutable $clone, $display_id, array &$build)
 {
     $displays = $this->getOption('displays');
     if (empty($displays[$display_id])) {
         return;
     }
     // Defer to the feed style; it may put in meta information, and/or
     // attach a feed icon.
     $clone->setArguments($this->view->args);
     $clone->setDisplay($this->display['id']);
     $clone->buildTitle();
     if ($plugin = $clone->display_handler->getPlugin('style')) {
         $plugin->attachTo($build, $display_id, $clone->getUrl(), $clone->getTitle());
         foreach ($clone->feedIcons as $feed_icon) {
             $this->view->feedIcons[] = $feed_icon;
         }
     }
     // Clean up.
     $clone->destroy();
     unset($clone);
 }
开发者ID:ddrozdik,项目名称:dmaps,代码行数:24,代码来源:Feed.php


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