## Class PradoBase

Description

PradoBase class.

PradoBase implements a few fundamental static methods.

To use the static methods, Use Prado as the class name rather than PradoBase. PradoBase is meant to serve as the base class of Prado. The latter might be rewritten for customization.

- since: 3.0
- version: $Revision: $ $Date: $
- author: Qiang Xue <qiang.xue@gmail.com>

Located in /PradoBase.php (line 43)

Direct descendents

Class | Description
--- | ---
Prado | Defines Prado class if not defined.

Class Constant Summary
CLASS_FILE_EXT = '.php'
Method Summary
void autoload (string $className)
TComponent createComponent (string $type)
void exceptionHandler (Exception $exception)
void fatalError (string $msg)
TApplication getApplication ()
string getFrameworkPath ()
TLogger getLogger ()
string getPathOfAlias (string $alias)
string getPathOfNamespace (string $namespace, [string $ext = ''])
string getPreferredLanguage ()
array getUserLanguages ()
string getVersion ()
void initErrorHandlers ()
string localize (string $text, [array $parameters = array()], [string $catalogue = null], [string $charset = null])
void log (string $msg, [integer $level = TLogger::INFO], [string $category = 'Uncategorized'])
void phpErrorHandler (integer $errno, string $errstr, string $errfile, integer $errline)
string poweredByPrado ()
string serialize (mixed $data)
void setApplication (TApplication $application)
void setPathOfAlias (string $alias, string $path)
void trace (string $msg, [string $category = 'Uncategorized'])
mixed unserialize (string $str)
void using (string $namespace)
string varDump (mixed $var, [integer $depth = 10], [boolean $highlight = false])
Methods
autoload (line 96)

Class autoload loader.

This method is provided to be invoked within an __auload() magic method.

- static:
- access: public

void autoload (string $className)

- string $className: class name

createComponent (line 220)

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 paramters passed to this method except the first one (the component type) will be supplied as component constructor paramters.

- return: component instance of the specified type
- static:
- access: public
- throws: TInvalidDataValueException if the component type is unknown

TComponent createComponent (string $type)

- string $type: component type

exceptionHandler (line 136)

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.

- static:
- access: public

void exceptionHandler (Exception $exception)

- Exception $exception: exception that is not caught

fatalError (line 370)

Fatal error handler.

This method displays an error message together with the current call stack. The application will exit after calling this method.

- static:
- access: public

void fatalError (string $msg)

- string $msg: error message

getApplication (line 168)

- return: the application singleton, null if the singleton has not be created yet.
- static:
- access: public

TApplication getApplication ()
getFrameworkPath (line 176)

- return: the path of the framework
- static:
- access: public

string getFrameworkPath ()
getLogger (line 501)

- return: message logger
- static:
- access: public

TLogger getLogger ()
getPathOfAlias (line 338)

- return: the path corresponding to the alias, null if alias not defined.
- static:
- access: public

string getPathOfAlias (string $alias)

- string $alias: alias to the path

getPathOfNamespace (line 317)

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.

- return: file path corresponding to the namespace, null if namespace is invalid
- static:
- access: public

string getPathOfNamespace (string $namespace, [string $ext = ''])

- string $namespace: namespace
- string $ext: extension to be appended if the namespace refers to a file

getPreferredLanguage (line 438)

Returns the most preferred language by the client user.

- return: the most preferred language by the client user, defaults to English.
- static:
- access: public

string getPreferredLanguage ()
getUserLanguages (line 410)

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.

- return: list of user preferred languages.
- static:
- access: public

array getUserLanguages ()
getVersion (line 69)

- return: the version of Prado framework
- static:
- access: public

string getVersion ()
initErrorHandlers (line 79)

Initializes error handlers.

This method set error and exception handlers to be functions defined in this class.

- static:
- access: public

void initErrorHandlers ()
localize (line 533)

Localize a text to the locale/culture specified in the globalization handler.

- return: localized text.
- static:
- access: public
- see: TTranslate::init()
- see: TTranslate::formatter()

string localize (string $text, [array $parameters = array()], [string $catalogue = null], [string $charset = null])

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

log (line 491)

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.

- static:
- access: public

void log (string $msg, [integer $level = TLogger::INFO], [string $category = 'Uncategorized'])

- 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

phpErrorHandler (line 121)

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.

- static:
- access: public

void phpErrorHandler (integer $errno, string $errstr, string $errfile, integer $errline)

- 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

poweredByPrado (line 106)

- return: a string that can be displayed on your Web page showing powered-by-PRADO information
- static:
- access: public

string poweredByPrado ()
serialize (line 188)

Serializes a data.

The original PHP serialize function has a bug that may not serialize properly an object.

- return: the serialized data
- static:
- access: public

string serialize (mixed $data)

- mixed $data: data to be serialized

setApplication (line 158)

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.

- static:
- access: public
- throws: TInvalidOperationException if this method is invoked twice or more.

void setApplication (TApplication $application)

- TApplication $application: the application instance

setPathOfAlias (line 349)

- static:
- access: public
- throws: TInvalidOperationException if the alias is already defined
- throws: TInvalidDataValueException if the path is not a valid file path

void setPathOfAlias (string $alias, string $path)

- string $alias: alias to the path
- string $path: the path corresponding to the alias

trace (line 464)

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.

- static:
- access: public
- see: PradoBase::log(), PradoBase::getLogger()

void trace (string $msg, [string $category = 'Uncategorized'])

- string $msg: message to be logged
- string $category: category of the message

unserialize (line 201)

Unserializes a data.

The original PHP unserialize function has a bug that may not unserialize properly an object.

- return: unserialized data, null if unserialize failed
- static:
- access: public

mixed unserialize (string $str)

- string $str: data to be unserialized

using (line 246)

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

- static:
- access: public
- throws: TInvalidDataValueException if the namespace is invalid

void using (string $namespace)

- string $namespace: namespace to be used

varDump (line 517)

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.

- return: the string representation of the variable
- static:
- access: public

string varDump (mixed $var, [integer $depth = 10], [boolean $highlight = false])

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

Class Constants
CLASS_FILE_EXT = '.php' (line 48)

File extension for Prado class files.

Documentation generated on Sun, 04 Jun 2006 18:58:32 -0400 by phpDocumentor 1.3.0RC4