Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.10.x will end 8 November 2021 (12 months).
  • Bug fixes for security issues in 3.10.x will end 9 May 2022 (18 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.

Differences Between: [Versions 310 and 311] [Versions 310 and 400] [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]

(no description)

File Size: 196 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