You are here

protected function GridStackPluginManagerBase::getImplementors in GridStack 8.2

Returns plugins names implementing a method.

1 call to GridStackPluginManagerBase::getImplementors()
GridStackPluginManagerBase::setAttachments in src/GridStackPluginManagerBase.php
Collects attachments from plugins.

File

src/GridStackPluginManagerBase.php, line 130

Class

GridStackPluginManagerBase
Implements GridStackPluginManagerInterface.

Namespace

Drupal\gridstack

Code

protected function getImplementors($method) {
  if (!isset($this->implementors[$method])) {
    $cid = static::$key . '_' . $method;
    if ($cache = $this->cacheBackend
      ->get($cid)) {
      $this->implementors[$method] = $cache->data;
    }
    else {
      $data = [];
      foreach ($this
        ->loadMultiple() as $plugin) {
        $class = $plugin
          ->get('class');
        $reflection = new \ReflectionClass($class);
        if ($reflection
          ->getMethod($method)->class == $class) {
          $data[$plugin
            ->getPluginId()] = $plugin
            ->getPluginId();
        }
      }
      ksort($data);
      $count = count($data);
      $tags = Cache::buildTags($cid, [
        'count:' . $count,
      ]);
      $this->cacheBackend
        ->set($cid, $data, Cache::PERMANENT, $tags);
      $this->implementors[$method] = $data;
    }
  }
  return $this->implementors[$method];
}