PRADO Component Framework for PHP 5
  • Home
  • About
  • Testimonials
  • Demos
  • Download
  • Documentation
  • Forum
  • Development
  • Tutorials
  • Class Docs
  • API Manual
  • Wiki

Packages

  • None
  • System
    • Caching
    • Collections
    • Data
      • ActiveRecord
        • Relations
        • Scaffold
          • InputBuilder
      • Commom
        • Sqlite
      • Common
        • Mssql
        • Mysql
        • Oracle
        • Pgsql
        • Sqlite
      • DataGateway
      • SqlMap
        • Configuration
        • Statements
    • Exceptions
    • I18N
    • IO
    • Security
    • Util
    • Web
      • Javascripts
      • Services
      • UI
        • ActiveControls
        • WebControls
    • Xml
  • Wsat
    • pages
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo

Class PradoBase

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.

Direct known subclasses

Prado
Package: System
Copyright: Copyright © 2005-2014 PradoSoft
License: http://www.pradosoft.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 3.0
Located at PradoBase.php
Methods summary
public static string
# getVersion( )

Returns

string
the version of Prado framework
public static
# initErrorHandlers( )

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

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

public static
# autoload( string $className )

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

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

Parameters

$className
string
class name
public static string
# poweredByPrado( integer $logoType = 0 )

Parameters

$logoType
integer
the type of "powered logo". Valid values include 0 and 1.

Returns

string
a string that can be displayed on your Web page showing powered-by-PRADO information
public static
# phpErrorHandler( integer $errno, string $errstr, string $errfile, integer $errline )

PHP error handler. This method should be registered as PHP error handler using set_error_handler. The method throws an exception that contains the error information.

PHP error handler. This method should be registered as PHP error handler using set_error_handler. The method throws an exception that contains the error information.

Parameters

$errno
integer
the level of the error raised
$errstr
string
the error message
$errfile
string
the filename that the error was raised in
$errline
integer
the line number the error was raised at
public static
# exceptionHandler( Exception $exception )

Default exception handler. This method should be registered as default exception handler using 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.

Default exception handler. This method should be registered as default exception handler using 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.

Parameters

$exception
Exception
exception that is not caught
public static
# 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.

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.

Parameters

$application
TApplication
the application instance

Throws

TInvalidOperationException
if this method is invoked twice or more.
public static TApplication
# getApplication( )

Returns

TApplication
the application singleton, null if the singleton has not be created yet.
public static string
# getFrameworkPath( )

Returns

string
the path of the framework
public static string
# serialize( mixed $data )

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

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

Parameters

$data
mixed
data to be serialized

Returns

string
the serialized data
public static mixed
# unserialize( string $str )

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

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

Parameters

$str
string
data to be unserialized

Returns

mixed
unserialized data, null if unserialize failed
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.

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.

Parameters

$type
string
component type

Returns

TComponent
component instance of the specified type

Throws

TInvalidDataValueException
if the component type is unknown
public static
# using( string $namespace, boolean $checkClassExistence = true )

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

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

Parameters

$namespace
string
namespace to be used
$checkClassExistence
boolean
whether to check the existence of the class after the class file is included

Throws

TInvalidDataValueException
if the namespace is invalid
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.

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.

Parameters

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

Returns

string
file path corresponding to the namespace, null if namespace is invalid
public static string
# getPathOfAlias( string $alias )

Parameters

$alias
string
alias to the path

Returns

string
the path corresponding to the alias, null if alias not defined.
protected static
# getPathAliases( )
public static
# setPathOfAlias( string $alias, string $path )

Parameters

$alias
string
alias to the path
$path
string
the path corresponding to the alias

Throws

TInvalidOperationException
if the alias is already defined
TInvalidDataValueException
if the path is not a valid file path
public static
# 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.

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

Parameters

$msg
string
error message
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.

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.

Returns

array
list of user preferred languages.
public static string
# getPreferredLanguage( )

Returns the most preferred language by the client user.

Returns the most preferred language by the client user.

Returns

string
the most preferred language by the client user, defaults to English.
public static
# trace( string $msg, string $category = 'Uncategorized', (string|TControl) $ctl = null )

Writes a log message. This method wraps PradoBase::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.

Writes a log message. This method wraps PradoBase::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.

Parameters

$msg
string
message to be logged
$category
string
category of the message
$ctl
(string|TControl)
control of the message

See

PradoBase::log(), PradoBase::getLogger()
public static
# log( string $msg, integer $level = TLogger::INFO, string $category = 'Uncategorized', (string|TControl) $ctl = null )

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.

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.

Parameters

$msg
string
message to be logged
$level
integer
level of the message. Valid values include TLogger::DEBUG, TLogger::INFO, TLogger::NOTICE, TLogger::WARNING, TLogger::ERROR, TLogger::ALERT, TLogger::FATAL.
$category
string
category of the message
$ctl
(string|TControl)
control of the message
public static TLogger
# getLogger( )

Returns

TLogger
message logger
public static string
# varDump( mixed $var, integer $depth = 10, boolean $highlight = false )

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.

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.

Parameters

$var
mixed
variable to be dumped
$depth
integer
maximum depth that the dumper should go into the variable. Defaults to 10.
$highlight
boolean
whether to syntax highlight the output. Defaults to false.

Returns

string
the string representation of the variable
public static string
# localize( string $text, array $parameters = array(), string $catalogue = null, string $charset = null )

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

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

Parameters

$text
string
text to be localized.
$parameters
array
a set of parameters to substitute.
$catalogue
string
a different catalogue to find the localize text.
$charset
string
the input AND output charset.

Returns

string
localized text.

See

TTranslate::formatter()
TTranslate::init()
Constants summary
string CLASS_FILE_EXT '.php'
#

File extension for Prado class files.

File extension for Prado class files.

Properties summary
protected static array $classExists array()
#

list of class exists checks

list of class exists checks

Terms of Service | Contact Us
PRADO v3.2.4 API Manual API documentation generated by ApiGen 2.8.0
Copyright © 2006-2014 by the PRADO Group.
Powered by PRADO