| Method Summary |
|
static
void
|
Class autoload loader.
|
|
static
TComponent
|
Creates a component with the specified type.
|
|
static
void
|
Default exception handler.
|
|
static
void
|
Fatal error handler.
|
|
static
TApplication
|
|
|
static
string
|
|
|
static
TLogger
|
|
|
protected
static
void
|
|
|
static
string
|
|
|
static
string
|
Translates a namespace into a file path.
|
|
static
string
|
Returns the most preferred language by the client user.
|
|
static
array
|
Returns a list of user preferred languages.
|
|
static
string
|
|
|
static
void
|
Initializes error handlers.
|
|
static
string
|
localize
( string $text, array $parameters, string $catalogue, string $charset)
Localize a text to the locale/culture specified in the globalization handler.
|
|
static
void
|
log
( string $msg, integer $level, string $category, (string|TControl) $ctl)
Logs a message.
|
|
static
void
|
phpErrorHandler
( integer $errno, string $errstr, string $errfile, integer $errline)
PHP error handler.
|
|
static
string
|
|
|
static
string
|
Serializes a data.
|
|
static
void
|
Stores the application instance in the class static member.
|
|
static
void
|
|
|
static
void
|
trace
( string $msg, string $category, (string|TControl) $ctl)
Writes a log message.
|
|
static
mixed
|
Unserializes a data.
|
|
static
void
|
using
( string $namespace, boolean $checkClassExistence)
Uses a namespace.
|
|
static
string
|
varDump
( mixed $var, integer $depth, boolean $highlight)
Converts a variable into a string representation.
|
| Method Details |
autoload
| public static void autoload |
(string $className ) |
Class autoload loader.
This method is provided to be invoked within an __autoload() magic method.
| Input |
| string | $className | class name |
| Output |
| Exception |
|
createComponent
| public static TComponent createComponent |
(string $type ) |
Creates a component with the specified type.
A component type can be either the component class name or a namespace referring to the path of the component class file. For example, 'TButton', 'System.Web.UI.WebControls.TButton' are both valid component type. This method can also pass parameters to component constructors. All parameters passed to this method except the first one (the component type) will be supplied as component constructor parameters.
| Input |
| string | $type | component type |
| Output |
|
TComponent
| component instance of the specified type |
| Exception |
| throws | TInvalidDataValueException if the component type is unknown |
|
exceptionHandler
| public static void exceptionHandler |
(Exception $exception ) |
Default exception handler.
This method should be registered as default exception handler using http://www.php.net/set_exception_handler. The method tries to use the errorhandler module of the Prado application to handle the exception. If the application or the module does not exist, it simply echoes the exception.
| Input |
| Exception | $exception | exception that is not caught |
| Output |
| Exception |
|
fatalError
| public static void fatalError |
(string $msg ) |
Fatal error handler.
This method displays an error message together with the current call stack. The application will exit after calling this method.
| Input |
| string | $msg | error message |
| Output |
| Exception |
|
getApplication
| Output |
|
TApplication
| the application singleton, null if the singleton has not be created yet. |
| Exception |
|
getFrameworkPath
| public static string getFrameworkPath |
() |
| Output |
|
string
| the path of the framework |
| Exception |
|
getLogger
| Output |
|
TLogger
| message logger |
| Exception |
|
getPathAliases
| protected static void getPathAliases |
() |
|
getPathOfAlias
| public static string getPathOfAlias |
(string $alias ) |
| Input |
| string | $alias | alias to the path |
| Output |
|
string
| the path corresponding to the alias, null if alias not defined. |
| Exception |
|
getPathOfNamespace
| public static string getPathOfNamespace |
(string $namespace , string $ext ) |
Translates a namespace into a file path.
The first segment of the namespace is considered as a path alias which is replaced with the actual path. The rest segments are subdirectory names appended to the aliased path. If the namespace ends with an asterisk '*', it represents a directory; Otherwise it represents a file whose extension name is specified by the second parameter (defaults to empty). Note, this method does not ensure the existence of the resulting file path.
| Input |
| string | $namespace | namespace |
| string | $ext | extension to be appended if the namespace refers to a file |
| Output |
|
string
| file path corresponding to the namespace, null if namespace is invalid |
| Exception |
|
getPreferredLanguage
| public static string getPreferredLanguage |
() |
Returns the most preferred language by the client user.
| Output |
|
string
| the most preferred language by the client user, defaults to English. |
| Exception |
|
getUserLanguages
| public static array getUserLanguages |
() |
Returns a list of user preferred languages.
The languages are returned as an array. Each array element represents a single language preference. The languages are ordered according to user preferences. The first language is the most preferred.
| Output |
|
array
| list of user preferred languages. |
| Exception |
|
getVersion
| public static string getVersion |
() |
| Output |
|
string
| the version of Prado framework |
| Exception |
|
initErrorHandlers
| public static void initErrorHandlers |
() |
Initializes error handlers.
This method set error and exception handlers to be functions defined in this class.
|
localize
| public static string localize |
(string $text , array $parameters , string $catalogue , string $charset ) |
Localize a text to the locale/culture specified in the globalization handler.
| Input |
| string | $text | text to be localized. |
| array | $parameters | a set of parameters to substitute. |
| string | $catalogue | a different catalogue to find the localize text. |
| string | $charset | the input AND output charset. |
| Output |
|
string
| localized text. |
| Exception |
|
log
| public static void log |
(string $msg , integer $level , string $category , (string|TControl) $ctl ) |
Logs a message.
Messages logged by this method may be retrieved via TLogger::getLogs and may be recorded in different media, such as file, email, database, using TLogRouter.
| Input |
| string | $msg | message to be logged |
| integer | $level | level of the message. Valid values include TLogger::DEBUG, TLogger::INFO, TLogger::NOTICE, TLogger::WARNING, TLogger::ERROR, TLogger::ALERT, TLogger::FATAL. |
| string | $category | category of the message |
| (string|TControl) | $ctl | control of the message |
| Output |
| Exception |
|
phpErrorHandler
| public static void phpErrorHandler |
(integer $errno , string $errstr , string $errfile , integer $errline ) |
PHP error handler.
This method should be registered as PHP error handler using http://www.php.net/set_error_handler. The method throws an exception that contains the error information.
| Input |
| integer | $errno | the level of the error raised |
| string | $errstr | the error message |
| string | $errfile | the filename that the error was raised in |
| integer | $errline | the line number the error was raised at |
| Output |
| Exception |
|
poweredByPrado
| public static string poweredByPrado |
(integer $logoType ) |
| Input |
| integer | $logoType | the type of "powered logo". Valid values include 0 and 1. |
| Output |
|
string
| a string that can be displayed on your Web page showing powered-by-PRADO information |
| Exception |
|
serialize
| public static string serialize |
(mixed $data ) |
Serializes a data.
The original PHP serialize function has a bug that may not serialize properly an object.
| Input |
| mixed | $data | data to be serialized |
| Output |
|
string
| the serialized data |
| Exception |
|
setApplication
| public static void setApplication |
(TApplication $application ) |
Stores the application instance in the class static member.
This method helps implement a singleton pattern for TApplication. Repeated invocation of this method or the application constructor will cause the throw of an exception. This method should only be used by framework developers.
| Input |
| TApplication | $application | the application instance |
| Output |
| Exception |
| throws | TInvalidOperationException if this method is invoked twice or more. |
|
setPathOfAlias
| public static void setPathOfAlias |
(string $alias , string $path ) |
| Input |
| string | $alias | alias to the path |
| string | $path | the path corresponding to the alias |
| Output |
| Exception |
| throws | TInvalidOperationException if the alias is already defined |
| throws | TInvalidDataValueException if the path is not a valid file path |
|
trace
| public static void trace |
(string $msg , string $category , (string|TControl) $ctl ) |
Writes a log message.
This method wraps log() by checking the application mode. When the application is in Debug mode, debug backtrace information is appended to the message and the message is logged at DEBUG level. When the application is in Performance mode, this method does nothing. Otherwise, the message is logged at INFO level.
| Input |
| string | $msg | message to be logged |
| string | $category | category of the message |
| (string|TControl) | $ctl | control of the message |
| Output |
| Exception |
|
unserialize
| public static mixed unserialize |
(string $str ) |
Unserializes a data.
The original PHP unserialize function has a bug that may not unserialize properly an object.
| Input |
| string | $str | data to be unserialized |
| Output |
|
mixed
| unserialized data, null if unserialize failed |
| Exception |
|
using
| public static void using |
(string $namespace , boolean $checkClassExistence ) |
Uses a namespace.
A namespace ending with an asterisk '*' refers to a directory, otherwise it represents a PHP file. If the namespace corresponds to a directory, the directory will be appended to the include path. If the namespace corresponds to a file, it will be included (include_once).
| Input |
| string | $namespace | namespace to be used |
| boolean | $checkClassExistence | whether to check the existence of the class after the class file is included |
| Output |
| Exception |
| throws | TInvalidDataValueException if the namespace is invalid |
|
varDump
| public static string varDump |
(mixed $var , integer $depth , boolean $highlight ) |
Converts a variable into a string representation.
This method achieves the similar functionality as var_dump and print_r but is more robust when handling complex objects such as PRADO controls.
| Input |
| mixed | $var | variable to be dumped |
| integer | $depth | maximum depth that the dumper should go into the variable. Defaults to 10. |
| boolean | $highlight | whether to syntax highlight the output. Defaults to false. |
| Output |
|
string
| the string representation of the variable |
| Exception |
|