Version 1
[yaffs-website] / web / core / lib / Drupal / Core / SitePathFactory.php
diff --git a/web/core/lib/Drupal/Core/SitePathFactory.php b/web/core/lib/Drupal/Core/SitePathFactory.php
new file mode 100644 (file)
index 0000000..7a01ff1
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+
+namespace Drupal\Core;
+
+/**
+ * Gets the site path from the kernel.
+ */
+class SitePathFactory {
+
+  /**
+   * The Drupal kernel.
+   *
+   * @var \Drupal\Core\DrupalKernelInterface
+   */
+  protected $drupalKernel;
+
+  /**
+   * Constructs an 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->getSitePath();
+  }
+
+}