summaryrefslogtreecommitdiffstatshomepage
path: root/core/tests/Drupal/Tests/ExtensionListTestTrait.php
blob: 04f88bf2610e3de935316973e4c998eaaf0476f2 (plain) (blame)
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
40
41
42
43
44
<?php

declare(strict_types=1);

namespace Drupal\Tests;

/**
 * Provides extension list methods.
 */
trait ExtensionListTestTrait {

  /**
   * Gets the path for the specified module.
   *
   * @param string $module_name
   *   The module name.
   *
   * @return string
   *   The Drupal-root relative path to the module directory.
   *
   * @throws \Drupal\Core\Extension\Exception\UnknownExtensionException
   *   If the module does not exist.
   */
  protected function getModulePath(string $module_name): string {
    return \Drupal::service('extension.list.module')->getPath($module_name);
  }

  /**
   * Gets the path for the specified theme.
   *
   * @param string $theme_name
   *   The theme name.
   *
   * @return string
   *   The Drupal-root relative path to the theme directory.
   *
   * @throws \Drupal\Core\Extension\Exception\UnknownExtensionException
   *   If the theme does not exist.
   */
  protected function getThemePath(string $theme_name): string {
    return \Drupal::service('extension.list.theme')->getPath($theme_name);
  }

}