setOptionDefaults example

$display_extender_options = $display['display_options']['display_extenders'];
      foreach ($extenders as $extender) {
        /** @var \Drupal\views\Plugin\views\display_extender\DisplayExtenderPluginBase $plugin */
        if ($plugin = $manager->createInstance($extender)) {
          $extender_options = isset($display_extender_options[$plugin->getPluginId()]) ? $display_extender_options[$plugin->getPluginId()] : [];
          $plugin->init($this->view, $this$extender_options);
          $this->extenders[$extender] = $plugin;
        }
      }
    }

    $this->setOptionDefaults($this->options, $this->defineOptions());
    $this->display = &$display;

    // Track changes that the user should know about.     $changed = FALSE;

    if (!isset($options) && isset($display['display_options'])) {
      $options = $display['display_options'];
    }

    if ($this->isDefaultDisplay() && isset($options['defaults'])) {
      unset($options['defaults']);
    }

  protected $definedOptions = [];

  /** * Calls the protected method setOptionDefaults(). * * @see \Drupal\views\Plugin\views\PluginBase::setOptionDefaults() */
  public function testSetOptionDefaults(&$storage$options$level = 0) {
    $this->setOptionDefaults($storage$options);
  }

  /** * Allows to set the defined options. * * @param array $options * The options to set. * * @return $this */
  public function setDefinedOptions($options) {
    

  public static function create(ContainerInterface $container, array $configuration$plugin_id$plugin_definition) {
    return new static($configuration$plugin_id$plugin_definition);
  }

  /** * {@inheritdoc} */
  public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
    $this->view = $view;
    $this->options = $this->options ?? [];
    $this->setOptionDefaults($this->options, $this->defineOptions());
    $this->displayHandler = $display;

    $this->unpackOptions($this->options, $options);
  }

  /** * Information about options for all kinds of purposes will be held here. * @code * 'option_name' => array( * - 'default' => default value, * - 'contains' => (optional) array of items this contains, with its own * defaults, etc. If contains is set, the default will be ignored and * assumed to be array(). * ), * @endcode * * @return array * Returns the options of this handler/plugin. */
Home | Imprint | This part of the site doesn't use cookies.