You are here

class SitePathFactory in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/SitePathFactory.php \Drupal\Core\SitePathFactory

Gets the site path from the kernel.

Hierarchy

Expanded class hierarchy of SitePathFactory

1 string reference to 'SitePathFactory'
core.services.yml in core/core.services.yml
core/core.services.yml
1 service uses SitePathFactory
site.path.factory in core/core.services.yml
Drupal\Core\SitePathFactory

File

core/lib/Drupal/Core/SitePathFactory.php, line 8

Namespace

Drupal\Core
View source
class SitePathFactory {

  /**
   * The Drupal kernel.
   *
   * @var \Drupal\Core\DrupalKernelInterface
   */
  protected $drupalKernel;

  /**
   * Constructs a SitePathFactory instance.
   *
   * @param \Drupal\Core\DrupalKernelInterface $drupal_kernel
   *   The Drupal kernel.
   */
  public function __construct(DrupalKernelInterface $drupal_kernel) {
    $this->drupalKernel = $drupal_kernel;
  }

  /**
   * Gets the site path.
   *
   * @return string
   *   The site path.
   */
  public function get() {
    return $this->drupalKernel
      ->getContainer()
      ->getParameter('site.path');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SitePathFactory::$drupalKernel protected property The Drupal kernel.
SitePathFactory::get public function Gets the site path.
SitePathFactory::__construct public function Constructs a SitePathFactory instance.