You are here

class AppRootFactory in Drupal 8

Same name and namespace in other branches
  1. 9 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
   */
  public function get() {
    return $this->drupalKernel
      ->getAppRoot();
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AppRootFactory::$drupalKernel protected property The Drupal kernel.
AppRootFactory::get public function Gets the app root.
AppRootFactory::__construct public function Constructs an AppRootFactory instance.