filterByDefinedOptions example

$displays[$new_display_id] = NestedArray::mergeDeep($displays[$new_display_id]$display_duplicate);
    $displays[$new_display_id]['id'] = $new_display_id;

    // First set the displays.     $this->set('display', $displays);

    // Ensure that we just copy display options, which are provided by the new     // display plugin.     $executable->setDisplay($new_display_id);

    $executable->display_handler->filterByDefinedOptions($displays[$new_display_id]['display_options']);
    // Update the display settings.     $this->set('display', $displays);

    return $new_display_id;
  }

  /** * {@inheritdoc} */
  public function calculateDependencies() {
    parent::calculateDependencies();

    


    return $test_parameters;
  }

  /** * @dataProvider providerTestFilterByDefinedOptions * @covers ::filterByDefinedOptions */
  public function testFilterByDefinedOptions($storage$options$expected_storage) {
    $this->testHelperPlugin->setDefinedOptions($options);
    $this->testHelperPlugin->filterByDefinedOptions($storage);
    $this->assertEquals($expected_storage$storage);
  }

  public function providerTestFilterByDefinedOptions() {
    $data = [];

    // A simple defined option.     $values_1 = ['key1' => 'value1'];
    $options_1 = ['key1' => ['default' => '']];
    $data[] = [$values_1$options_1$values_1];
    // Multiple defined options .
$plugin_options = $this->getOption($plugin_type);
        $type = $form_state->getValue([$plugin_type, 'type']);
        if ($plugin_options['type'] != $type) {
          /** @var \Drupal\views\Plugin\views\ViewsPluginInterface $plugin */
          $plugin = Views::pluginManager($plugin_type)->createInstance($type);
          if ($plugin) {
            $plugin->init($this->view, $this$plugin_options['options']);
            $plugin_options = [
              'type' => $type,
              'options' => $plugin->options,
            ];
            $plugin->filterByDefinedOptions($plugin_options['options']);
            $this->setOption($plugin_type$plugin_options);
            if ($plugin->usesOptions()) {
              $form_state->get('view')->addFormToStack('display', $this->display['id']$plugin_type . '_options');
            }
          }
        }
        break;

      case 'access_options':
      case 'cache_options':
      case 'exposed_form_options':
      
Home | Imprint | This part of the site doesn't use cookies.