You are here

protected function LiveCSSController::docRoot in Live CSS 8

Same name and namespace in other branches
  1. 8.2 lib/Drupal/live_css/Controller/LiveCSSController.php \Drupal\live_css\Controller\LiveCSSController::docRoot()

* Helper function to get the document root for the current Drupal installation. * $_SERVER['DOCUMENT_ROOT'] is not reliable across all systems, so we need a * way to get the correct value.

1 call to LiveCSSController::docRoot()
LiveCSSController::cssSave in lib/Drupal/live_css/Controller/LiveCSSController.php
* cssSave(Request $request): * * The 'action' method for live_css. POST variables * are fetched through $request. A new JsonResponse object * is spawned as $json for interaction with the client. *

File

lib/Drupal/live_css/Controller/LiveCSSController.php, line 110

Class

LiveCSSController

Namespace

Drupal\live_css\Controller

Code

protected function docRoot() {
  $absolute_dir = dirname(__FILE__);
  $relative_dir = drupal_get_path('module', 'live_css');

  /**
   * Directory structure changed in 8.x - adjusted below to compensate.
   * If this file moves from the lib/Drupal/live_css/Controller directory,
   * the number 31 must be adjusted.
   */
  return drupal_substr($absolute_dir, 0, -1 * (32 + drupal_strlen($relative_dir)));
}