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.

  • author: Qiang Xue <qiang.xue@gmail.com>
  • version: $Id: PradoBase.php 3168 2012-06-25 10:43:31Z ctrlaltca $
  • since: 3.0

Located in /PradoBase.php (line 41)


	
			
Direct descendents
Class Description
Prado Prado class.
Class Constant Summary
 CLASS_FILE_EXT = '.php'
Variable Summary
static array $classExists
Method Summary
static void autoload (string $className)
static TComponent createComponent (string $type)
static void exceptionHandler (Exception $exception)
static void fatalError (string $msg)
static string getFrameworkPath ()
static TLogger getLogger ()
static void getPathAliases ()
static string getPathOfAlias (string $alias)
static string getPathOfNamespace (string $namespace, [string $ext = ''])
static string getPreferredLanguage ()
static array getUserLanguages ()
static string getVersion ()
static void initErrorHandlers ()
static string localize (string $text, [array $parameters = array()], [string $catalogue = null], [string $charset = null])
static void log (string $msg, [integer $level = TLogger::INFO], [string $category = 'Uncategorized'], [(string|TControl) $ctl = null])
static void phpErrorHandler (integer $errno, string $errstr, string $errfile, integer $errline)
static string poweredByPrado ([integer $logoType = 0])
static string serialize (mixed $data)
static void setApplication (TApplication $application)
static void setPathOfAlias (string $alias, string $path)
static void trace (string $msg, [string $category = 'Uncategorized'], [(string|TControl) $ctl = null])
static mixed unserialize (string $str)
static void using (string $namespace, [boolean $checkClassExistence = true])
static string varDump (mixed $var, [integer $depth = 10], [boolean $highlight = false])
Variables
static array $classExists = array() (line 67)
  • var: list of class exists checks
  • access: protected
Methods
static method autoload (line 99)

Class autoload loader.

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

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

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
  • throws: TInvalidDataValueException if the component type is unknown
  • access: public
static TComponent createComponent (string $type)
  • string $type: component type
static method exceptionHandler (line 148)

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.

  • access: public
static void exceptionHandler (Exception $exception)
  • Exception $exception: exception that is not caught
static method fatalError (line 403)

Fatal error handler.

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

  • access: public
static void fatalError (string $msg)
  • string $msg: error message
static method getApplication (line 180)
  • return: the application singleton, null if the singleton has not be created yet.
  • access: public
static TApplication getApplication ()
static method getFrameworkPath (line 188)
  • return: the path of the framework
  • access: public
static string getFrameworkPath ()
static method getLogger (line 562)
  • return: message logger
  • access: public
static TLogger getLogger ()
static method getPathAliases (line 371)
  • access: protected
static void getPathAliases ()
static method getPathOfAlias (line 366)
  • return: the path corresponding to the alias, null if alias not defined.
  • access: public
static string getPathOfAlias (string $alias)
  • string $alias: alias to the path
static method getPathOfNamespace (line 342)

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
  • access: public
static string getPathOfNamespace (string $namespace, [string $ext = ''])
  • string $namespace: namespace
  • string $ext: extension to be appended if the namespace refers to a file
static method getPreferredLanguage (line 497)

Returns the most preferred language by the client user.

  • return: the most preferred language by the client user, defaults to English.
  • access: public
static string getPreferredLanguage ()
static method getUserLanguages (line 469)

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.
  • access: public
static array getUserLanguages ()
static method getVersion (line 72)
  • return: the version of Prado framework
  • access: public
static string getVersion ()
static method initErrorHandlers (line 82)

Initializes error handlers.

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

  • access: public
static void initErrorHandlers ()
static method localize (line 594)

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

  • return: localized text.
  • see: TTranslate::formatter()
  • see: TTranslate::init()
  • access: public
static 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.
static method log (line 552)

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.

  • access: public
static void log (string $msg, [integer $level = TLogger::INFO], [string $category = 'Uncategorized'], [(string|TControl) $ctl = null])
  • 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
static method phpErrorHandler (line 133)

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.

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

Serializes a data.

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

  • return: the serialized data
  • access: public
static string serialize (mixed $data)
  • mixed $data: data to be serialized
static method setApplication (line 170)

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.

  • throws: TInvalidOperationException if this method is invoked twice or more.
  • access: public
static void setApplication (TApplication $application)
static method setPathOfAlias (line 382)
  • throws: TInvalidOperationException if the alias is already defined
  • throws: TInvalidDataValueException if the path is not a valid file path
  • access: public
static void setPathOfAlias (string $alias, string $path)
  • string $alias: alias to the path
  • string $path: the path corresponding to the alias
static method trace (line 524)

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 void trace (string $msg, [string $category = 'Uncategorized'], [(string|TControl) $ctl = null])
  • string $msg: message to be logged
  • string $category: category of the message
  • (string|TControl) $ctl: control of the message
static method unserialize (line 212)

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
  • access: public
static mixed unserialize (string $str)
  • string $str: data to be unserialized
static method using (line 281)

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

  • throws: TInvalidDataValueException if the namespace is invalid
  • access: public
static 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
static method varDump (line 578)

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
  • access: public
static 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, 25 Jun 2012 14:36:49 +0200 by phpDocumentor 1.4.3