You are here

protected function AssetInjectorBase::filePathRelativeToDrupalRoot in Asset Injector 8

Same name and namespace in other branches
  1. 8.2 src/Entity/AssetInjectorBase.php \Drupal\asset_injector\Entity\AssetInjectorBase::filePathRelativeToDrupalRoot()

Get file path relative to drupal root to use in library info.

Return value

string File path relative to drupal root, with leading slash.

2 calls to AssetInjectorBase::filePathRelativeToDrupalRoot()
CssInjector::libraryInfo in src/Entity/CssInjector.php
Gets the library array used in library_info_build.
JsInjector::libraryInfo in src/Entity/JsInjector.php
Gets the library array used in library_info_build.

File

src/Entity/AssetInjectorBase.php, line 143

Class

AssetInjectorBase
Class AssetInjectorBase: Base asset injector class.

Namespace

Drupal\asset_injector\Entity

Code

protected function filePathRelativeToDrupalRoot() {

  // @todo See if we can simplify this via file_url_transform_relative().
  $path = parse_url(file_create_url($this
    ->internalFileUri()), PHP_URL_PATH);
  $path = str_replace(base_path(), '/', $path);
  return $path;
}