AppRootFactory.php 621 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace Drupal\Core;
  3. /**
  4. * Gets the app root from the kernel.
  5. */
  6. class AppRootFactory {
  7. /**
  8. * The Drupal kernel.
  9. *
  10. * @var \Drupal\Core\DrupalKernelInterface
  11. */
  12. protected $drupalKernel;
  13. /**
  14. * Constructs an AppRootFactory instance.
  15. *
  16. * @param \Drupal\Core\DrupalKernelInterface $drupal_kernel
  17. * The Drupal kernel.
  18. */
  19. public function __construct(DrupalKernelInterface $drupal_kernel) {
  20. $this->drupalKernel = $drupal_kernel;
  21. }
  22. /**
  23. * Gets the app root.
  24. *
  25. * @return string
  26. */
  27. public function get() {
  28. return $this->drupalKernel->getAppRoot();
  29. }
  30. }