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: $Id: PradoBase.php 2446 2008-04-21 14:35:40Z xue $
  • author: Qiang Xue <qiang.xue@gmail.com>

Located in /PradoBase.php (line 41)


	
			
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)
string getFrameworkPath ()
void getPathAliases ()
string getPathOfAlias (string $alias)
string getPathOfNamespace (string $namespace, [string $ext = ''])
array getUserLanguages ()
string getVersion ()
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 (integer $logoType)
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, [boolean $checkClassExistence = true])
string varDump (mixed $var, [integer $depth = 10], [boolean $highlight = false])
Methods
autoload (line 94)

Class autoload loader.

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

  • static:
  • access: public
void autoload (string $className)
  • string $className: class name
createComponent (line 227)

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.

  • 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 143)

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

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 175)
  • return: the application singleton, null if the singleton has not be created yet.
  • static:
  • access: public
TApplication getApplication ()
getFrameworkPath (line 183)
  • return: the path of the framework
  • static:
  • access: public
string getFrameworkPath ()
getLogger (line 530)
  • return: message logger
  • static:
  • access: public
TLogger getLogger ()
getPathAliases (line 341)
  • static:
  • access: protected
void getPathAliases ()
getPathOfAlias (line 336)
  • 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 315)

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

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

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 67)
  • return: the version of Prado framework
  • static:
  • access: public
string getVersion ()
initErrorHandlers (line 77)

Initializes error handlers.

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

  • static:
  • access: public
void initErrorHandlers ()
localize (line 562)

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

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

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 105)
  • return: a string that can be displayed on your Web page showing powered-by-PRADO information
  • static:
  • access: public
string poweredByPrado (integer $logoType)
  • integer $logoType: the type of "powered logo". Valid values include 0 and 1.
serialize (line 195)

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

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)
setPathOfAlias (line 352)
  • 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 493)

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.

void trace (string $msg, [string $category = 'Uncategorized'])
  • string $msg: message to be logged
  • string $category: category of the message
unserialize (line 208)

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

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, [boolean $checkClassExistence = true])
  • string $namespace: namespace to be used
  • boolean $checkClassExistence: whether to check the existence of the class after the class file is included
varDump (line 546)

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

File extension for Prado class files.

Documentation generated on Mon, 21 Apr 2008 11:29:24 -0400 by phpDocumentor 1.3.0RC4