ViewsDiscovery.php 1.22 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php

/**
 * @file
 * Definition of Drupal\views\Plugin\Discovery\ViewsDiscovery.
 */

namespace Drupal\views\Plugins\Discovery;
use Drupal\Core\Plugin\Discovery\HookDiscovery;

/**
 * Discovery interface which supports the hook_views_plugins mechanism.
 */
class ViewsDiscovery extends HookDiscovery {
  /**
   * The plugin type in views which should be discovered, for example query.
   *
   * @var string
   */
  protected $viewsPluginType;

  /**
   * Constructs a Drupal\views\Plugin\Discovery\ViewsDiscovery object.
   *
   * @param string $hook
   *   The Drupal hook that a module can implement in order to interface to
   *   this discovery class.
   * @param string $plugin_type
   *   The plugin type in views which should be discovered, for example query.
   */
  function __construct($hook, $plugin_type) {
    $this->viewsPluginType = $plugin_type;
    parent::__construct($hook);
  }

  /**
   * Implements Drupal\Component\Plugin\Discovery\DicoveryInterface::getDefinitions().
   */
  public function getDefinitions() {
dawehner's avatar
dawehner committed
40
41
42
43
44
    views_include('plugins');
    views_include_handlers();

    $definitions = module_invoke_all($this->hook);
    drupal_alter($this->hook, $definitions);
45
46
47
    return $definitions[$this->viewsPluginType];
  }
}