Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

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

(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.

return: string
param: string $path

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

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

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

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

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

return: string
param: string $path