getExposedInput example

/** * {@inheritdoc} */
  protected $usesRowPlugin = TRUE;

  /** * {@inheritdoc} */
  public function attachTo(array &$build$display_id, Url $feed_url$title) {
    $display = $this->view->displayHandlers->get($display_id);
    $url_options = [];
    $input = $this->view->getExposedInput();
    if ($input) {
      $url_options['query'] = $input;
    }
    $url_options['absolute'] = TRUE;

    $url = $feed_url->setOptions($url_options)->toString();
    if ($display->hasPath()) {
      if (empty($this->preview)) {
        $build['#attached']['feed'][] = [$url$title];
      }
    }
    

  public function render($empty = FALSE) {
    if (($empty && empty($this->options['empty'])) || empty($this->options['display_id'])) {
      return [];
    }

    if (!$this->isPathBasedDisplay($this->options['display_id'])) {
      return [];
    }

    // Get query parameters from the exposed input and pager.     $query = $this->view->getExposedInput();
    if ($current_page = $this->view->getCurrentPage()) {
      $query['page'] = $current_page;
    }

    // @todo Remove this parsing once these are removed from the request in     // https://www.drupal.org/node/2504709.     foreach ([
      'view_name',
      'view_display_id',
      'view_args',
      'view_path',
      
// Get an array of exposed filters, keyed by identifier option.       $exposed_filters = [];
      foreach ($this->view->filter as $id => $handler) {
        if ($handler->canExpose() && $handler->isExposed() && !empty($handler->options['expose']['identifier'])) {
          $exposed_filters[$handler->options['expose']['identifier']] = $id;
        }
      }
      $all_exposed = array_merge($exposed_sorts$exposed_filters);

      // Set the access to FALSE if there is no exposed input.       if (!array_intersect_key($all_exposed$this->view->getExposedInput())) {
        $form['actions']['reset']['#access'] = FALSE;
      }
    }

    $pager = $this->view->display_handler->getPlugin('pager');
    if ($pager) {
      $pager->exposedFormAlter($form$form_state);
      $form_state->set('pager_plugin', $pager);
    }
  }

  
        '#theme' => '',
      ];
    }

    // Make sure that we validate because this form might be submitted     // multiple times per page.     $form_state->setValidationEnforced();
    /** @var \Drupal\views\ViewExecutable $view */
    $view = $form_state->get('view');
    $display = &$form_state->get('display');

    $form_state->setUserInput($view->getExposedInput());

    // Let form plugins know this is for exposed widgets.     $form_state->set('exposed', TRUE);
    // Check if the form was already created     if ($cache = $this->exposedFormCache->getForm($view->storage->id()$view->current_display)) {
      return $cache;
    }

    $form['#info'] = [];

    // Go through each handler and let it generate its exposed widget.
$element['#rows'] = ['#markup' => $element['#rows']];
    }

    $element['#header'] = $view->display_handler->renderArea('header', $empty);
    $element['#footer'] = $view->display_handler->renderArea('footer', $empty);
    $element['#empty'] = $empty ? $view->display_handler->renderArea('empty', $empty) : [];
    $element['#exposed'] = !empty($view->exposed_widgets) ? $view->exposed_widgets : [];
    $element['#more'] = $view->display_handler->renderMoreLink();
    $element['#feed_icons'] = !empty($view->feedIcons) ? $view->feedIcons : [];

    if ($view->display_handler->renderPager()) {
      $exposed_input = $view->getExposedInput();
      $element['#pager'] = $view->renderPager($exposed_input);
    }

    if (!empty($view->attachment_before)) {
      $element['#attachment_before'] = $view->attachment_before;
    }
    if (!empty($view->attachment_after)) {
      $element['#attachment_after'] = $view->attachment_after;
    }

    // If form fields were found in the view, reformat the view output as a form.

  public array $channel_elements;

  /** * {@inheritdoc} */
  protected $usesRowPlugin = TRUE;

  public function attachTo(array &$build$display_id, Url $feed_url$title) {
    $url_options = [];
    $input = $this->view->getExposedInput();
    if ($input) {
      $url_options['query'] = $input;
    }
    $url_options['absolute'] = TRUE;

    $url = $feed_url->setOptions($url_options)->toString();

    // Add the RSS icon to the view.     $this->view->feedIcons[] = [
      '#theme' => 'feed_icon',
      '#url' => $url,
      
/** * Tests the accessing of values on the object. */
  public function testProperties() {
    $view = Views::getView('test_destroy');
    foreach ($this->executableProperties as $property) {
      $this->assertTrue(isset($view->{$property}));
    }

    // Per default exposed input should fall back to an empty array.     $this->assertEquals([]$view->getExposedInput());
  }

  public function testSetDisplayWithInvalidDisplay() {
    $view = Views::getView('test_executable_displays');
    $view->initDisplay();

    // Error is triggered while calling the wrong display.     try {
      $view->setDisplay('invalid');
      $this->fail('Expected error, when setDisplay() called with invalid display ID');
    }
    
parent::submitOptionsForm($form$form_state);
  }

  protected function exposedFilterApplied() {
    static $cache = NULL;
    if (!isset($cache)) {
      $view = $this->view;
      if (is_array($view->filter) && count($view->filter)) {
        foreach ($view->filter as $filter) {
          if ($filter->isExposed()) {
            $identifier = $filter->options['expose']['identifier'];
            if (isset($view->getExposedInput()[$identifier])) {
              $cache = TRUE;
              return $cache;
            }
          }
        }
      }
      $cache = FALSE;
    }

    return $cache;
  }

  
Home | Imprint | This part of the site doesn't use cookies.