initializePlugin example

return isset($this->pluginInstances[$instance_id]) || isset($this->instanceIds[$instance_id]);
  }

  /** * Gets a plugin instance, initializing it if necessary. * * @param string $instance_id * The ID of the plugin instance being retrieved. */
  public function Dget($instance_id) {
    if (!isset($this->pluginInstances[$instance_id])) {
      $this->initializePlugin($instance_id);
    }
    return $this->pluginInstances[$instance_id];
  }

  /** * Stores an initialized plugin. * * @param string $instance_id * The ID of the plugin instance being stored. * @param mixed $value * An instantiated plugin. */

  public function Dget($instance_id) {
    return parent::get($instance_id);
  }

  /** * {@inheritdoc} */
  protected function initializePlugin($instance_id) {
    parent::initializePlugin($instance_id);

    $plugin_instance = $this->pluginInstances[$instance_id];
    if ($plugin_instance instanceof ConfigurableSearchPluginInterface) {
      $plugin_instance->setSearchPageId($this->searchPageId);
    }
  }

}


  /** * {@inheritdoc} */
  protected function initializePlugin($instance_id) {
    if (!$instance_id) {
      throw new PluginException("The block '{$this->blockId}' did not specify a plugin.");
    }

    try {
      parent::initializePlugin($instance_id);
    }
    catch (PluginException $e) {
      $module = $this->configuration['provider'];
      // Ignore blocks belonging to uninstalled modules, but re-throw valid       // exceptions when the module is installed and the plugin is       // misconfigured.       if (!$module || \Drupal::moduleHandler()->moduleExists($module)) {
        throw $e;
      }
    }
  }

}
$this->definitions = $this->manager->getDefinitions();
      // Do not allow the null filter to be used directly, only as a fallback.       unset($this->definitions['filter_null']);
    }

    // Ensure that there is an instance of all available filters.     // Note that getDefinitions() are keyed by $plugin_id. $instance_id is the     // $plugin_id for filters, since a single filter plugin can only exist once     // in a format.     foreach ($this->definitions as $plugin_id => $definition) {
      if (!isset($this->pluginInstances[$plugin_id])) {
        $this->initializePlugin($plugin_id);
      }
    }
    return $this->pluginInstances;
  }

  /** * {@inheritdoc} */
  protected function initializePlugin($instance_id) {
    // Filters have a 1:1 relationship to text formats and can be added and     // instantiated at any time.

  public function __construct(ViewExecutable $view, PluginManagerInterface $manager) {
    parent::__construct($manager$view->storage->get('display'));

    $this->view = $view;
    $this->initializePlugin('default');
  }

  /** * Destructs a DisplayPluginCollection object. */
  public function __destruct() {
    $this->clear();
  }

  /** * {@inheritdoc} * * @return \Drupal\views\Plugin\views\display\DisplayPluginBase */
Home | Imprint | This part of the site doesn't use cookies.