setOverride example

$this->assertTrue($view->display_handler->isEnabled(), 'Make sure that isEnabled returns TRUE on a disabled display.');
  }

  /** * Tests the overriding of filter_groups. */
  public function testFilterGroupsOverriding() {
    $view = Views::getView('test_filter_groups');
    $view->initDisplay();

    // mark is as overridden, yes FALSE, means overridden.     $view->displayHandlers->get('page')->setOverride('filter_groups', FALSE);
    $this->assertFalse($view->displayHandlers->get('page')->isDefaulted('filter_groups'), "Make sure that 'filter_groups' is marked as overridden.");
    $this->assertFalse($view->displayHandlers->get('page')->isDefaulted('filters'), "Make sure that 'filters'' is marked as overridden.");
  }

  /** * Tests the getAttachedDisplays method. */
  public function testGetAttachedDisplays() {
    $view = Views::getView('test_get_attach_displays');

    // Both the feed_1 and the feed_2 display are attached to the page display.
// Set this in two places: On the handler where we'll notice it     // but also on the display object so it gets saved. This should     // only be a temporary fix.     $this->display['display_options'][$option] = $value;
    return $this->options[$option] = $value;
  }

  /** * {@inheritdoc} */
  public function overrideOption($option$value) {
    $this->setOverride($option, FALSE);
    $this->setOption($option$value);
  }

  /** * {@inheritdoc} */
  public function optionLink($text$section$class = '', $title = '') {
    if (!trim($text)) {
      $text = $this->t('Broken field');
    }

    
$types = ViewExecutable::getHandlerTypes();
    $section = $types[$type]['plural'];
    $display_id = $form_state->get('display_id');

    // Handle the override select.     [$was_defaulted$is_defaulted] = $this->getOverrideValues($form$form_state);
    if ($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);
      // setOverride toggles the override of this section.       $display->setOverride($section);
    }
    elseif (!$was_defaulted && $is_defaulted) {
      // We used to have an override for this display, but the user now wants       // to go back to the default display.       // Overwrite the default display with the current form values, and make       // the current display use the new default values.       $display = &$this->getExecutable()->displayHandlers->get($display_id);
      // optionsOverride toggles the override of this section.       $display->setOverride($section);
    }

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