xplo.re Medusa Core Framework 3.2
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Event
  • Todo
  • Download

Namespaces

  • Core
    • Authentication
      • Auto
        • Driver
      • Driver
    • Cache
      • Driver
    • Charset
      • Driver
    • Configuration
      • Driver
    • Controller
    • Converter
      • Driver
    • Decoder
      • Driver
    • Encoder
      • Driver
    • Env
      • Authentication
      • Locale
      • Proxy
      • Server
        • HTTP
        • Redirect
        • X
    • Exception
    • Exchange
      • Driver
    • Fault
      • Formatter
        • Driver
      • Incident
        • Exception
      • Reporter
        • Driver
    • Field
    • Filter
      • Driver
    • Formatter
      • Driver
        • coreuimarkup
          • Token
    • Hash
    • Loader
    • Locale
    • Log
      • Driver
    • Module
      • Dependency
        • Requirement
          • Core
          • PHP
      • Linkage
        • Driver
    • PDF
    • Plugin
    • Query
      • Driver
    • Server
      • Driver
    • Session
      • Driver
    • Set
    • Storage
      • Driver
      • Field
        • Element
    • Stream
      • Driver
    • String
    • Translation
      • Driver
      • Language
        • Driver
    • Type
    • URI
      • Driver
    • Version
    • View
      • Driver
        • coreui
          • Control
            • Button
            • Table
          • Element
        • htmlbuilder
          • Tags
        • yui
          • Modules
  • None
  • PHP

Classes

  • Authentication
  • Authentication_Token
  • AutoLoader
  • Cache
  • Charset
  • ClassDescriptor
  • Closure
  • Configuration
  • Controller
  • Converter
  • Date
  • Decoder
  • Delegate
  • Dispatcher
  • Encoder
  • Env
  • Env_Field
  • Env_File
  • Env_FileList
  • Env_Request
  • Env_SERVER
  • Exchange
  • Fault
  • Field
  • Filter
  • Filter_Value
  • Formatter
  • Hash
  • IP
  • Loader
  • Locale
  • Locale_Node
  • Log
  • Module
  • Module_Iterator
  • Nothing
  • Object
  • OS
  • Plugin
  • Profiler
  • Query
  • Registry
  • Resource
  • Server
  • Session
  • Session_Token
  • Set
  • Storage
  • Storage_Result
  • Storage_Statement
  • Stream
  • Translation
  • URI
  • URI_Parameters
  • UUID
  • Value
  • Version
  • View

Interfaces

  • Accessor
  • Chainable
  • Comparable
  • Configurable
  • Equality
  • Identity
  • Inquiry
  • Masquerade
  • Mutator
  • SeekableStream
  • Storable
  • Variator

Exceptions

  • Exception

Constants

  • Copyright
  • ProductName
  • Version

Class Loader

Module resolver and loader. Also used by the auto-loader. Keeps track of loaded modules and automatically records time and memory states for modules if enabled in Core configuration.

Namespace: Core
Package: Core
Since: 3.0
Requires: PHP 5.3
Version: 2.0
Located at Loader.inc.php

Methods summary

protected static
# _load( string $module, string $filename, Core\Profiler $profiler )

Internal actual module loader.

Internal actual module loader.

Parameters

$module
Name of module to load.
$filename

Filename of module to load. Automatically resolves the file against the PHP include path, unless an absolute filename is given.

$profiler

Profiler instance used to record time and memory states for the module. Set to null to disable profiler.

Throws

Core\Exception\Loader
Module file does not exist or an error occurred while loading the file.

Since

3.0
public static string
# classNameFromModule( $module )

Returns the default class name for a given module.

Returns the default class name for a given module.

The standard class name of a module is the class with the same namespace and base name as the requested module. Note, that the returned value does not implicate the existence of such a class.

Parameters

$module
of module to extract default class name from.

Returns

string
Standard class name for the module with full namespace hierarchy.

Since

3.1
public static string
# cleanupModuleName( $module )

Returns the unified module name from a given string.

Returns the unified module name from a given string.

Parameters

$module
name to return unified variant for.

Returns

string
Unified module name.

Since

3.1
public static string
# driverNameFromClassAndScheme( $class, $scheme )

Formats class name for driver factories.

Formats class name for driver factories.

Parameters

$class

of base class to render driver name for. Usually __CLASS__ is used for standard driver factories. Namespace prefix is mandatory.

$scheme

or Core\URI instance to derive driver class name from. If a Core\URI instance is given, the scheme is automatically extracted. If a provided Core\URI instance includes a scheme namespace, the primary namespace of the given class bane is replaced by the scheme namespace. This is useful to provide inter-library class hierarchies, e.g. applications usually placing views in their own namespace to avoid cluttering the Core namespace.

Returns

string

Class name including namespace information, Core\URI scheme and base class name.

Since

3.1
public static string
# encodeName( $string )

Returns a function, module and class name-safe variant of a string. All characters except alphanumeric characters and underscores are removed.

Returns a function, module and class name-safe variant of a string. All characters except alphanumeric characters and underscores are removed.

Parameters

$string
to return name-safe variant of.

Returns

string

Variant of source string that is safe to use as a file, module, class, function and variable name. If the resulting string is of empty, a single underscore is returned instead.

See

Core\Loader::encodeNameFS()

Since

3.1
public static string
# encodeNameFS( string $string )

Returns a filesystem-safe version of a given string. All characters which may not be handled correctly by some file system are replaced with an underscore.

Returns a filesystem-safe version of a given string. All characters which may not be handled correctly by some file system are replaced with an underscore.

No characters are truncated from the filename. The returned string has the same length as the original string.

Parameters

$string
String to return filesystem-safe variant of.

Returns

string

Variant of source string with all characters not being a Latin alphabet letter or number, minus sign, underscore or dot replaced by an underscore.

See

Core\Loader::encodeName()

Since

3.1
public static string[]
# getLoadedModules( )

Returns an array containing all loaded module names.

Returns an array containing all loaded module names.

Returns

string[]
Array of loaded module names.

Since

3.0
public static string
# getModuleFilename( $module )

Returns the filename for a given module identifier.

Returns the filename for a given module identifier.

Parameters

$module
name to retrieve filename (including extension) for.

Returns

string

Filename of given module. This method does not test, whether the filename can be resolved.

Since

3.0
public static array|false
# getModuleInfo( string $module )

Returns information set on a specified module.

Returns information set on a specified module.

Parameters

$module
Name of module to retrieve information for.

Returns

array|false

Associative array of module information of false if the named module is not loaded.

Since

3.0 \todo Prototype. Planned to include further module information.


public static
# getModuleInfoList( )

Returns an array of all loaded modules with their information sets.

Returns an array of all loaded modules with their information sets.

Since

3.0 \todo Prototype, probably obsolete.


public static string
# getModulePath( $module )

Returns the path for a given module or module resource identifier.

Returns the path for a given module or module resource identifier.

Parameters

$module
name to retrieve path for.

Returns

string

Path for given module name. This method does not test, whether the path can be resolved.

Since

3.2
public static string|false
# getModuleWithFilename( $filename )

Returns the name of a registered module based on the filename.

Returns the name of a registered module based on the filename.

Parameters

$filename
to search module for.

Returns

string|false
Name of module with given filename, otherwise false.

Since

3.1
public static string[]
# includePaths( string $includePath = null )

Returns an array of all configured include paths.

Returns an array of all configured include paths.

Parameters

$includePath

Include path definition to parse. If null, the standard PHP include path is used instead.

Returns

string[]
Array of configured include paths.

Since

3.2
public static boolean
# isAbsolutePath( $filename )

Tests, whether a given filename is considered absolute on the current platform.

Tests, whether a given filename is considered absolute on the current platform.

Parameters

$filename
to test for.

Returns

boolean

true, if the filename matches criteria for being absolute, otherwise false. This does not test, whether the file actually exists.

Since

3.2
public static boolean
# loadModule( $arg1 )

Loads a set of given module names.

Loads a set of given module names.

Parameters

$arg1

of modules to load. Multiple module name arguments are supported. Requires fully qualified module names (with full namespace hierarchy).

Returns

boolean
true on success, otherwise an exception is thrown.

Throws

Core\Exception\Loader

Either the module name does not contain the full namespace hierarchy, the module file does not exist or is not readable.

Event

Observers are notified after a module has been loaded.

See

Core\Loader::observeModuleLoaded()

Since

3.0
public static Core\Delegate
# observeModuleLoaded( $objectOrString, string $methodName = null )

Registers an observer for the Module.Loaded event.

Registers an observer for the Module.Loaded event.

Parameters

$objectOrString
Closure::add().
$methodName
See Closure::add().

Returns

Core\Delegate
Registered delegate.

Throws

Core\Exception\Delegate
Core\Exception\Loader

Since

3.1
public static
# registerModule( $version )

Registers module information for the currently loaded module. This is the first method a regular module should call:

Registers module information for the currently loaded module. This is the first method a regular module should call:

Loader::registerModule ('1.0-dev (revision)');

A call to this method is only valid for modules loaded via the Core module loader interface. Otherwise an exception is thrown.

Parameters

$version
version string or false, if no version information is available.

Throws

Core\Exception\Loader
Module registration called from outside the loader process.

Since

3.0
public static string
# resolveIncludePath( string $filename )

Resolves a filename against the include path.

Resolves a filename against the include path.

This method does not cache results itself but utilises file system functions that cache status information. See clearstatcache() for details. If available, the stream_resolve_include_path() PHP library function (PHP 5.3.2 or newer) is used, otherwise the include path is searched manually.

The method was previously known as the version manager function ns_resolve() in Medusa Core version 3.1 and older.

Parameters

$filename

Filename to resolve against the include path. If the filename is absolute and does exist, the canonicalised filename will be returned.

Returns

string

Resolved absolute filename or null, if the filename was not found in the include path because the file either does not exist or the script has insufficient access privileges.

Since

3.2
public static string[]
# resolveIncludePaths( string $filename, integer $limit = null )

Resolves a filename against the include path and returns all matches.

Resolves a filename against the include path and returns all matches.

This method does not cache results itself but utilises file system functions that cache status information. See clearstatcache() for details.

Parameters

$filename

Filename to resolve against the include path. If the filename is absolute and does exist, an array with only the canonicalised filename will be returned. If the filename is absolute and does not exist, an empty array is returned.

$limit

Optional maximum number of matches to return. Search will stop prematurely if limit is reached. If null or not provided, all matches will be returned.

Returns

string[]

Array of all matches found in order of their appearance in the include path. Only matches that exist and the script has access to are returned. If not match was found, an empty array is returned.

Since

3.2
public static string
# resolveModuleFilename( $module )

Resolves a module filename against the include path.

Resolves a module filename against the include path.

Parameters

$module
name to resolve filename for.

Returns

string

Resolved module filename on success, otherwise null if the module filename does not exist or cannot be accessed.

Since

3.2
public static string[]
# resolveModuleFilenames( $module )

Resolves a module filename against the include path and returns all matches.

Resolves a module filename against the include path and returns all matches.

Parameters

$module
name to resolve filename for.

Returns

string[]

Array of all matches found in order of their appearance in the include path. Only matches that exist and the script has access to are returned. If not match was found, an empty array is returned.

Since

3.2
public static string
# resolveModulePath( $module )

Resolves a module or module resource path against the include path.

Resolves a module or module resource path against the include path.

Parameters

$module
name to resolve path for.

Returns

string

Resolved module path on success, otherwise null if the module path does not exist or cannot be accessed.

Since

3.2
public static string[]
# resolveModulePaths( $module )

Resolves a module or module resource path against the include path and returns all matches.

Resolves a module or module resource path against the include path and returns all matches.

Parameters

$module
name to resolve paths for.

Returns

string[]

Array of all matches found in order of their appearance in the include path. Only matches that exist and the script has access to are returned. If not match was found, an empty array is returned.

Since

3.2
xplo.re Medusa Core Framework 3.2 API documentation generated by ApiGen