PHP Класс App_CLI, atk4

(c) 2008-2013 Agile Toolkit Limited Distributed under Affero General Public License v3 and commercial license. See LICENSE or LICENSE_COM for more information =====================================================ATK4=
Наследование: extends AbstractView
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$atk_version string This is a major version of Agile Toolkit. The APP of Agile Toolkit is very well established and changes rarely. Your application would generally be compatible throughout the same major version of Agile Tooolkit.
$compat_42 boolean | Controller_Compat42 If you want Agile Toolkit to be compatible with 4.2 version, include compatibility controller.
$config array Once configuration file is read, data is saved inside this property.
$config_files array If you are loading additional config later, use readConfig() instead Order of this array is important.
$config_files_loaded array Contains list of loaded config files.
$config_location string ." or inside "config" sub-folder by setting value to 'config' to better reflect your application layout.
$db DB In a typical application, one connection to the database is enough for majority of applications. Calling $app->dbConnect will read Database data from config file and store it in $db property. If you requires a more advanced connectivity or multiple connections, you can manually initialize more database connections.
$locale string This is the default locale for the application. You change this manually inside application APP class or use some controller which will pull this variable out of the URL. This variable will be respected throughout the framework.
$logger Logger Without logger, APP will dump out errors and exceptions in a very brief and straigtforward way. Logger is a controller which enhances error output and in most cases you do need one. Logger can be further configured to either output detailed errors or show brief message instead.
$logger_class If you want to use your own logger class, redefine this property.
$max_name_length integer Agile Toolkit implements a mechanism which will replace common beginning of objects with an abbreviation thus keeping object name length under control. This variable defines the maximum length of the object's $name. Be mindful that some objects will concatinate theri name with fields, so the maximum letgth of GET argument names can exceed this value by the length of your field. We recommend you to increase SUHOSIN get limits if you encounter any problems. Set this value to "false" to turn off name shortening.
$pathfinder PathFinder PathFinder is a controller which is responsible for locating resources, such as PHP includes, JavaScript files, templates, etc. APP Initializes PathFinder as soon as possible, then defines "Locations" which describe type of data found in different folders.
$pm Controller_PageManager PageManager object
$pr object Profiler measures relative time it took in certain parts of your application to help you find a slow-perfoming parts of application. By default $pr points to empty profiler object, which implements empty methods. All the lines referencing $pr myst be prefixed with the 4-symbol sequence "/ ** /" (no spaces). If you want to speed up Agile Toolkit further, you can eliminate all lines started with this sequence from your source code.
$unique_hashes array As more names are shortened, the substituted part is being placed into this hash and the value contains the new key. This helps to avoid creating many sequential prefixes for the same character sequenece.

Защищенные свойства (Protected)

Свойство Тип Описание
$pagemanager_class string Change a different Page Manager class.
$pagemanager_options array Set to array('debug' => true) to debug Page Manager.
$pathfinder_class string If you would want to use your own PathFinder class, you must change this property and include it.

Открытые методы

Метод Описание
_ ( string $str ) : string Redefine this function to introduce your localization.
__construct ( string $realm = null, array $options = [] ) Regular objects in Agile Toolkit use init() and are added through add().
_beforeInit ( ) Finds out which page is requested. We don't need this method for CLI, but others might need it.
addGlobalMethod ( string $name, callable $callable ) Agile Toolkit objects allow method injection. This is quite similar to technique used in JavaScript:.
addLocation ( array $contents, mixed $obsolete = UNDEFINED ) : PathFinder_Location Add new location with additional resources.
caughtException ( Exception $e ) Is executed if exception is raised during execution.
configExceptionOrDefault ( string $default, string $exceptiontext ) Executed when trying to access config parameter which is not find in the file.
dbConnect ( mixed $dsn = null ) : DB Use database configuration settings from config file to establish default connection.
encodeHtmlChars ( string $s, integer $flags = null, string $encode = null, boolean $double_encode = false ) : string Encodes HTML special chars.
getBaseURL ( ) : string Returns base URL of this Web application installation. If you require link to a page, you can use URL::useAbsoluteURL();.
getConfig ( string $path, mixed $default_value = UNDEFINED ) : string Load config if necessary and look up corresponding setting.
getLogger ( string $class_name = UNDEFINED ) : Logger Initialize logger or return existing one.
getStickyArguments ( ) : array
getVersion ( string $of = 'atk' ) : string Determine version of Agile Toolkit or specified plug-in.
hasGlobalMethod ( string $name ) : boolean Returns if a global method with such name was defined.
locate ( string $type, string $filename = '', string $return = 'relative' ) : string | object | array Find relative path to the resource respective to the current directory.
locatePath ( string $type, string $filename = '' ) : string | object | array Return full system path to specified resource.
locateURL ( string $type, string $filename = '' ) : string | object | array Calculate URL pointing to specified resource.
normalizeClassName ( string | object $name, string $prefix = null ) : string | object First normalize class name, then add specified prefix to class name if it's passed and not already added.
normalizeName ( string $name, string $separator = '_' ) : string Normalize field or identifier name. Can also be used in URL normalization.
outputDebug ( $object, $msg, $shift )
outputWarning ( $msg, $shift )
readAllConfig ( ) Will include all files as they are defined in $this->config_files from folder $config_location.
readConfig ( string $file = 'config.php' ) : boolean Read config file and store it in $this->config. Use getConfig() to access.
removeGlobalMethod ( string $name ) Removes global method.
requires ( string $addon = 'atk', string $v, string $location = null ) : boolean Verifies version. Should be used by addons. For speed improvement, redefine this into empty function.
setConfig ( array $config = [], mixed $val = UNDEFINED ) Manually set configuration option.
url ( mixed $page = null, array $arguments = [] ) : URL Generates URL for specified page. Useful for building links on pages or emails. Returns URL object.
versionRequirement ( $v, $location = null )

Описание методов

_() публичный Метод

Agile Toolkit will pass all system strings through this method. If some methods are not properly passed through, please fork Agile Toolkit from http://github.com/atk4/atk4/ , modify, commit, push your fix and notify authors of Agile Toolkit using contact form on http://agiletoolkit.org/contact. See file CONTRIBUTING
public _ ( string $str ) : string
$str string String which needs localization
Результат string Localized string

__construct() публичный Метод

Application class is differente, you use "new" keyword because it's the first class to be created. That's why constructor will perform quite a bit of initialization. Do not redefine constructor but instead use init(); $realm defines a top-level name of your application. This impacts all id= prefixes in your HTML code, form field names and many other things, such as session name. If you have two application classes which are part of same web app and may want to use same realm, but in other cases it's preferably that you keep realm unique on your domain in the interests of security.
public __construct ( string $realm = null, array $options = [] )
$realm string Will become $app->name
$options array

_beforeInit() публичный Метод

Finds out which page is requested. We don't need this method for CLI, but others might need it.
public _beforeInit ( )

addGlobalMethod() публичный Метод

obj.test = function() { .. } All non-existant method calls on all Agile Toolkit objects will be tried against local table of registered methods and then against global registered methods. addGlobalmethod allows you to register a globally-recognized for all agile toolkit object. PHP is not particularly fast about executing methods like that, but this technique can be used for adding backward-compatibility or debugging, etc.
См. также: AbstractObject::hasMethod()
См. также: AbstractObject::__call()
public addGlobalMethod ( string $name, callable $callable )
$name string Name of the method
$callable callable Calls your function($object, $arg1, $arg2)

addLocation() публичный Метод

Add new location with additional resources.
public addLocation ( array $contents, mixed $obsolete = UNDEFINED ) : PathFinder_Location
$contents array
$obsolete mixed
Результат PathFinder_Location

caughtException() публичный Метод

Re-define to have custom handling of exceptions system-wide.
public caughtException ( Exception $e )
$e Exception

configExceptionOrDefault() публичный Метод

Executed when trying to access config parameter which is not find in the file.
public configExceptionOrDefault ( string $default, string $exceptiontext )
$default string
$exceptiontext string

dbConnect() публичный Метод

Use database configuration settings from config file to establish default connection.
public dbConnect ( mixed $dsn = null ) : DB
$dsn mixed
Результат DB

encodeHtmlChars() публичный Метод

By default does not encode already encoded ones.
public encodeHtmlChars ( string $s, integer $flags = null, string $encode = null, boolean $double_encode = false ) : string
$s string
$flags integer
$encode string
$double_encode boolean
Результат string

getBaseURL() публичный Метод

Returns base URL of this Web application installation. If you require link to a page, you can use URL::useAbsoluteURL();.
См. также: URL::useAbsoluteURL()
public getBaseURL ( ) : string
Результат string

getConfig() публичный Метод

Load config if necessary and look up corresponding setting.
public getConfig ( string $path, mixed $default_value = UNDEFINED ) : string
$path string
$default_value mixed
Результат string

getLogger() публичный Метод

Initialize logger or return existing one.
public getLogger ( string $class_name = UNDEFINED ) : Logger
$class_name string
Результат Logger

getStickyArguments() публичный Метод

public getStickyArguments ( ) : array
Результат array

getVersion() публичный Метод

Determine version of Agile Toolkit or specified plug-in.
public getVersion ( string $of = 'atk' ) : string
$of string
Результат string

hasGlobalMethod() публичный Метод

Returns if a global method with such name was defined.
public hasGlobalMethod ( string $name ) : boolean
$name string Name of the method
Результат boolean if registered

locate() публичный Метод

Find relative path to the resource respective to the current directory.
public locate ( string $type, string $filename = '', string $return = 'relative' ) : string | object | array
$type string
$filename string
$return string
Результат string | object | array

locatePath() публичный Метод

Return full system path to specified resource.
public locatePath ( string $type, string $filename = '' ) : string | object | array
$type string
$filename string
Результат string | object | array

locateURL() публичный Метод

Calculate URL pointing to specified resource.
public locateURL ( string $type, string $filename = '' ) : string | object | array
$type string
$filename string
Результат string | object | array

normalizeClassName() публичный Метод

Class name can have namespaces and they are treated prefectly. If object is passed as $name parameter, then same object is returned. Example: normalizeClassName('User','Model') == 'Model_User';
public normalizeClassName ( string | object $name, string $prefix = null ) : string | object
$name string | object Name of class or object
$prefix string Optional prefix for class name
Результат string | object Full, normalized class name or received object

normalizeName() публичный Метод

This will replace all non alpha-numeric characters with separator. Multiple separators in a row is replaced with one. Separators in beginning and at the end of name are removed. Sample input: "Hello, Dear Jon!" Sample output: "Hello_Dear_Jon"
public normalizeName ( string $name, string $separator = '_' ) : string
$name string String to process
$separator string Character acting as separator
Результат string Normalized string

outputDebug() публичный Метод

Устаревший: 4.3.2
public outputDebug ( $object, $msg, $shift )

outputWarning() публичный Метод

Устаревший: 4.3.2
public outputWarning ( $msg, $shift )

readAllConfig() публичный Метод

Will include all files as they are defined in $this->config_files from folder $config_location.
public readAllConfig ( )

readConfig() публичный Метод

Read config file and store it in $this->config. Use getConfig() to access.
public readConfig ( string $file = 'config.php' ) : boolean
$file string Filename
Результат boolean

removeGlobalMethod() публичный Метод

Removes global method.
public removeGlobalMethod ( string $name )
$name string

requires() публичный Метод

Verifies version. Should be used by addons. For speed improvement, redefine this into empty function.
public requires ( string $addon = 'atk', string $v, string $location = null ) : boolean
$addon string
$v string
$location string
Результат boolean

setConfig() публичный Метод

Manually set configuration option.
public setConfig ( array $config = [], mixed $val = UNDEFINED )
$config array
$val mixed

url() публичный Метод

Generates URL for specified page. Useful for building links on pages or emails. Returns URL object.
public url ( mixed $page = null, array $arguments = [] ) : URL
$page mixed
$arguments array
Результат URL

versionRequirement() публичный Метод

public versionRequirement ( $v, $location = null )

Описание свойств

$atk_version публичное свойство

This is a major version of Agile Toolkit. The APP of Agile Toolkit is very well established and changes rarely. Your application would generally be compatible throughout the same major version of Agile Tooolkit.
public string $atk_version
Результат string

$compat_42 публичное свойство

If you want Agile Toolkit to be compatible with 4.2 version, include compatibility controller.
public bool|Controller_Compat42 $compat_42
Результат boolean | Controller_Compat42

$config публичное свойство

Once configuration file is read, data is saved inside this property.
См. также: getConfig()
См. также: readConfig()
public array $config
Результат array

$config_files публичное свойство

If you are loading additional config later, use readConfig() instead Order of this array is important.
public array $config_files
Результат array

$config_files_loaded публичное свойство

Contains list of loaded config files.
public array $config_files_loaded
Результат array

$config_location публичное свойство

." or inside "config" sub-folder by setting value to 'config' to better reflect your application layout.
public string $config_location
Результат string

$db публичное свойство

In a typical application, one connection to the database is enough for majority of applications. Calling $app->dbConnect will read Database data from config file and store it in $db property. If you requires a more advanced connectivity or multiple connections, you can manually initialize more database connections.
См. также: dbConnect()
public DB $db
Результат DB

$locale публичное свойство

This is the default locale for the application. You change this manually inside application APP class or use some controller which will pull this variable out of the URL. This variable will be respected throughout the framework.
public string $locale
Результат string

$logger публичное свойство

Without logger, APP will dump out errors and exceptions in a very brief and straigtforward way. Logger is a controller which enhances error output and in most cases you do need one. Logger can be further configured to either output detailed errors or show brief message instead.
См. также: Logger
public Logger $logger
Результат Logger

$logger_class публичное свойство

If you want to use your own logger class, redefine this property.
public $logger_class

$max_name_length публичное свойство

Agile Toolkit implements a mechanism which will replace common beginning of objects with an abbreviation thus keeping object name length under control. This variable defines the maximum length of the object's $name. Be mindful that some objects will concatinate theri name with fields, so the maximum letgth of GET argument names can exceed this value by the length of your field. We recommend you to increase SUHOSIN get limits if you encounter any problems. Set this value to "false" to turn off name shortening.
public int $max_name_length
Результат integer

$pagemanager_class защищенное свойство

Change a different Page Manager class.
protected string $pagemanager_class
Результат string

$pagemanager_options защищенное свойство

Set to array('debug' => true) to debug Page Manager.
protected array $pagemanager_options
Результат array

$pathfinder публичное свойство

PathFinder is a controller which is responsible for locating resources, such as PHP includes, JavaScript files, templates, etc. APP Initializes PathFinder as soon as possible, then defines "Locations" which describe type of data found in different folders.
public PathFinder $pathfinder
Результат PathFinder

$pathfinder_class защищенное свойство

If you would want to use your own PathFinder class, you must change this property and include it.
protected string $pathfinder_class
Результат string

$pm публичное свойство

PageManager object
См. также: Controller_PageManager::init()
public Controller_PageManager $pm
Результат Controller_PageManager

$pr публичное свойство

Profiler measures relative time it took in certain parts of your application to help you find a slow-perfoming parts of application. By default $pr points to empty profiler object, which implements empty methods. All the lines referencing $pr myst be prefixed with the 4-symbol sequence "/ ** /" (no spaces). If you want to speed up Agile Toolkit further, you can eliminate all lines started with this sequence from your source code.
public object $pr
Результат object

$unique_hashes публичное свойство

As more names are shortened, the substituted part is being placed into this hash and the value contains the new key. This helps to avoid creating many sequential prefixes for the same character sequenece.
public array $unique_hashes
Результат array