class AppRootFactory

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/AppRootFactory.php \Drupal\Core\AppRootFactory

Gets the app root from the kernel.

Hierarchy

Expanded class hierarchy of AppRootFactory

1 string reference to 'AppRootFactory'
core.services.yml in core/core.services.yml
core/core.services.yml
1 service uses AppRootFactory
app.root.factory in core/core.services.yml
Drupal\Core\AppRootFactory

File

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

Namespace

Drupal\Core
View source
class AppRootFactory {
    
    /**
     * The Drupal kernel.
     *
     * @var \Drupal\Core\DrupalKernelInterface
     */
    protected $drupalKernel;
    
    /**
     * Constructs an AppRootFactory instance.
     *
     * @param \Drupal\Core\DrupalKernelInterface $drupal_kernel
     *   The Drupal kernel.
     */
    public function __construct(DrupalKernelInterface $drupal_kernel) {
        $this->drupalKernel = $drupal_kernel;
    }
    
    /**
     * Gets the app root.
     *
     * @return string
     *   The app root.
     */
    public function get() {
        return $this->drupalKernel
            ->getContainer()
            ->getParameter('app.root');
    }

}

Members

Title Sort descending Modifiers Object type Summary
AppRootFactory::$drupalKernel protected property The Drupal kernel.
AppRootFactory::get public function Gets the app root.
AppRootFactory::__construct public function Constructs an AppRootFactory instance.

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