AppRootFactory.php

Same filename and directory in other branches
  1. 8.9.x core/lib/Drupal/Core/AppRootFactory.php

Namespace

Drupal\Core

File

core/lib/Drupal/Core/AppRootFactory.php

View source
<?php

namespace Drupal\Core;


/**
 * Gets the app root from the kernel.
 */
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');
    }

}

Classes

Title Deprecated Summary
AppRootFactory Gets the app root from the kernel.

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