ViewsExposedFilterBlock.php in Zircon Profile 8.0
File
core/modules/views/src/Plugin/Derivative/ViewsExposedFilterBlock.php
View source
<?php
namespace Drupal\views\Plugin\Derivative;
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class ViewsExposedFilterBlock implements ContainerDeriverInterface {
protected $derivatives = array();
protected $viewStorage;
protected $basePluginId;
public function __construct($base_plugin_id, EntityStorageInterface $view_storage) {
$this->basePluginId = $base_plugin_id;
$this->viewStorage = $view_storage;
}
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($base_plugin_id, $container
->get('entity.manager')
->getStorage('view'));
}
public function getDerivativeDefinition($derivative_id, $base_plugin_definition) {
if (!empty($this->derivatives) && !empty($this->derivatives[$derivative_id])) {
return $this->derivatives[$derivative_id];
}
$this
->getDerivativeDefinitions($base_plugin_definition);
return $this->derivatives[$derivative_id];
}
public function getDerivativeDefinitions($base_plugin_definition) {
foreach ($this->viewStorage
->loadMultiple() as $view) {
if (!$view
->status()) {
continue;
}
$executable = $view
->getExecutable();
$executable
->initDisplay();
foreach ($executable->displayHandlers as $display) {
if (isset($display) && $display
->getOption('exposed_block')) {
if ($display
->usesExposedFormInBlock()) {
$delta = $view
->id() . '-' . $display->display['id'];
$desc = t('Exposed form: @view-@display_id', array(
'@view' => $view
->id(),
'@display_id' => $display->display['id'],
));
$this->derivatives[$delta] = array(
'admin_label' => $desc,
'config_dependencies' => array(
'config' => array(
$view
->getConfigDependencyName(),
),
),
);
$this->derivatives[$delta] += $base_plugin_definition;
}
}
}
}
return $this->derivatives;
}
}