class SitePathFactory

Same name in other branches
  1. 8.9.x 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

Title Sort descending Modifiers Object type Summary
SitePathFactory::$drupalKernel protected property The Drupal kernel.
SitePathFactory::get public function Gets the site path.
SitePathFactory::__construct public function Constructs a SitePathFactory instance.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.