Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 39 and 401]

(no description)

File Size: 204 lines (6 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Converter:: (5 methods):
  __construct()
  normalize()
  shared()
  convert()
  dirname()


Class: Converter  - X-Ref

Convert paths relative from 1 file to another.

E.g.
../../images/icon.jpg relative to /css/imports/icons.css
becomes
../images/icon.jpg relative to /css/minified.css

Please report bugs on https://github.com/matthiasmullie/path-converter/issues

__construct($from, $to, $root = '')   X-Ref

param: string $from The original base path (directory, not file!)
param: string $to   The new base path (directory, not file!)
param: string $root Root directory (defaults to `getcwd`)

normalize($path)   X-Ref
Normalize path.

param: string $path
return: string

shared($path1, $path2)   X-Ref
Figure out the shared path of 2 locations.

Example:
/home/forkcms/frontend/core/layout/images/img.gif
and
/home/forkcms/frontend/cache/minified_css
share
/home/forkcms/frontend

param: string $path1
param: string $path2
return: string

convert($path)   X-Ref
Convert paths relative from 1 file to another.

E.g.
../images/img.gif relative to /home/forkcms/frontend/core/layout/css
should become:
../../core/layout/images/img.gif relative to
/home/forkcms/frontend/cache/minified_css

param: string $path The relative path that needs to be converted
return: string The new relative path

dirname($path)   X-Ref
Attempt to get the directory name from a path.

param: string $path
return: string