PHP Class Contao\System

The class provides miscellaneous methods that are used all throughout the application. It is the base class of the Contao library which provides the central "import" method to load other library classes. Usage: class MyClass extends \System { public function __construct() { $this->import('Database'); } }
Afficher le fichier Open project: contao/core-bundle Class Usage Examples

Protected Properties

Свойство Type Description
$arrCache array Cache
$arrImageSizes array Available image sizes
$arrLanguageFiles array Loaded language files
$arrLanguages array Available languages
$arrObjects array Default libraries
$arrStaticObjects array Static objects
$objContainer Symfony\Component\DependencyInjection\ContainerInterface Container

Méthodes publiques

Méthode Description
__get ( string $strKey ) : mixed | null Get an object property
addToUrl ( string $strRequest ) : string Add a request string to the current URL
anonymizeIp ( string $strIp ) : string Anonymize an IP address by overriding the last chunk
convertXlfToPhp ( string $strName, string $strLanguage, boolean $blnLoad = false ) : string Convert an .xlf file into a PHP language file
disableModule ( ) : boolean Disable a back end module
enableModule ( ) : boolean Enable a back end module
getContainer ( ) : Symfony\Component\DependencyInjection\ContainerInterface Return the container object
getCountries ( ) : array Return the countries as array
getFormattedNumber ( mixed $varNumber, integer $intDecimals = 2 ) : mixed Format a number
getImageSizes ( ) : array Return all image sizes as array
getIndexFreeRequest ( boolean $blnAmpersand = true ) : string Return the request string without the script name
getLanguages ( boolean $blnInstalledOnly = false ) : array Return the available languages as array
getModelClassFromTable ( string $strTable ) : string Compile a Model class name from a table name (e.g. tl_form_field becomes FormFieldModel)
getReadableSize ( integer $intSize, integer $intDecimals = 1 ) : string Convert a byte value into a human readable format
getReferer ( boolean $blnEncodeAmpersands = false, string $strTable = null ) : string Return the referer URL and optionally encode ampersands
getSessionHash ( string $strCookie ) : string Return the session hash
getTimeZones ( ) : array Return the timezones as array
importStatic ( string $strClass, string $strKey = null, boolean $blnForce = false ) : object Import a library in non-object context
isInstalledLanguage ( boolean $strLanguage ) : boolean Check whether a language is installed
loadLanguageFile ( string $strName, boolean $strLanguage = null, boolean $blnNoCache = false ) Load a set of language files
log ( string $strText, string $strFunction, string $strCategory ) Add a log entry to the database
parseDate ( string $strFormat, integer $intTstamp = null ) : string Parse a date format string and translate textual representations
redirect ( string $strLocation, integer $intStatus = 303 ) Redirect to another page
reload ( ) Reload the current page
setContainer ( Symfony\Component\DependencyInjection\ContainerInterface $container ) Set the container object
setCookie ( string $strName, mixed $varValue, integer $intExpires, string $strPath = null, string $strDomain = null, boolean $blnSecure = false, boolean $blnHttpOnly = false ) Set a cookie
splitFriendlyName ( string $strEmail ) : array Split a friendly-name e-address and return name and e-mail as array
urlEncode ( string $strPath ) : string Urlencode a file path preserving slashes

Méthodes protégées

Méthode Description
__construct ( ) Import the Config and Session instances
addConfirmationMessage ( string $strMessage ) Add a confirmation message
addErrorMessage ( string $strMessage ) Add an error message
addInfoMessage ( string $strMessage ) Add an info message
addMessage ( string $strMessage, string $strType ) Add a message
addNewMessage ( string $strMessage ) Add a new message
addRawMessage ( string $strMessage ) Add an unformatted message
getMessageTypes ( ) : array Return all available message types
getMessages ( string $strScope = TL_MODE ) : string Return all messages as HTML
idnaDecode ( string $strDomain ) : string Decode an internationalized domain name
idnaEncode ( string $strDomain ) : string Encode an internationalized domain name
idnaEncodeEmail ( string $strEmail ) : string Encode the domain in an e-mail address
idnaEncodeUrl ( string $strUrl ) : string Encode the domain in an URL
import ( string $strClass, string $strKey = null, boolean $blnForce = false ) Import a library and make it accessible by its name or an optional key
isValidEmailAddress ( string $strEmail ) : boolean Validate an e-mail address
readPhpFileWithoutTags ( string $strName ) : string Read the contents of a PHP file, stripping the opening and closing PHP tags
resetMessages ( ) Reset the message system

Method Details

__construct() protected méthode

Import the Config and Session instances
protected __construct ( )

__get() public méthode

Lazy load the Input and Environment libraries (which are now static) and only include them as object property if an old module requires it
public __get ( string $strKey ) : mixed | null
$strKey string The property name
Résultat mixed | null The property value or null

addConfirmationMessage() protected méthode

Add a confirmation message
Deprecation: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Message::addConfirmation() instead.
protected addConfirmationMessage ( string $strMessage )
$strMessage string The confirmation

addErrorMessage() protected méthode

Add an error message
Deprecation: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Message::addError() instead.
protected addErrorMessage ( string $strMessage )
$strMessage string The error message

addInfoMessage() protected méthode

Add an info message
Deprecation: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Message::addInfo() instead.
protected addInfoMessage ( string $strMessage )
$strMessage string The info message

addMessage() protected méthode

Add a message
Deprecation: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Message::add() instead.
protected addMessage ( string $strMessage, string $strType )
$strMessage string The message
$strType string The message type

addNewMessage() protected méthode

Add a new message
Deprecation: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Message::addNew() instead.
protected addNewMessage ( string $strMessage )
$strMessage string The new message

addRawMessage() protected méthode

Add an unformatted message
Deprecation: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Message::addRaw() instead.
protected addRawMessage ( string $strMessage )
$strMessage string The unformatted message

addToUrl() public static méthode

Add a request string to the current URL
Deprecation: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Controller::addToUrl() instead.
public static addToUrl ( string $strRequest ) : string
$strRequest string The string to be added
Résultat string The new URL

anonymizeIp() public static méthode

Anonymize an IP address by overriding the last chunk
public static anonymizeIp ( string $strIp ) : string
$strIp string The IP address
Résultat string The encoded IP address

convertXlfToPhp() public static méthode

Convert an .xlf file into a PHP language file
Deprecation: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use the Contao\CoreBundle\Config\Loader\XliffFileLoader instead.
public static convertXlfToPhp ( string $strName, string $strLanguage, boolean $blnLoad = false ) : string
$strName string The name of the .xlf file
$strLanguage string The language code
$blnLoad boolean Add the labels to the global language array
Résultat string The PHP code

disableModule() public static méthode

Disable a back end module
Deprecation: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Composer to add or remove modules.
public static disableModule ( ) : boolean
Résultat boolean True if the module was disabled

enableModule() public static méthode

Enable a back end module
Deprecation: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Composer to add or remove modules.
public static enableModule ( ) : boolean
Résultat boolean True if the module was enabled

getContainer() public static méthode

Return the container object
public static getContainer ( ) : Symfony\Component\DependencyInjection\ContainerInterface
Résultat Symfony\Component\DependencyInjection\ContainerInterface The container object

getCountries() public static méthode

Return the countries as array
public static getCountries ( ) : array
Résultat array An array of country names

getFormattedNumber() public static méthode

Format a number
public static getFormattedNumber ( mixed $varNumber, integer $intDecimals = 2 ) : mixed
$varNumber mixed An integer or float number
$intDecimals integer The number of decimals to show
Résultat mixed The formatted number

getImageSizes() public static méthode

Return all image sizes as array
Deprecation: Deprecated since Contao 4.1, to be removed in Contao 5. Use the contao.image.image_sizes service instead.
public static getImageSizes ( ) : array
Résultat array The available image sizes

getIndexFreeRequest() public static méthode

Return the request string without the script name
Deprecation: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Environment::get("indexFreeRequest") instead.
public static getIndexFreeRequest ( boolean $blnAmpersand = true ) : string
$blnAmpersand boolean If true, ampersands will be encoded
Résultat string The request string

getLanguages() public static méthode

Return the available languages as array
public static getLanguages ( boolean $blnInstalledOnly = false ) : array
$blnInstalledOnly boolean If true, return only installed languages
Résultat array An array of languages

getMessageTypes() protected méthode

Return all available message types
Deprecation: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Message::getTypes() instead.
protected getMessageTypes ( ) : array
Résultat array An array of message types

getMessages() protected méthode

Return all messages as HTML
Deprecation: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Message::generate() instead.
protected getMessages ( string $strScope = TL_MODE ) : string
$strScope string An optional message scope
Résultat string The messages HTML markup

getModelClassFromTable() public static méthode

Compile a Model class name from a table name (e.g. tl_form_field becomes FormFieldModel)
Deprecation: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Model::getClassFromTable() instead.
public static getModelClassFromTable ( string $strTable ) : string
$strTable string The table name
Résultat string The model class name

getReadableSize() public static méthode

Convert a byte value into a human readable format
public static getReadableSize ( integer $intSize, integer $intDecimals = 1 ) : string
$intSize integer The size in bytes
$intDecimals integer The number of decimals to show
Résultat string The human readable size

getReferer() public static méthode

Return the referer URL and optionally encode ampersands
public static getReferer ( boolean $blnEncodeAmpersands = false, string $strTable = null ) : string
$blnEncodeAmpersands boolean If true, ampersands will be encoded
$strTable string An optional table name
Résultat string The referer URL

getSessionHash() public static méthode

Return the session hash
public static getSessionHash ( string $strCookie ) : string
$strCookie string The cookie name
Résultat string The session hash

getTimeZones() public static méthode

Return the timezones as array
public static getTimeZones ( ) : array
Résultat array An array of timezones

idnaDecode() protected méthode

Decode an internationalized domain name
Deprecation: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Idna::decode() instead.
protected idnaDecode ( string $strDomain ) : string
$strDomain string The domain name
Résultat string The decoded domain name

idnaEncode() protected méthode

Encode an internationalized domain name
Deprecation: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Idna::encode() instead.
protected idnaEncode ( string $strDomain ) : string
$strDomain string The domain name
Résultat string The encoded domain name

idnaEncodeEmail() protected méthode

Encode the domain in an e-mail address
Deprecation: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Idna::encodeEmail() instead.
protected idnaEncodeEmail ( string $strEmail ) : string
$strEmail string The e-mail address
Résultat string The encoded e-mail address

idnaEncodeUrl() protected méthode

Encode the domain in an URL
Deprecation: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Idna::encodeUrl() instead.
protected idnaEncodeUrl ( string $strUrl ) : string
$strUrl string The URL
Résultat string The encoded URL

import() protected méthode

Import a library and make it accessible by its name or an optional key
protected import ( string $strClass, string $strKey = null, boolean $blnForce = false )
$strClass string The class name
$strKey string An optional key to store the object under
$blnForce boolean If true, existing objects will be overridden

importStatic() public static méthode

Import a library in non-object context
public static importStatic ( string $strClass, string $strKey = null, boolean $blnForce = false ) : object
$strClass string The class name
$strKey string An optional key to store the object under
$blnForce boolean If true, existing objects will be overridden
Résultat object The imported object

isInstalledLanguage() public static méthode

Check whether a language is installed
public static isInstalledLanguage ( boolean $strLanguage ) : boolean
$strLanguage boolean The language code
Résultat boolean True if the language is installed

isValidEmailAddress() protected méthode

Validate an e-mail address
Deprecation: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Validator::isEmail() instead.
protected isValidEmailAddress ( string $strEmail ) : boolean
$strEmail string The e-mail address
Résultat boolean True if it is a valid e-mail address

loadLanguageFile() public static méthode

Load a set of language files
public static loadLanguageFile ( string $strName, boolean $strLanguage = null, boolean $blnNoCache = false )
$strName string The table name
$strLanguage boolean An optional language code
$blnNoCache boolean If true, the cache will be bypassed

log() public static méthode

Add a log entry to the database
Deprecation: Deprecated since Contao 4.2, to be removed in Contao 5. Use the logger service instead.
public static log ( string $strText, string $strFunction, string $strCategory )
$strText string The log message
$strFunction string The function name
$strCategory string The category name

parseDate() public static méthode

Parse a date format string and translate textual representations
Deprecation: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Date::parse() instead.
public static parseDate ( string $strFormat, integer $intTstamp = null ) : string
$strFormat string The date format string
$intTstamp integer An optional timestamp
Résultat string The textual representation of the date

readPhpFileWithoutTags() protected static méthode

Read the contents of a PHP file, stripping the opening and closing PHP tags
Deprecation: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use the Contao\CoreBundle\Config\Loader\PhpFileLoader instead.
protected static readPhpFileWithoutTags ( string $strName ) : string
$strName string The name of the PHP file
Résultat string The PHP code without the PHP tags

redirect() public static méthode

Redirect to another page
Deprecation: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Controller::redirect() instead.
public static redirect ( string $strLocation, integer $intStatus = 303 )
$strLocation string The target URL
$intStatus integer The HTTP status code (defaults to 303)

reload() public static méthode

Reload the current page
Deprecation: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Controller::reload() instead.
public static reload ( )

resetMessages() protected méthode

Reset the message system
Deprecation: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use Message::reset() instead.
protected resetMessages ( )

setContainer() public static méthode

Set the container object
public static setContainer ( Symfony\Component\DependencyInjection\ContainerInterface $container )
$container Symfony\Component\DependencyInjection\ContainerInterface The container object

setCookie() public static méthode

Set a cookie
public static setCookie ( string $strName, mixed $varValue, integer $intExpires, string $strPath = null, string $strDomain = null, boolean $blnSecure = false, boolean $blnHttpOnly = false )
$strName string The cookie name
$varValue mixed The cookie value
$intExpires integer The expiration date
$strPath string An optional path
$strDomain string An optional domain name
$blnSecure boolean If true, the secure flag will be set
$blnHttpOnly boolean If true, the http-only flag will be set

splitFriendlyName() public static méthode

Split a friendly-name e-address and return name and e-mail as array
Deprecation: Deprecated since Contao 4.0, to be removed in Contao 5.0. Use StringUtil::splitFriendlyEmail() instead.
public static splitFriendlyName ( string $strEmail ) : array
$strEmail string A friendly-name e-mail address
Résultat array An array with name and e-mail address

urlEncode() public static méthode

Urlencode a file path preserving slashes
public static urlEncode ( string $strPath ) : string
$strPath string The file path
Résultat string The encoded file path

Property Details

$arrCache protected_oe property

Cache
Deprecation: Deprecated since Contao 4.0, to be removed in Contao 5.0.
protected array $arrCache
Résultat array

$arrImageSizes protected_oe static_oe property

Available image sizes
protected static array $arrImageSizes
Résultat array

$arrLanguageFiles protected_oe static_oe property

Loaded language files
protected static array $arrLanguageFiles
Résultat array

$arrLanguages protected_oe static_oe property

Available languages
protected static array $arrLanguages
Résultat array

$arrObjects protected_oe property

Default libraries
protected array $arrObjects
Résultat array

$arrStaticObjects protected_oe static_oe property

Static objects
protected static array $arrStaticObjects
Résultat array

$objContainer protected_oe static_oe property

Container
protected static ContainerInterface,Symfony\Component\DependencyInjection $objContainer
Résultat Symfony\Component\DependencyInjection\ContainerInterface