DisplayPluginManager.php in Search API 8
File
src/Display/DisplayPluginManager.php
View source
<?php
namespace Drupal\search_api\Display;
use Drupal\Core\Cache\CacheBackendInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\search_api\Event\SearchApiEvents;
use Drupal\search_api\SearchApiPluginManager;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
class DisplayPluginManager extends SearchApiPluginManager implements DisplayPluginManagerInterface {
protected $displays = NULL;
public function __construct(\Traversable $namespaces, CacheBackendInterface $cache_backend, ModuleHandlerInterface $module_handler, EventDispatcherInterface $eventDispatcher) {
parent::__construct('Plugin/search_api/display', $namespaces, $module_handler, $eventDispatcher, 'Drupal\\search_api\\Display\\DisplayInterface', 'Drupal\\search_api\\Annotation\\SearchApiDisplay');
$this
->setCacheBackend($cache_backend, 'search_api_displays');
$this
->alterInfo('search_api_displays');
$this
->alterEvent(SearchApiEvents::GATHERING_DISPLAYS);
}
public function getInstances() {
if ($this->displays === NULL) {
$this->displays = [];
foreach ($this
->getDefinitions() as $name => $display_definition) {
if (class_exists($display_definition['class']) && empty($this->displays[$name])) {
$display = $this
->createInstance($name);
$this->displays[$name] = $display;
}
}
}
return $this->displays;
}
public function clearCachedDefinitions() {
parent::clearCachedDefinitions();
$this->discovery = NULL;
}
}