You are here

protected function AssetInjectorBase::filePathRelativeToDrupalRoot in Asset Injector 8.2

Same name and namespace in other branches
  1. 8 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()
AssetInjectorCss::libraryInfo in src/Entity/AssetInjectorCss.php
Gets the library array used in library_info_build.
AssetInjectorJs::libraryInfo in src/Entity/AssetInjectorJs.php
Gets the library array used in library_info_build.

File

src/Entity/AssetInjectorBase.php, line 107

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;
}