Class: atkClassLoader
Source Location: /utils/class.atkclassloader.inc
Class atkClassLoader
Method Summary
| static
cleaned-up
|
cleanPath() |
Clean-up the given path. |
| static
string
|
getClassName() |
Converts a pathname ("/map1/map2/class.classname.inc") |
| static
string
|
getClassPath() |
Converts an ATK classname ("map1.map2.classname") |
| static
bool
|
hasOverloader() |
Checks wether or not a class has an overloader defined |
| static
bool
|
import() |
Imports a file |
| static
boolean
|
invokeFromString() |
Invoke a method on a class based on a string definition. |
| static
void
|
mountClassPath() |
Mount a certain (class) path on a certain prefix. After this you can simply load the classes on the given path using the prefix. This makes it for example possible to load classes outside your atkroot. |
| static
object instance
|
newInstance() |
Returns a new instance of a class |
| static
String
|
resolveClass() |
Resolve a classname to its final classname. |
| string|bool |
findClass() |
Finds a class in the current application. |
Properties
Is re-indexed during this request?
Methods
static bool addOverloader(
String
$original, String
$overload, [bool
$overwrite = true]
)
|
|
Add a class overloader
Parameters:
|
String |
$original: |
|
|
String |
$overload: |
|
|
bool |
$overwrite: |
|
API Tags:
| Return: | Wether or not we added the overloader |
static cleaned-up cleanPath(
string
$path
)
|
|
Clean-up the given path.
Parameters:
API Tags:
static string getClassName(
string
$classpath, [bool
$class = true]
)
|
|
Converts a pathname ("/map1/map2/class.classname.inc")
to an ATK classname ("map1.map2.classname")
Parameters:
|
string |
$classpath: |
pathname to be converted |
|
bool |
$class: |
is the file a class? defaults to true |
API Tags:
| Return: | converted filename |
static string getClassPath(
string
$fullclassname, [bool
$class = true]
)
|
|
Converts an ATK classname ("map1.map2.classname")
to a pathname ("/map1/map2/class.classname.inc")
Parameters:
|
string |
$fullclassname: |
ATK classname to be converted |
|
bool |
$class: |
is the file a class? defaults to true |
API Tags:
| Return: | converted filename |
static obj getSingletonInstance(
string
$fullclassname, [bool
$reset = false]
)
|
|
Return a singleton instance of the specified class.
This works for all singletons that implement the getInstance() method.
Parameters:
|
string |
$fullclassname: |
the ATK classname of the class ("map1.map2.classname") |
|
bool |
$reset: |
Force resetting of the instance |
API Tags:
| Return: | instance of the class |
static bool hasOverloader(
String
$original
)
|
|
Checks wether or not a class has an overloader defined
Parameters:
|
String |
$original: |
The class to check for |
API Tags:
| Return: | Wether or not the class has an overloader |
static bool import(
string
$fullclassname, [bool
$failsafe = true], [bool
$path = false]
)
|
|
Imports a file
Parameters:
|
string |
$fullclassname: |
Name of class in atkformat (map1.map2.classfile) |
|
bool |
$failsafe: |
If $failsafe is true (default), the class is required. Otherwise, the class is included. |
|
bool |
$path: |
Whether or not it is NOT an ATK classname ("map.class"), if true it will interpret classname as: "map/class.classname.inc", default false. |
API Tags:
| Return: | whether the file we want to import was actually imported or not |
static boolean invokeFromString(
String
$str, [array
$params = array()]
)
|
|
Invoke a method on a class based on a string definition.
The string must be in the format "packagename.subpackage.classname#methodname"
Parameters:
|
String |
$str: |
The "classname#method" to invoke. |
|
array |
$params: |
Any params to be passed to the invoked method. |
API Tags:
| Return: | false if the call failed. In all other cases, it returns the output of the invoked method. (be careful with methods that return false). |
static void mountClassPath(
string
$prefix, string
$path
)
|
|
Mount a certain (class) path on a certain prefix. After this you can simply load the classes on the given path using the prefix. This makes it for example possible to load classes outside your atkroot.
Note: at the moment only single element prefixes are allowed!
Example: atkClassLoader::mountClassPath('frontend', atkconfig('atkroot').'../frontend/'); atkClassLoader::newInstance('frontend.helloworld');
Parameters:
|
string |
$prefix: |
prefix |
|
string |
$path: |
class path |
static object instance newInstance(
string
$fullclassname, mixed
1
)
|
|
Returns a new instance of a class
Parameters:
|
string |
$fullclassname: |
the ATK classname of the class ("map1.map2.classname") |
|
mixed |
1: |
... all arguments after the class name will be passed to the class constructor |
API Tags:
static object instance newInstanceArgs(
string
$fullclassname, [array
$args = array()]
)
|
|
Returns a new instance of a class
Parameters:
|
string |
$fullclassname: |
the ATK classname of the class ("map1.map2.classname") |
|
array |
$args: |
arguments for the new instance |
API Tags:
static bool removeOverloader(
String
$original
)
|
|
Remove a class overloader for a class
Parameters:
API Tags:
| Return: | Wether or not we removed an overloader |
static String resolveClass(
String
$class
)
|
|
Resolve a classname to its final classname.
An application can overload a class with a custom version. This method resolves the initial classname to its overloaded version (if any).
Parameters:
|
String |
$class: |
The name of the class to resolve |
API Tags:
| Return: | The resolved classname |
Find all classes in ATK.
API Tags:
| Return: | An array with the classes as keys and the path as value. |
Information Tags:
| Todo: | Make it search and support modules too. |
string|bool findClass(
string
$class
)
|
|
Finds a class in the current application.
Parameters:
|
string |
$class: |
The classname to find. |
API Tags:
| Return: | The classpath (atkimport statement) of the class if found, else false |
Array getAllClasses(
[bool
$force = false]
)
|
|
Gets an array with all the the classes
Parameters:
|
bool |
$force: |
Force reloading of classes, instead of using cache. |
API Tags:
| Return: | An array with the classes as keys and the path as value. |