core/model/modx/modx.class.php
This is the main file to include in your scripts to use MODX.
For detailed information on using this class, see {@tutorial modx/modx.pkg}.
- Package
- modx
Constants
\modSystemEvent
Represents a modEvent when invoking events.
Constants
Properties

boolean
$_propagate= 'true'
Whether or not to allow further execution of Plugins for this event
trueDetails- Type
- boolean

string
$activePlugin= ''''
The name of the active plugin being invoked
''Details- Type
- string
- Deprecated

string
$propertySet= ''''
''Details- Type
- string
- Deprecated
Methods

alert(
string $msg
)
:
voidDisplay a message to the user during the event.
| Name | Type | Description |
|---|---|---|
| $msg | string | The message to display. |
- Todo
- Remove this; the centralized modRegistry will handle configurable logging of any kind of message or data to any repository or output context. Use {@link modX::_log()} in the meantime.

isPropagatable(
)
:
booleanReturns whether the event will propagate or not.
| Type | Description |
|---|---|
| boolean |
- Access
- public

output(
string $output
)
:
voidRender output from the event.
| Name | Type | Description |
|---|---|---|
| $output | string | The output to render. |
\modX
This is the MODX gateway class.
It can be used to interact with the MODX framework and serves as a front controller for handling requests to the virtual resources managed by the MODX Content Management Framework.
- Parent(s)
- \xPDO
Constants
SESSION_STATE_UNAVAILABLE
= -1The parameter for when a session state is not able to be accessed
- Const
- SESSION_STATE_UNAVAILABLE
SESSION_STATE_UNINITIALIZED
= 0The parameter for when a session has not yet been instantiated
- Const
- SESSION_STATE_UNINITIALIZED
SESSION_STATE_INITIALIZED
= 1The parameter for when a session has been fully initialized
- Const
- SESSION_STATE_INITIALIZED
SESSION_STATE_EXTERNAL
= 2The parameter marking when a session is being controlled by an external provider
- Const
- SESSION_STATE_EXTERNAL
OPT_AUTO_CREATE_TABLES
= 'auto_create_tables'- Inherited_from
- \xPDO::OPT_AUTO_CREATE_TABLES
OPT_BASE_CLASSES
= 'base_classes'- Inherited_from
- \xPDO::OPT_BASE_CLASSES
OPT_BASE_PACKAGES
= 'base_packages'- Inherited_from
- \xPDO::OPT_BASE_PACKAGES
OPT_CACHE_COMPRESS
= 'cache_compress'- Inherited_from
- \xPDO::OPT_CACHE_COMPRESS
OPT_CACHE_DB
= 'cache_db'- Inherited_from
- \xPDO::OPT_CACHE_DB
OPT_CACHE_DB_COLLECTIONS
= 'cache_db_collections'- Inherited_from
- \xPDO::OPT_CACHE_DB_COLLECTIONS
OPT_CACHE_DB_OBJECTS_BY_PK
= 'cache_db_objects_by_pk'- Inherited_from
- \xPDO::OPT_CACHE_DB_OBJECTS_BY_PK
OPT_CACHE_DB_EXPIRES
= 'cache_db_expires'- Inherited_from
- \xPDO::OPT_CACHE_DB_EXPIRES
OPT_CACHE_DB_HANDLER
= 'cache_db_handler'- Inherited_from
- \xPDO::OPT_CACHE_DB_HANDLER
OPT_CACHE_DB_SIG_CLASS
= 'cache_db_sig_class'- Inherited_from
- \xPDO::OPT_CACHE_DB_SIG_CLASS
OPT_CACHE_DB_SIG_GRAPH
= 'cache_db_sig_graph'- Inherited_from
- \xPDO::OPT_CACHE_DB_SIG_GRAPH
OPT_CACHE_EXPIRES
= 'cache_expires'- Inherited_from
- \xPDO::OPT_CACHE_EXPIRES
OPT_CACHE_FORMAT
= 'cache_format'- Inherited_from
- \xPDO::OPT_CACHE_FORMAT
OPT_CACHE_HANDLER
= 'cache_handler'- Inherited_from
- \xPDO::OPT_CACHE_HANDLER
OPT_CACHE_KEY
= 'cache_key'- Inherited_from
- \xPDO::OPT_CACHE_KEY
OPT_CACHE_PATH
= 'cache_path'- Inherited_from
- \xPDO::OPT_CACHE_PATH
OPT_CACHE_PREFIX
= 'cache_prefix'- Inherited_from
- \xPDO::OPT_CACHE_PREFIX
OPT_CACHE_ATTEMPTS
= 'cache_attempts'- Inherited_from
- \xPDO::OPT_CACHE_ATTEMPTS
OPT_CACHE_ATTEMPT_DELAY
= 'cache_attempt_delay'- Inherited_from
- \xPDO::OPT_CACHE_ATTEMPT_DELAY
OPT_CALLBACK_ON_REMOVE
= 'callback_on_remove'- Inherited_from
- \xPDO::OPT_CALLBACK_ON_REMOVE
OPT_CALLBACK_ON_SAVE
= 'callback_on_save'- Inherited_from
- \xPDO::OPT_CALLBACK_ON_SAVE
OPT_CONNECTIONS
= 'connections'- Inherited_from
- \xPDO::OPT_CONNECTIONS
OPT_CONN_INIT
= 'connection_init'- Inherited_from
- \xPDO::OPT_CONN_INIT
OPT_CONN_MUTABLE
= 'connection_mutable'- Inherited_from
- \xPDO::OPT_CONN_MUTABLE
OPT_HYDRATE_FIELDS
= 'hydrate_fields'- Inherited_from
- \xPDO::OPT_HYDRATE_FIELDS
OPT_HYDRATE_ADHOC_FIELDS
= 'hydrate_adhoc_fields'- Inherited_from
- \xPDO::OPT_HYDRATE_ADHOC_FIELDS
OPT_HYDRATE_RELATED_OBJECTS
= 'hydrate_related_objects'- Inherited_from
- \xPDO::OPT_HYDRATE_RELATED_OBJECTS
OPT_LOADER_CLASSES
= 'loader_classes'- Inherited_from
- \xPDO::OPT_LOADER_CLASSES
- See
- \call()
OPT_ON_SET_STRIPSLASHES
= 'on_set_stripslashes'- Inherited_from
- \xPDO::OPT_ON_SET_STRIPSLASHES
OPT_TABLE_PREFIX
= 'table_prefix'- Inherited_from
- \xPDO::OPT_TABLE_PREFIX
OPT_VALIDATE_ON_SAVE
= 'validate_on_save'- Inherited_from
- \xPDO::OPT_VALIDATE_ON_SAVE
OPT_VALIDATOR_CLASS
= 'validator_class'- Inherited_from
- \xPDO::OPT_VALIDATOR_CLASS
LOG_LEVEL_FATAL
= 0- Inherited_from
- \xPDO::LOG_LEVEL_FATAL
LOG_LEVEL_ERROR
= 1- Inherited_from
- \xPDO::LOG_LEVEL_ERROR
LOG_LEVEL_WARN
= 2- Inherited_from
- \xPDO::LOG_LEVEL_WARN
LOG_LEVEL_INFO
= 3- Inherited_from
- \xPDO::LOG_LEVEL_INFO
LOG_LEVEL_DEBUG
= 4- Inherited_from
- \xPDO::LOG_LEVEL_DEBUG
SCHEMA_VERSION
= '1.1'- Inherited_from
- \xPDO::SCHEMA_VERSION
Properties

boolean
$_cacheEnabled= 'false'
A global cache flag that can be used to enable/disable all xPDO caching.
All caching is disabled by default.Inherited from: \xPDO::$$_cacheEnabledfalseDetails- Type
- boolean
- Access
- public
- Inherited_from
- \xPDO::$$_cacheEnabled

array
$_config= 'null'
nullDetails- Type
- array

array
$_connections= 'array()'
array()Details- Type
- array
- Inherited_from
- \xPDO::$$_connections

boolean
$_debug= 'false'
Indicates the debug state of this instance.
Default is false.Inherited from: \xPDO::$$_debugfalseDetails- Type
- boolean
- Access
- protected
- Inherited_from
- \xPDO::$$_debug

string
$_escapeCharClose= ''''
Indicates the closing escape character used for a particular database engine.
Inherited from: \xPDO::$$_escapeCharClose''Details- Type
- string
- Access
- public
- Inherited_from
- \xPDO::$$_escapeCharClose

string
$_escapeCharOpen= ''''
Indicates the opening escape character used for a particular database engine.
Inherited from: \xPDO::$$_escapeCharOpen''Details- Type
- string
- Access
- public
- Inherited_from
- \xPDO::$$_escapeCharOpen

boolean
$_initialized= 'false'
falseDetails- Type
- boolean

string
$_quoteChar= '"'"'
Represents the character used for quoting strings for a particular driver.
Inherited from: \xPDO::$$_quoteChar"'"Details- Type
- string
- Inherited_from
- \xPDO::$$_quoteChar

integer
$_sessionState= 'modX::SESSION_STATE_UNINITIALIZED'
modX::SESSION_STATE_UNINITIALIZEDDetails- Type
- integer

array
$_systemConfig= 'null'
nullDetails- Type
- array

array
$_userConfig= 'array()'
array()Details- Type
- array

array
$actionMap= 'null'
nullDetails- Type
- array

array
$aliasMap= 'null'
nullDetails- Type
- array

\xPDOCacheManager
$cacheManager= 'null'
nullDetails- Type
- \xPDOCacheManager
- Inherited_from
- \xPDO::$$cacheManager

string
$cachePath= 'null'
nullDetails- Type
- string
- Inherited_from
- \xPDO::$$cachePath

$classMap= 'array()'
array()Details- Type
- n/a
- Inherited_from
- \xPDO::$$classMap

array
$config= 'null'
nullDetails- Type
- array
- Inherited_from
- \xPDO::$$config

\xPDOConnection
$connection= 'null'
nullDetails- Type
- \xPDOConnection
- Inherited_from
- \xPDO::$$connection

array
$contentTypes= 'null'
nullDetails- Type
- array

\modContext
$context= 'null'
nullDetails- Type
- \modContext

array
$contexts= 'array()'
array()Details- Type
- array

\modManagerController
$controller= 'null'
nullDetails

string
$cultureKey= ''''
''Details- Type
- string

\xPDODriver
$driver= 'null'
nullDetails- Type
- \xPDODriver
- Inherited_from
- \xPDO::$$driver

array
$elementCache= 'array ()'
array ()Details- Type
- array

\modError
$error= 'null'
nullDetails- Type
- \modError

\modErrorHandler|object
$errorHandler= 'null'
nullDetails- Type
- \modErrorHandler | object

\modSystemEvent
$event= 'null'
nullDetails- Type
- \modSystemEvent

array
$eventMap= 'null'
nullDetails- Type
- array

int
$executedQueries= '0'
0Details- Type
- int
- Inherited_from
- \xPDO::$$executedQueries

array
$instances= 'array()'
array()Details- Type
- array
- Inherited_from
- \xPDO::$$instances

array
$jscripts= 'array ()'
array ()Details- Type
- array

\modLexicon
$lexicon= 'null'
nullDetails- Type
- \modLexicon

array
$loadedjscripts= 'array ()'
array ()Details- Type
- array

integer
$logLevel= 'xPDO::LOG_LEVEL_FATAL'
xPDO::LOG_LEVEL_FATALDetails- Type
- integer
- Inherited_from
- \xPDO::$$logLevel

string
$logTarget= ''ECHO''
'ECHO'Details- Type
- string
- Inherited_from
- \xPDO::$$logTarget

\xPDOManager
$manager= 'null'
{@link xPDOManager} instance, loaded only if needed to manage datasource containers, data structures, etc.
Inherited from: \xPDO::$$managernullDetails- Type
- \xPDOManager
- Access
- public
- Inherited_from
- \xPDO::$$manager

array
$map= 'array ()'
array ()Details- Type
- array
- Access
- public
- Inherited_from
- \xPDO::$$map

string
$package= ''''
''Details- Type
- string
- Access
- public
- Inherited_from
- \xPDO::$$package

array
$packages= 'array ()'
An array storing packages and package-specific information.
Inherited from: \xPDO::$$packagesarray ()Details- Type
- array
- Access
- public
- Inherited_from
- \xPDO::$$packages

\modParser
$parser= 'null'
nullDetails- Type
- \modParser

\PDO
$pdo= 'null'
nullDetails- Type
- \PDO
- Inherited_from
- \xPDO::$$pdo

array
$placeholders= 'array ()'
array ()Details- Type
- array

array
$pluginCache= 'array()'
array()Details- Type
- array

array
$processors= 'array()'
array()Details- Type
- array

int
$queryTime= '0'
0Details- Type
- int
- Inherited_from
- \xPDO::$$queryTime

\modRequest
$request= 'null'
nullDetails- Type
- \modRequest

\modResource
$resource= 'null'
nullDetails- Type
- \modResource
- Used_by
- \modFieldTag

boolean
$resourceGenerated= 'false'
falseDetails- Type
- boolean

mixed
$resourceIdentifier= 'null'
nullDetails- Type
- mixed

array
$resourceListing= 'null'
nullDetails- Type
- array

string
$resourceMethod= 'null'
nullDetails- Type
- string

\modResponse
$response= 'null'
nullDetails- Type
- \modResponse

array
$sanitizePatterns= 'array(
'scripts' => '@<script[^>]*?>.*?</script>@si',
'entities' => '@&#(\d+);@e',
'tags' => '@\[\[(.[^\[\[]*?)\]\]@si',
)'
array(
'scripts' => '@<script[^>]*?>.*?</script>@si',
'entities' => '@&#(\d+);@e',
'tags' => '@\[\[(.[^\[\[]*?)\]\]@si',
)Details- Type
- array

array
$services= 'array ()'
array ()Details- Type
- array

array
$sjscripts= 'array ()'
array ()Details- Type
- array

array
$sourceCache= 'array(
'modChunk' => array()
,'modSnippet' => array()
,'modTemplateVar' => array()
)'
array(
'modChunk' => array()
,'modSnippet' => array()
,'modTemplateVar' => array()
)Details- Type
- array

float
$startTime= '0'
0Details- Type
- float
- Inherited_from
- \xPDO::$$startTime

\modUser
$user= 'null'
nullDetails- Type
- \modUser

array
$version= 'null'
nullDetails- Type
- array
Methods

__construct(
string $configPath
=
'', array $options
=
null, array $driverOptions
=
null
)
:
\modXConstruct a new modX instance.
This method is used to create a new xPDO object with a connection to a specific database container.
| Name | Type | Description |
|---|---|---|
| $configPath | string | An absolute filesystem path to look for the config file. |
| $options | array | xPDO options that can be passed to the instance. |
| $driverOptions | array | PDO driver options that can be passed to the instance. |
| Type | Description |
|---|---|
| \modX | A new modX instance. |

_getFullTableName(
string $baseTableName, boolean $includeDb
=
false
)
:
stringAdds the table prefix, and optionally database name, to a given table.
Inherited from: \xPDO::_getFullTableName()| Name | Type | Description |
|---|---|---|
| $baseTableName | string | The table name as specified in the object model. |
| $includeDb | boolean | Qualify the table name with the database name. |
| Type | Description |
|---|---|
| string | The fully-qualified and quoted table name for the |

_getLogLevel(
integer $level
)
:
string
| Name | Type | Description |
|---|---|---|
| $level | integer | The logging level to retrieve a string for. |
| Type | Description |
|---|---|
| string | The string representation of a valid logging level. |

_initContext(
string $contextKey, boolean $regenerate
=
false, $options
=
null
)
:
booleanLoads a specified Context.
Merges any context settings with the modX::$config, and performs any other context specific initialization tasks.
| Name | Type | Description |
|---|---|---|
| $contextKey | string | A context identifier. |
| $regenerate | boolean | If true, force regeneration of the context even if already initialized. |
| $options |
| Type | Description |
|---|---|
| boolean | True if the context was properly initialized |
- Access
- protected

_initCulture(
array | null $options
=
null
)
:
voidInitializes the culture settings.
| Name | Type | Description |
|---|---|---|
| $options | array | null | Options for the culture initialization process. |

_initErrorHandler(
array | null $options
=
null
)
:
voidLoads the error handler for this instance.
| Name | Type | Description |
|---|---|---|
| $options | array | null | An array of options for the errorHandler. |

_initEventMap(
string $contextKey
)
:
voidPopulates the map of events and registered plugins for each.
| Name | Type | Description |
|---|---|---|
| $contextKey | string | Context identifier. |

_initSession(
array | null $options
=
null
)
:
voidLoads the session handler and starts the session.
| Name | Type | Description |
|---|---|---|
| $options | array | null | Options to override Settings explicitly. |

_loadClass(
$class, $fqn, $included
=
false, $path
=
'', $transient
=
false
)
:
void| Name | Type | Description |
|---|---|---|
| $class | ||
| $fqn | ||
| $included | ||
| $path | ||
| $transient |

_loadConfig(
)
:
booleanLoads the modX system configuration settings.
| Type | Description |
|---|---|
| boolean | True if successful. |
- Access
- protected

_loadExtensionPackages(
array | null $options
=
null
)
:
voidLoads any specified extension packages.
| Name | Type | Description |
|---|---|---|
| $options | array | null | An optional array of options that can contain additional extension packages which will be merged with those specified via config. |

_log(
integer $level, string $msg, string $target
=
'', string $def
=
'', string $file
=
'', string $line
=
''
)
:
voidProvides modX the ability to use modRegister instances as log targets.
| Name | Type | Description |
|---|---|---|
| $level | integer | The level of the logged message. |
| $msg | string | The message to log. |
| $target | string | The logging target. |
| $def | string | The name of a defining structure (such as a class) to help identify the log event source. |
| $file | string | A filename in which the log event occured. |
| $line | string | A line number to help locate the source of the event within the indicated file. |

_logInRegister(
\modRegister $register, int $level, string $msg, string $def, string $file, string $line
)
:
voidProvides custom logging functionality for modRegister targets.
| Name | Type | Description |
|---|---|---|
| $register | \modRegister | The modRegister instance to send to |
| $level | int | The level of error or message that occurred |
| $msg | string | The message to send to the register |
| $def | string | The type of error that occurred |
| $file | string | The filename of the file that the message occurs for |
| $line | string | The line number of the file that the message occurs for |
- Access
- protected

_postProcess(
)
:
voidExecuted after the response is sent and execution is completed.
- Access
- protected

addConnection(
string $dsn, string $username
=
'', string $password
=
'', array $options
=
array(), null $driverOptions
=
null
)
:
booleanAdd an xPDOConnection instance to the xPDO connection pool.
Inherited from: \xPDO::addConnection()| Name | Type | Description |
|---|---|---|
| $dsn | string | A PDO DSN representing the connection details. |
| $username | string | The username credentials for the connection. |
| $password | string | The password credentials for the connection. |
| $options | array | An array of options for the connection. |
| $driverOptions | null | An array of PDO driver options for the connection. |
| Type | Description |
|---|---|
| boolean | True if a valid connection was added. |

addDerivativeCriteria(
string $className, \xPDOCriteria $criteria
)
:
voidAdd criteria when requesting a derivative class row automatically.
Inherited from: \xPDO::addDerivativeCriteria()This applies class_key filtering for single-table inheritance queries and may provide a convenient location for similar features in the future.
| Name | Type | Description |
|---|---|---|
| $className | string | A valid xPDOObject derivative table class. |
| $criteria | \xPDOCriteria | A valid xPDOCriteria instance. |

addEventListener(
string $event, integer $pluginId
)
:
booleanAdd a plugin to the eventMap within the current execution cycle.
| Name | Type | Description |
|---|---|---|
| $event | string | Name of the event. |
| $pluginId | integer | Plugin identifier to add to the event. |
| Type | Description |
|---|---|
| boolean | true if the event is successfully added, otherwise false. |

addExtensionPackage(
string $name, string $path, array $options
=
array()
)
:
booleanAdd an extension package to MODX
| Name | Type | Description |
|---|---|---|
| $name | string | |
| $path | string | |
| $options | array |
| Type | Description |
|---|---|
| boolean |

addPackage(
string $pkg
=
'', string $path
=
'', string | null $prefix
=
null
)
:
boolAdds a model package and base class path for including classes and/or maps from.
Inherited from: \xPDO::addPackage()| Name | Type | Description |
|---|---|---|
| $pkg | string | A package name to use when looking up classes/maps in xPDO. |
| $path | string | The root path for looking up classes in this package. |
| $prefix | string | null | Provide a string to define a package-specific table_prefix. |
| Type | Description |
|---|---|
| bool |

beginTransaction(
)
:
void- See
- \http://php.net/manual/en/function.pdo-begintransaction.php

call(
string $class, string $method, array $args
=
array(), boolean $transient
=
false
)
:
mixed | nullCall a static method from a valid package class with arguments.
Inherited from: \xPDO::call()Will always search for database-specific class files first.
| Name | Type | Description |
|---|---|---|
| $class | string | The name of a class to to get the static method from. |
| $method | string | The name of the method you want to call. |
| $args | array | An array of arguments for the method. |
| $transient | boolean | Indicates if the class has dbtype derivatives. Set to true if you want to use on classes not derived from xPDOObject. |
| Type | Description |
|---|---|
| mixed | null | The callback method's return value or null if no valid method is found. |

checkForLocks(
integer $id, string $action, string $type
)
:
string | booleanChecks for locking on a page.
| Name | Type | Description |
|---|---|---|
| $id | integer | Id of the user checking for a lock. |
| $action | string | The action identifying what is locked. |
| $type | string | Message indicating the kind of lock being checked. |
| Type | Description |
|---|---|
| string | boolean | If locked, will return a locked message |

checkSession(
string $sessionContext
=
'web'
)
:
booleanChecks to see if the user has a session in the specified context.
| Name | Type | Description |
|---|---|---|
| $sessionContext | string | The context to test for a session key in. |
| Type | Description |
|---|---|
| boolean | True if the user is valid in the context specified. |

checkSiteStatus(
)
:
booleanDetermines the current site_status.
| Type | Description |
|---|---|
| boolean | True if the site is online or the user has a valid user session in the 'mgr' context; false otherwise. |

commit(
)
:
void- See
- \http://php.net/manual/en/function.pdo-commit.php

connect(
array $driverOptions
=
array (), $options
=
array()
)
:
booleanGet or create a PDO connection to a database specified in the configuration.
Inherited from: \xPDO::connect()| Name | Type | Description |
|---|---|---|
| $driverOptions | array | An optional array of driver options to use when creating the connection. |
| $options |
| Type | Description |
|---|---|
| boolean | Returns true if the PDO connection was created successfully. |

errorCode(
)
:
void- See
- \http://php.net/manual/en/function.pdo-errorcode.php

errorInfo(
)
:
void- See
- \http://php.net/manual/en/function.pdo-errorinfo.php

escSplit(
string $char, string $str, string $escToken
=
'`', integer $limit
=
0
)
:
arraySplits a string on a specified character, ignoring escaped content.
Inherited from: \xPDO::escSplit()| Name | Type | Description |
|---|---|---|
| $char | string | A character to split the tag content on. |
| $str | string | The string to operate on. |
| $escToken | string | A character used to surround escaped content; all content within a pair of these tokens will be ignored by the split operation. |
| $limit | integer | Limit the number of results. Default is 0 which is no limit. Note that setting the limit to 1 will only return the content up to the first instance of the split character and will discard the remainder of the string. |
| Type | Description |
|---|---|
| array | An array of results from the split operation, or an empty array. |
- Static

escape(
string $string
)
:
stringEscapes the provided string using the platform-specific escape character.
Inherited from: \xPDO::escape()Different database engines escape string literals in SQL using different characters. For example, this is used to escape column names that might match a reserved string for that SQL interpreter. To write database agnostic queries with xPDO, it is highly recommend to escape any database or column names in any native SQL strings used.
| Name | Type | Description |
|---|---|---|
| $string | string | A string to escape using the platform-specific escape characters. |
| Type | Description |
|---|---|
| string | The string escaped with the platform-specific escape characters. |

exec(
$query
)
:
void| Name | Type | Description |
|---|---|---|
| $query |
- See
- \http://php.net/manual/en/function.pdo-exec.php

fromCache(
string | \xPDOCriteria $signature, string $class
=
'', array $options
=
array()
)
:
array | string | null
| Name | Type | Description |
|---|---|---|
| $signature | string | \xPDOCriteria | A unique string or xPDOCriteria object that represents the query identifying the result set. |
| $class | string | An optional classname the result represents. |
| $options | array | Various cache options. |
| Type | Description |
|---|---|
| array | string | null | A PHP array or JSON object representing the result set, or null if no cache representation is found. |

fromJSON(
string $src, boolean $asArray
=
true
)
:
mixedConverts a JSON source string into an equivalent PHP representation.
Inherited from: \xPDO::fromJSON()| Name | Type | Description |
|---|---|---|
| $src | string | A JSON source string. |
| $asArray | boolean | Indicates if the result should treat objects as associative arrays; since all JSON associative arrays are objects, the default is true. Set to false to have JSON objects returned as PHP objects. |
| Type | Description |
|---|---|
| mixed | The PHP representation of the JSON source. |

getAggregates(
string $className
)
:
arrayGets a collection of aggregate foreign key relationship definitions.
Inherited from: \xPDO::getAggregates()| Name | Type | Description |
|---|---|---|
| $className | string | The fully-qualified name of the class. |
| Type | Description |
|---|---|
| array | An array of aggregate foreign key relationship definitions. |

getAncestry(
string $className, boolean $includeSelf
=
true
)
:
array
| Name | Type | Description |
|---|---|---|
| $className | string | className The name of the class. |
| $includeSelf | boolean | includeSelf Determines if the specified class should be included in the resulting array. |
| Type | Description |
|---|---|
| array | An array of string class names representing the class hierarchy, or an empty array if unsuccessful. |

getAttribute(
$attribute
)
:
void| Name | Type | Description |
|---|---|---|
| $attribute |
- See
- \http://php.net/manual/en/function.pdo-getattribute.php

getAuthenticatedUser(
string $contextKey
=
''
)
:
\modUser | nullGets the user authenticated in the specified context.
| Name | Type | Description |
|---|---|---|
| $contextKey | string | Optional context key; uses current context by default. |
| Type | Description |
|---|---|
| \modUser | null | The user object that is authenticated in the specified context, or null if no user is authenticated. |

getCacheManager(
string $class
=
'cache.xPDOCacheManager', array $options
=
array('path' => XPDO_CORE_PATH, 'ignorePkg' => true)
)
:
\modCacheManagerGet an extended xPDOCacheManager instance responsible for MODX caching.
This class is responsible for handling all types of caching operations for the xPDO core.
| Name | Type | Description |
|---|---|---|
| $class | string | The class name of the cache manager to load |
| $options | array | An array of options to send to the cache manager instance |
| Type | Description |
|---|---|
| \modCacheManager | A modCacheManager instance registered for this modX instance. |

getChildIds(
integer $id
=
null, integer $depth
=
10, array $options
=
array()
)
:
arrayGets all of the child resource ids for a given resource.
| Name | Type | Description |
|---|---|---|
| $id | integer | The resource id for the starting node. |
| $depth | integer | How many levels max to search for children (default 10). |
| $options | array | An array of filtering options, such as 'context' to specify the context to grab from |
| Type | Description |
|---|---|
| array | An array of all the child resource ids for the specified resource. |
- See
- \getTree

getChunk(
string $chunkName, array $properties
=
array ()
)
:
stringProcess and return the output from a Chunk by name.
| Name | Type | Description |
|---|---|---|
| $chunkName | string | The name of the chunk. |
| $properties | array | An associative array of properties to process the Chunk with, treated as placeholders within the scope of the Element. |
| Type | Description |
|---|---|
| string | The processed output of the Chunk. |

getCollection(
string $className, object | array | string $criteria
=
null, mixed $cacheFlag
=
true
)
:
array | nullRetrieves a collection of xPDOObjects by the specified xPDOCriteria.
Inherited from: \xPDO::getCollection()| Name | Type | Description |
|---|---|---|
| $className | string | Name of the class to search for instances of. |
| $criteria | object | array | string | An xPDOCriteria object or an array search expression. |
| $cacheFlag | mixed | If an integer value is provided, this specifies the time to live in the result set cache; if cacheFlag === false, caching is ignored for the collection and if cacheFlag === true, the objects will live in cache until flushed by another process. |
| Type | Description |
|---|---|
| array | null | An array of class instances retrieved. |

getCollectionGraph(
string $className, string | array $graph, mixed $criteria
=
null, boolean $cacheFlag
=
true
)
:
arrayRetrieves a collection of xPDOObject instances with related objects.
Inherited from: \xPDO::getCollectionGraph()| Name | Type | Description |
|---|---|---|
| $className | string | The name of the class to return a collection of. |
| $graph | string | array | A related object graph in array or JSON format, e.g. array('relationAlias'=>array('subRelationAlias'=>array())) or {"relationAlias":{"subRelationAlias":{}}}. Note that the empty arrays are necessary in order for the relation to be recognized. |
| $criteria | mixed | A valid xPDOCriteria instance or condition string. |
| $cacheFlag | boolean | Indicates if the result set should be cached. |
| Type | Description |
|---|---|
| array | An array of instances matching the criteria with related objects from the graph hydrated. An empty array is returned when no matches are found. |

getComposites(
string $className
)
:
arrayGets a collection of composite foreign key relationship definitions.
Inherited from: \xPDO::getComposites()| Name | Type | Description |
|---|---|---|
| $className | string | The fully-qualified name of the class. |
| Type | Description |
|---|---|
| array | An array of composite foreign key relationship definitions. |

getConfig(
)
:
arrayGet the configuration for the site.
| Type | Description |
|---|---|
| array | An associate array of configuration key/values |

getConnection(
array $options
=
array()
)
:
\xPDOConnection | nullGet an xPDOConnection from the xPDO connection pool.
Inherited from: \xPDO::getConnection()| Name | Type | Description |
|---|---|---|
| $options | array | An array of options for getting the connection. |
| Type | Description |
|---|---|
| \xPDOConnection | null | An xPDOConnection instance or null if no connection could be retrieved. |

getContext(
string $contextKey
)
:
\modContextRetrieve a context by name without initializing it.
Within a request, contexts retrieved using this function will cache the context data into the modX::$contexts array to avoid loading the same context multiple times.
| Name | Type | Description |
|---|---|---|
| $contextKey | string | The context to retrieve. |
| Type | Description |
|---|---|
| \modContext | A modContext object retrieved from cache or database. |
- Access
- public

getCount(
string $className, mixed $criteria
=
null
)
:
integerRetrieves a count of xPDOObjects by the specified xPDOCriteria.
Inherited from: \xPDO::getCount()| Name | Type | Description |
|---|---|---|
| $className | string | Class of xPDOObject to count instances of. |
| $criteria | mixed | Any valid xPDOCriteria object or expression. |
| Type | Description |
|---|---|
| integer | The number of instances found by the criteria. |

getCriteria(
string $className, string $type
=
null, boolean | integer $cacheFlag
=
true
)
:
\xPDOCriteriaConvert any valid criteria into an xPDOQuery instance.
Inherited from: \xPDO::getCriteria()| Name | Type | Description |
|---|---|---|
| $className | string | The class to get predefined criteria for. |
| $type | string | The type of criteria to get (you can define any type you want, but 'object' and 'collection' are the typical criteria for retrieving single and multiple instances of an object). |
| $cacheFlag | boolean | integer | Indicates if the result is cached and optionally for how many seconds. |
| Type | Description |
|---|---|
| \xPDOCriteria | A criteria object or null if not found. |

getCriteriaType(
mixed $criteria
)
:
string | nullValidate and return the type of a specified criteria variable.
Inherited from: \xPDO::getCriteriaType()| Name | Type | Description |
|---|---|---|
| $criteria | mixed | An xPDOCriteria instance or any valid criteria variable. |
| Type | Description |
|---|---|
| string | null | The type of valid criteria passed, or null if the criteria is not valid. |

getDebug(
)
:
boolean
| Type | Description |
|---|---|
| boolean | The current debug state for the instance, true for on, false for off. |

getDebugBacktrace(
)
:
arrayReturns an abbreviated backtrace of debugging information.
Inherited from: \xPDO::getDebugBacktrace()This function returns just the fields returned via xPDOObject::toArray() on xPDOObject instances, and simply the classname for other objects, to reduce the amount of unnecessary information returned.
| Type | Description |
|---|---|
| array | The abbreviated backtrace. |

getDescendants(
string $className
)
:
arrayGets a list of derivative classes for the specified xPDOObject instance.
Inherited from: \xPDO::getDescendants()NOTE: Will not work with xPDOObject/xPDOSimpleObject.
| Name | Type | Description |
|---|---|---|
| $className | string | The name of the class to retrieve derivatives for. |
| Type | Description |
|---|---|
| array | An array of derivative classes or an empty array. |

getDriver(
)
:
\xPDODriver | null
The driver class provides baseline data and operations for a specific database driver.
| Type | Description |
|---|---|
| \xPDODriver | null | An xPDODriver instance for the xPDO connection, or null if a driver class can not be instantiated. |

getEventMap(
string $contextKey
)
:
arrayGets a map of events and registered plugins for the specified context.
Service #s: 1 - Parser Service Events 2 - Manager Access Events 3 - Web Access Service Events 4 - Cache Service Events 5 - Template Service Events 6 - User Defined Events
| Name | Type | Description |
|---|---|---|
| $contextKey | string | Context identifier. |
| Type | Description |
|---|---|
| array | A map of events and registered plugins for each. |

getFKDefinition(
string $parentClass, string $alias
)
:
arrayGets an aggregate or composite relation definition from a class.
Inherited from: \xPDO::getFKDefinition()| Name | Type | Description |
|---|---|---|
| $parentClass | string | The class from which the relation is defined. |
| $alias | string | The alias identifying the related class. |
| Type | Description |
|---|---|
| array | The aggregate or composite definition details in an array or null if no definition is found. |

getFieldAliases(
string $className
)
:
arrayGets a collection of field aliases for an object by class name.
Inherited from: \xPDO::getFieldAliases()| Name | Type | Description |
|---|---|---|
| $className | string | The name of the class to lookup field aliases for. |
| Type | Description |
|---|---|
| array | An array of field aliases with aliases as keys and actual field names as values. |

getFieldMeta(
string $className, boolean $includeExtended
=
false
)
:
arrayGets a list of field (or column) definitions for an object by class name.
Inherited from: \xPDO::getFieldMeta()These definitions are used by the objects themselves to build their own meta data based on class inheritance.
| Name | Type | Description |
|---|---|---|
| $className | string | The name of the class to lookup fields meta data for. |
| $includeExtended | boolean | If true, include meta from all derivative classes in loaded packages. |
| Type | Description |
|---|---|
| array | An array featuring field names as the array keys, and arrays of metadata information as the array values; empty array is returned if unsuccessful. |

getFields(
string $className
)
:
arrayGets a list of fields (or columns) for an object by class name.
Inherited from: \xPDO::getFields()This includes default values for each field and is used by the objects themselves to build their initial attributes based on class inheritence.
| Name | Type | Description |
|---|---|---|
| $className | string | The name of the class to lookup fields for. |
| Type | Description |
|---|---|
| array | An array featuring field names as the array keys, and default field values as the array values; empty array is returned if unsuccessful. |

getGraph(
string $className, int $depth
=
3, array $parents
=
array(), array $visited
=
array()
)
:
array
| Name | Type | Description |
|---|---|---|
| $className | string | A fully-qualified xPDOObject class name. |
| $depth | int | The depth to retrieve relations for the graph, defaults to 3. |
| $parents | array | &$parents An array of parent classes to avoid traversing circular dependencies. |
| $visited | array | &$visited An array of already visited classes to avoid traversing circular dependencies. |
| Type | Description |
|---|---|
| array | An xPDOObject relation graph, or an empty array if no graph can be constructed. |

getIndexMeta(
string $className
)
:
array
| Name | Type | Description |
|---|---|---|
| $className | string | The name of the class to lookup indices for. |
| Type | Description |
|---|---|
| array | An array of indices and their details for the specified class. |

getInherit(
\$className $className
)
:
stringIndicates the inheritance model for the xPDOObject class specified.
Inherited from: \xPDO::getInherit()| Name | Type | Description |
|---|---|---|
| $className | \$className | The class to determine the table inherit type from. |
| Type | Description |
|---|---|
| string | single, multiple, or none |

getInstance(
string | int | null $id
=
null, array | null $config
=
null, bool $forceNew
=
false
)
:
\modXCreate, retrieve, or update specific modX instances.
| Name | Type | Description |
|---|---|---|
| $id | string | int | null | An optional identifier for the instance. If not set a uniqid will be generated and used as the key for the instance. |
| $config | array | null | An optional array of config data for the instance. |
| $forceNew | bool | If true a new instance will be created even if an instance with the provided $id already exists in modX::$instances. |
| Type | Description |
|---|---|
| \modX | An instance of modX. |
| Exception | Description |
|---|---|
| \xPDOException |
- Static

getIterator(
string $className, mixed $criteria
=
null, bool $cacheFlag
=
true
)
:
\xPDOIteratorRetrieves an iterable representation of a collection of xPDOObjects.
Inherited from: \xPDO::getIterator()| Name | Type | Description |
|---|---|---|
| $className | string | Name of the class to search for instances of. |
| $criteria | mixed | An xPDOCriteria object or representation. |
| $cacheFlag | bool | If an integer value is provided, this specifies the time to live in the result set cache; if cacheFlag === false, caching is ignored for the collection and if cacheFlag === true, the objects will live in cache until flushed by another process. |
| Type | Description |
|---|---|
| \xPDOIterator | An iterable representation of a collection. |

getLogLevel(
)
:
integer| Type | Description |
|---|---|
| integer | The current log level. |

getLogTarget(
)
:
integer| Type | Description |
|---|---|
| integer | The current log level. |

getLoginUserID(
string $context
=
''
)
:
integerReturns the current user ID, for the current or specified context.
| Name | Type | Description |
|---|---|---|
| $context | string | The key of a valid modContext so you can retrieve the current user ID from a different context than the current. |
| Type | Description |
|---|---|
| integer | The ID of the current user. |

getLoginUserName(
string $context
=
''
)
:
stringReturns the current user name, for the current or specified context.
| Name | Type | Description |
|---|---|---|
| $context | string | The key of a valid modContext so you can retrieve the username from a different context than the current. |
| Type | Description |
|---|---|
| string | The username of the current user. |

getManager(
)
:
\xPDOManager | null
The manager class can perform operations such as creating or altering table structures, creating data containers, generating custom persistence classes, and other advanced operations that do not need to be loaded frequently.
| Type | Description |
|---|---|
| \xPDOManager | null | An xPDOManager instance for the xPDO connection, or null if a manager class can not be instantiated. |

getModelVersion(
string $className
)
:
stringGets the version string of the schema the specified class was generated from.
Inherited from: \xPDO::getModelVersion()| Name | Type | Description |
|---|---|---|
| $className | string | The name of the class to get the model version from. |
| Type | Description |
|---|---|
| string | The version string for the schema model the class was generated from. |

getObject(
string $className, mixed $criteria
=
null, mixed $cacheFlag
=
true
)
:
object | nullRetrieves a single object instance by the specified criteria.
Inherited from: \xPDO::getObject()The criteria can be a primary key value, and array of primary key values (for multiple primary key objects) or an {@link xPDOCriteria} object. If no $criteria parameter is specified, no class is found, or an object cannot be located by the supplied criteria, null is returned.
| Name | Type | Description |
|---|---|---|
| $className | string | Name of the class to get an instance of. |
| $criteria | mixed | Primary key of the record or a xPDOCriteria object. |
| $cacheFlag | mixed | If an integer value is provided, this specifies the time to live in the object cache; if cacheFlag === false, caching is ignored for the object and if cacheFlag === true, the object will live in cache indefinitely. |
| Type | Description |
|---|---|
| object | null | An instance of the class, or null if it could not be instantiated. |
- Uses
- \xPDOObject::load()

getObjectGraph(
string $className, string | array $graph, mixed $criteria
=
null, boolean | integer $cacheFlag
=
true
)
:
objectRetrieves an xPDOObject instance with specified related objects.
Inherited from: \xPDO::getObjectGraph()| Name | Type | Description |
|---|---|---|
| $className | string | The name of the class to return an instance of. |
| $graph | string | array | A related object graph in array or JSON format, e.g. array('relationAlias'=>array('subRelationAlias'=>array())) or {"relationAlias":{"subRelationAlias":{}}}. Note that the empty arrays are necessary in order for the relation to be recognized. |
| $criteria | mixed | A valid xPDOCriteria instance or expression. |
| $cacheFlag | boolean | integer | Indicates if the result set should be cached, and optionally for how many seconds. |
| Type | Description |
|---|---|
| object | The object instance with related objects from the graph hydrated, or null if no instance can be located by the criteria. |

getObjectLoader(
string $className, string $method
)
:
\callableFinds the class responsible for loading instances of the specified class.
Inherited from: \xPDO::getObjectLoader()| Name | Type | Description |
|---|---|---|
| $className | string | The name of the class to find a loader for. |
| $method | string | Indicates the specific loader method to use, loadCollection or loadObject (or other public static methods). |
| Type | Description |
|---|---|
| \callable | A callable loader function. |

getOption(
string $key, array $options
=
null, mixed $default
=
null, $skipEmpty
=
false
)
:
mixed
| Name | Type | Description |
|---|---|---|
| $key | string | The option key. |
| $options | array | A set of options to override those from xPDO. |
| $default | mixed | An optional default value to return if no value is found. |
| $skipEmpty |
| Type | Description |
|---|---|
| mixed | The configuration option value. |

getPDOType(
mixed $value
)
:
int | nullGet the appropriate PDO::PARAM_ type constant from a PHP value.
Inherited from: \xPDO::getPDOType()| Name | Type | Description |
|---|---|---|
| $value | mixed | Any PHP scalar or null value |
| Type | Description |
|---|---|
| int | null |

getPK(
string $className
)
:
mixed
| Name | Type | Description |
|---|---|---|
| $className | string | The name of the class to lookup the primary key for. |
| Type | Description |
|---|---|
| mixed | The name of the field representing a class instance primary key, an array of key names for compound primary keys, or null if no primary key is found or defined for the class. |

getPKType(
string $className, $pk
=
false
)
:
string
| Name | Type | Description |
|---|---|---|
| $className | string | className The name of the class to lookup the primary key type for. |
| $pk |
| Type | Description |
|---|---|
| string | The type of the field representing a class instance primary key, or null if no primary key is found or defined for the class. |

getPackage(
string $className
)
:
string
| Name | Type | Description |
|---|---|---|
| $className | string | The name of the class to lookup the package for. |
| Type | Description |
|---|---|
| string | The package the class belongs to. |

getParentIds(
integer $id
=
null, integer $height
=
10, array $options
=
array()
)
:
arrayGets all of the parent resource ids for a given resource.
| Name | Type | Description |
|---|---|---|
| $id | integer | The resource id for the starting node. |
| $height | integer | How many levels max to search for parents (default 10). |
| $options | array | An array of filtering options, such as 'context' to specify the context to grab from |
| Type | Description |
|---|---|
| array | An array of all the parent resource ids for the specified resource. |

getParser(
)
:
\modParserGets the MODX parser.
Returns an instance of modParser responsible for parsing tags in element content, performing actions, returning content and/or sending other responses in the process.
| Type | Description |
|---|---|
| \modParser | The modParser for this modX instance. |

getPlaceholder(
string $key
)
:
mixedGet a placeholder value by key.
| Name | Type | Description |
|---|---|---|
| $key | string | The key of the placeholder to a return a value from. |
| Type | Description |
|---|---|
| mixed | The value of the requested placeholder, or an empty string if not located. |
- Used_by
- \modPlaceholderTag

getRegisteredClientScripts(
)
:
stringReturns all registered JavaScripts.
| Type | Description |
|---|---|
| string | The parsed HTML of the client scripts. |
- Access
- public

getRegisteredClientStartupScripts(
)
:
stringReturns all registered startup CSS, JavaScript, or HTML blocks.
| Type | Description |
|---|---|
| string | The parsed HTML of the startup scripts. |
- Access
- public

getRequest(
string $class
=
'modRequest', string $path
=
''
)
:
booleanAttempt to load the request handler class, if not already loaded.
| Name | Type | Description |
|---|---|---|
| $class | string | The class name of the response class to load. Defaults to modRequest; is ignored if the Setting "modRequest.class" is set. |
| $path | string | The absolute path by which to load the response class from. Defaults to the current MODX model path. |
| Type | Description |
|---|---|
| boolean | Returns true if a valid request handler object was loaded on this or any previous call to the function, false otherwise. |
- Access
- public

getResponse(
string $class
=
'modResponse', string $path
=
''
)
:
booleanAttempt to load the response handler class, if not already loaded.
| Name | Type | Description |
|---|---|---|
| $class | string | The class name of the response class to load. Defaults to modResponse; is ignored if the Setting "modResponse.class" is set. |
| $path | string | The absolute path by which to load the response class from. Defaults to the current MODX model path. |
| Type | Description |
|---|---|
| boolean | Returns true if a valid response handler object was loaded on this or any previous call to the function, false otherwise. |
- Access
- public

getSelectColumns(
string $className, string $tableAlias
=
'', string $columnPrefix
=
'', array $columns
=
array (), boolean $exclude
=
false
)
:
stringGets select columns from a specific class for building a query.
Inherited from: \xPDO::getSelectColumns()| Name | Type | Description |
|---|---|---|
| $className | string | The name of the class to build the column list from. |
| $tableAlias | string | An optional alias for the class table, to be used in complex queries with multiple tables. |
| $columnPrefix | string | An optional string with which to prefix the columns returned, to avoid name collisions in return columns. |
| $columns | array | An optional array of columns to include. |
| $exclude | boolean | If true, will exclude columns in the previous parameter, instead of including them. |
| Type | Description |
|---|---|
| string | A valid SQL string of column names for a SELECT statement. |

getService(
string $name, string $class
=
'', string $path
=
'', array $params
=
array ()
)
:
object | null
| Name | Type | Description |
|---|---|---|
| $name | string | The variable name of the instance. |
| $class | string | The service class name. |
| $path | string | An optional root path to search for the class. |
| $params | array | An array of optional params to pass to the service class constructor. |
| Type | Description |
|---|---|
| object | null | A reference to the service class instance or null if it could not be loaded. |

getSessionState(
)
:
integerReturns the state of the SESSION being used by modX.
The possible values for session state are:
modX::SESSION_STATE_UNINITIALIZED modX::SESSION_STATE_UNAVAILABLE modX::SESSION_STATE_EXTERNAL modX::SESSION_STATE_INITIALIZED
| Type | Description |
|---|---|
| integer | Returns an integer representing the session state. |

getTableClass(
string $className
)
:
null | stringGet the class which defines the table for a specified className.
Inherited from: \xPDO::getTableClass()| Name | Type | Description |
|---|---|---|
| $className | string | The name of a class to determine the table class from. |
| Type | Description |
|---|---|
| null | string | The name of a class defining the table for the specified className; null if not found. |

getTableMeta(
string $className
)
:
stringGets the actual run-time table metadata from a specified class name.
Inherited from: \xPDO::getTableMeta()| Name | Type | Description |
|---|---|---|
| $className | string | The name of the class to lookup a table name for. |
| Type | Description |
|---|---|
| string | The table meta data for the class, or null if unsuccessful. |

getTableName(
string $className, boolean $includeDb
=
false
)
:
stringGets the actual run-time table name from a specified class name.
Inherited from: \xPDO::getTableName()| Name | Type | Description |
|---|---|---|
| $className | string | The name of the class to lookup a table name for. |
| $includeDb | boolean | Qualify the table name with the database name. |
| Type | Description |
|---|---|
| string | The table name for the class, or null if unsuccessful. |

getTree(
int | array $id
=
null, int $depth
=
10
)
:
arrayGet a site tree from a single or multiple modResource instances.
| Name | Type | Description |
|---|---|---|
| $id | int | array | A single or multiple modResource ids to build the tree from. |
| $depth | int | The maximum depth to build the tree (default 10). |
| Type | Description |
|---|---|
| array | An array containing the tree structure. |
- See
- \getChildIds

getUser(
string $contextKey
=
'', boolean $forceLoadSettings
=
false
)
:
\modUserGet the current authenticated User and assigns it to the modX instance.
| Name | Type | Description |
|---|---|---|
| $contextKey | string | An optional context to get the user from. |
| $forceLoadSettings | boolean | If set to true, will load settings regardless of whether the user has an authenticated context or not. |
| Type | Description |
|---|---|
| \modUser | The user object authenticated for the request. |

getValidationRules(
string $className
)
:
arrayGets a set of validation rules defined for an object by class name.
Inherited from: \xPDO::getValidationRules()| Name | Type | Description |
|---|---|---|
| $className | string | The name of the class to lookup validation rules for. |
| Type | Description |
|---|---|
| array | An array featuring field names as the array keys, and arrays of validation rule information as the array values; empty array is returned if unsuccessful. |

getValue(
\PDOStatement $stmt, null | integer $column
=
null
)
:
mixedExecute a PDOStatement and get a single column value from the first row of the result set.
Inherited from: \xPDO::getValue()| Name | Type | Description |
|---|---|---|
| $stmt | \PDOStatement | A prepared PDOStatement object ready to be executed. |
| $column | null | integer | 0-indexed number of the column you wish to retrieve from the row. If null or no value is supplied, it fetches the first column. |
| Type | Description |
|---|---|
| mixed | The value of the specified column from the first row of the result set, or null. |

getVersionData(
)
:
arrayGets the modX core version data.
| Type | Description |
|---|---|
| array | The version data loaded from the config version file. |

handleRequest(
)
:
mixedInitialize, cleanse, and process a request made to a modX site.
| Type | Description |
|---|---|
| mixed | The result of the request handler. |

hasPermission(
string $pm
)
:
booleanReturns true if user has the specified policy permission.
| Name | Type | Description |
|---|---|---|
| $pm | string | Permission key to check. |
| Type | Description |
|---|---|
| boolean |

initConfig(
string | array $data
)
:
array
| Name | Type | Description |
|---|---|---|
| $data | string | array | The config input source. Currently accepts a PHP array, or a PHP string representing xPDO::OPT_TABLE_PREFIX (deprecated). |
| Type | Description |
|---|---|
| array | An array of xPDO config data. |

initialize(
string $contextKey
=
'web', array | null $options
=
null
)
:
boolInitializes the modX engine.
This includes preparing the session, pre-loading some common classes and objects, the current site and context settings, extension packages used to override session handling, error handling, or other initialization classes
| Name | Type | Description |
|---|---|---|
| $contextKey | string | Indicates the context to initialize. |
| $options | array | null | An array of options for the initialization. |
| Type | Description |
|---|---|
| bool | True if initialized successfully, or already initialized. |

invokeEvent(
string $eventName, array $params
=
array ()
)
:
booleanInvokes a specified Event with an optional array of parameters.
| Name | Type | Description |
|---|---|---|
| $eventName | string | Name of an event to invoke. |
| $params | array | Optional params provided to the elements registered with an event. |
| Type | Description |
|---|---|
| boolean |
- Access
- public
- Todo
- refactor this completely, yuck!!

isInitialized(
)
:
booleanReturns whether modX instance has been initialized or not.
| Type | Description |
|---|---|
| boolean |
- Access
- public

lastInsertId(
)
:
void- See
- \http://php.net/manual/en/function.pdo-lastinsertid.php

lexicon(
string $key, array $params
=
array(), string $language
=
''
)
:
null | stringGrabs a processed lexicon string.
| Name | Type | Description |
|---|---|---|
| $key | string | |
| $params | array | |
| $language | string |
| Type | Description |
|---|---|
| null | string | The translated string, or null if none is set |
- Access
- public

literal(
string $string
)
:
stringUse to insert a literal string into a SQL query without escaping or quoting.
Inherited from: \xPDO::literal()| Name | Type | Description |
|---|---|---|
| $string | string | A string to return as a literal, unescaped and unquoted. |
| Type | Description |
|---|---|
| string | The string with any escape or quote characters trimmed. |

loadClass(
string $fqn, $path
=
'', $ignorePkg
=
false, $transient
=
false
)
:
string | boolean
The $fqn should in the format:
dir_a.dir_b.dir_c.classname
which will translate to:
XPDO_CORE_PATH/om/dir_a/dir_b/dir_c/dbtype/classname.class.php
| Name | Type | Description |
|---|---|---|
| $fqn | string | The fully-qualified name of the class to load. |
| $path | ||
| $ignorePkg | ||
| $transient |
| Type | Description |
|---|---|
| string | boolean | The actual classname if successful, or false if not. |

loadConfig(
string $configPath
=
'', array $data
=
array(), null $driverOptions
=
null
)
:
arrayLoad the modX configuration when creating an instance of modX.
| Name | Type | Description |
|---|---|---|
| $configPath | string | An absolute path location to search for the modX config file. |
| $data | array | Data provided to initialize the instance with, overriding config file entries. |
| $driverOptions | null | Driver options for the primary connection. |
| Type | Description |
|---|---|
| array | The merged config data ready for use by the modX::__construct() method. |

log(
integer $level, string $msg, string $target
=
'', string $def
=
'', string $file
=
'', string $line
=
''
)
:
voidLog a message with details about where and when an event occurs.
Inherited from: \xPDO::log()| Name | Type | Description |
|---|---|---|
| $level | integer | The level of the logged message. |
| $msg | string | The message to log. |
| $target | string | The logging target. |
| $def | string | The name of a defining structure (such as a class) to help identify the message source. |
| $file | string | A filename in which the log event occured. |
| $line | string | A line number to help locate the source of the event within the indicated file. |

logManagerAction(
string $action, string $class_key, mixed $item
)
:
\modManagerLogLogs a manager action.
| Name | Type | Description |
|---|---|---|
| $action | string | The action to pull from the lexicon module. |
| $class_key | string | The class key that the action is being performed on. |
| $item | mixed | The primary key id or array of keys to grab the object with. |
| Type | Description |
|---|---|
| \modManagerLog | The newly created modManagerLog object. |

makeUrl(
integer $id, string $context
=
'', string $args
=
'', mixed $scheme
=
-1, array $options
=
array()
)
:
stringGenerates a URL representing a specified resource.
| Name | Type | Description |
|---|---|---|
| $id | integer | The id of a resource. |
| $context | string | Specifies a context to limit URL generation to. |
| $args | string | A query string to append to the generated URL. |
| $scheme | mixed | The scheme indicates in what format the URL is generated. -1 : (default value) URL is relative to site_url 0 : see http 1 : see https full : URL is absolute, prepended with site_url from config abs : URL is absolute, prepended with base_url from config http : URL is absolute, forced to http scheme https : URL is absolute, forced to https scheme |
| $options | array | An array of options for generating the Resource URL. |
| Type | Description |
|---|---|
| string | The URL for the resource. |

messageQuit(
string $msg
=
'unspecified error', string $query
=
'', bool $is_error
=
true, string $nr
=
'', string $file
=
'', string $source
=
'', string $text
=
'', string $line
=
''
)
:
voidLegacy fatal error message.
| Name | Type | Description |
|---|---|---|
| $msg | string | |
| $query | string | |
| $is_error | bool | |
| $nr | string | |
| $file | string | |
| $source | string | |
| $text | string | |
| $line | string |
- Deprecated

newObject(
string $className, array $fields
=
array ()
)
:
object | null
All new objects created with this method are transient until {@link xPDOObject::save()} is called the first time and is reflected by the {@link xPDOObject::$_new} property.
| Name | Type | Description |
|---|---|---|
| $className | string | Name of the class to get a new instance of. |
| $fields | array | An associated array of field names/values to populate the object with. |
| Type | Description |
|---|---|
| object | null | A new instance of the specified class, or null if a new object could not be instantiated. |

newQuery(
string $class, mixed $criteria
=
null, boolean | integer $cacheFlag
=
true
)
:
\xPDOQueryCreates an new xPDOQuery for a specified xPDOObject class.
Inherited from: \xPDO::newQuery()| Name | Type | Description |
|---|---|---|
| $class | string | The class to create the xPDOQuery for. |
| $criteria | mixed | Any valid xPDO criteria expression. |
| $cacheFlag | boolean | integer | Indicates if the result should be cached and optionally for how many seconds (if passed an integer greater than 0). |
| Type | Description |
|---|---|
| \xPDOQuery | The resulting xPDOQuery instance or false if unsuccessful. |

parseBindings(
string $sql, array $bindings
)
:
stringParses parameter bindings in SQL prepared statements.
Inherited from: \xPDO::parseBindings()| Name | Type | Description |
|---|---|---|
| $sql | string | A SQL prepared statement to parse bindings in. |
| $bindings | array | An array of parameter bindings to use for the replacements. |
| Type | Description |
|---|---|
| string | The SQL with the binding placeholders replaced. |

parseChunk(
string $chunkName, array $chunkArr, string $prefix
=
'[[+', string $suffix
=
']]'
)
:
stringParse a chunk using an associative array of replacement variables.
| Name | Type | Description |
|---|---|---|
| $chunkName | string | The name of the chunk. |
| $chunkArr | array | An array of properties to replace in the chunk. |
| $prefix | string | The placeholder prefix, defaults to [[+. |
| $suffix | string | The placeholder suffix, defaults to ]]. |
| Type | Description |
|---|---|
| string | The processed chunk with the placeholders replaced. |

parseDSN(
string $string
)
:
arrayParses a DSN and returns an array of the connection details.
Inherited from: \xPDO::parseDSN()| Name | Type | Description |
|---|---|---|
| $string | string | The DSN to parse. |
| Type | Description |
|---|---|
| array | An array of connection details from the DSN. |
- Static

prepare(
$statement, $driver_options
=
array ()
)
:
void| Name | Type | Description |
|---|---|---|
| $statement | ||
| $driver_options |
- See
- \http://php.net/manual/en/function.pdo-prepare.php

query(
$query
)
:
void| Name | Type | Description |
|---|---|---|
| $query |
- See
- \http://php.net/manual/en/function.pdo-query.php

quote(
$string, $parameter_type
=
PDO::PARAM_STR
)
:
void| Name | Type | Description |
|---|---|---|
| $string | ||
| $parameter_type |
- See
- \http://php.net/manual/en/function.pdo-quote.php

regClientCSS(
string $src
)
:
voidRegister CSS to be injected inside the HEAD tag of a resource.
| Name | Type | Description |
|---|---|---|
| $src | string | The CSS to be injected before the closing HEAD tag in an HTML response. |

regClientHTMLBlock(
string $html
)
:
voidRegister HTML to be injected before the closing BODY tag.
| Name | Type | Description |
|---|---|---|
| $html | string | The HTML to be injected. |

regClientScript(
string $src, boolean $plaintext
=
false
)
:
voidRegister JavaScript to be injected before the closing BODY tag.
| Name | Type | Description |
|---|---|---|
| $src | string | The JavaScript to be injected before the closing BODY tag in an HTML response. |
| $plaintext | boolean | Optional param to treat the $src as plaintext rather than assuming it is JavaScript. |

regClientStartupHTMLBlock(
string $html
)
:
voidRegister HTML to be injected before the closing HEAD tag.
| Name | Type | Description |
|---|---|---|
| $html | string | The HTML to be injected. |

regClientStartupScript(
string $src, boolean $plaintext
=
false
)
:
voidRegister JavaScript to be injected inside the HEAD tag of a resource.
| Name | Type | Description |
|---|---|---|
| $src | string | The JavaScript to be injected before the closing HEAD tag of an HTML response. |
| $plaintext | boolean | Optional param to treat the $src as plaintext rather than assuming it is JavaScript. |

reloadConfig(
)
:
arrayReload the config settings.
| Type | Description |
|---|---|
| array | An associative array of configuration key/values |

reloadContext(
string $key
=
null
)
:
booleanReload data for a specified Context, without switching to it.
Note that the Context will be loaded even if it is not already.
| Name | Type | Description |
|---|---|---|
| $key | string | The key of the Context to (re)load. |
| Type | Description |
|---|---|
| boolean | True if the Context was (re)loaded successfully; false otherwise. |

removeCollection(
string $className, mixed $criteria
)
:
boolean | integerRemove a collection of instances by the supplied className and criteria.
Inherited from: \xPDO::removeCollection()| Name | Type | Description |
|---|---|---|
| $className | string | The name of the class to remove a collection of. |
| $criteria | mixed | Valid xPDO criteria for selecting a collection. |
| Type | Description |
|---|---|
| boolean | integer | False if the remove encounters an error, otherwise an integer value representing the number of rows that were removed. |

removeEventListener(
string $event
)
:
booleanRemove an event from the eventMap so it will not be invoked.
| Name | Type | Description |
|---|---|---|
| $event | string |
| Type | Description |
|---|---|
| boolean | false if the event parameter is not specified or is not present in the eventMap. |

removeExtensionPackage(
string $name
)
:
booleanRemove an extension package from MODX
| Name | Type | Description |
|---|---|---|
| $name | string |
| Type | Description |
|---|---|
| boolean |

removeObject(
string $className, mixed $criteria
)
:
booleanRemove an instance of the specified className by a supplied criteria.
Inherited from: \xPDO::removeObject()| Name | Type | Description |
|---|---|---|
| $className | string | The name of the class to remove an instance of. |
| $criteria | mixed | Valid xPDO criteria for selecting an instance. |
| Type | Description |
|---|---|
| boolean | True if the instance is successfully removed. |

rollBack(
)
:
void- See
- \http://php.net/manual/en/function.pdo-rollback.php

runProcessor(
string $action
=
'', array $scriptProperties
=
array(), array $options
=
array()
)
:
mixedLoads and runs a specific processor.
| Name | Type | Description |
|---|---|---|
| $action | string | The processor to run, eg: context/update |
| $scriptProperties | array | Optional. An array of parameters to pass to the processor. |
| $options | array | Optional. An array of options for running the processor, such as: - processors_path - If specified, will override the default MODX processors path. - location - A prefix to load processor files from, will prepend to the action parameter (Note: location will be deprecated in future Revolution versions.) |
| Type | Description |
|---|---|
| mixed | The result of the processor. |

runSnippet(
string $snippetName, array $params
=
array ()
)
:
stringProcess and return the output from a PHP snippet by name.
| Name | Type | Description |
|---|---|---|
| $snippetName | string | The name of the snippet. |
| $params | array | An associative array of properties to pass to the snippet. |
| Type | Description |
|---|---|
| string | The processed output of the snippet. |

sanitize(
array $target, array | string $patterns
=
array(), integer $depth
=
3, integer $nesting
=
10
)
:
arraySanitize values of an array using regular expression patterns.
| Name | Type | Description |
|---|---|---|
| $target | array | The target array to sanitize. |
| $patterns | array | string | A regular expression pattern, or array of regular expression patterns to apply to all values of the target. |
| $depth | integer | The maximum recursive depth to sanitize if the target contains values that are arrays. |
| $nesting | integer | The maximum nesting level in which to dive |
| Type | Description |
|---|---|
| array | The sanitized array. |
- Static

sanitizeString(
string $str, array $chars
=
array('/',"'",'"','(',')',';','>','<'), string $allowedTags
=
''
)
:
stringSanitizes a string
| Name | Type | Description |
|---|---|---|
| $str | string | The string to sanitize |
| $chars | array | An array of chars to remove |
| $allowedTags | string | A list of tags to allow. |
| Type | Description |
|---|---|
| string | The sanitized string. |

sendError(
string $type
=
'', array $options
=
array()
)
:
voidSend the user to a type-specific core error page and halt PHP execution.
| Name | Type | Description |
|---|---|---|
| $type | string | The type of error to present. |
| $options | array | An array of options to provide for the error file. |

sendErrorPage(
array $options
=
null
)
:
voidSend the user to a MODX virtual error page.
| Name | Type | Description |
|---|---|---|
| $options | array | An array of options to provide for the OnPageNotFound event and error page. |
- Uses
- \invokeEvent()

sendForward(
integer $id, string $options
=
null
)
:
voidForwards the request to another resource without changing the URL.
| Name | Type | Description |
|---|---|---|
| $id | integer | The resource identifier. |
| $options | string | An array of options for the process. |

sendRedirect(
string $url, array | boolean $options
=
false, string $type
=
'', string $responseCode
=
''
)
:
voidSends a redirect to the specified URL using the specified options.
Valid 'type' option values include: REDIRECT_REFRESH Uses the header refresh method REDIRECT_META Sends a a META HTTP-EQUIV="Refresh" tag to the output REDIRECT_HEADER Uses the header location method
REDIRECT_HEADER is the default.
| Name | Type | Description |
|---|---|---|
| $url | string | The URL to redirect the client browser to. |
| $options | array | boolean | An array of options for the redirect OR indicates if redirect attempts should be counted and limited to 3 (latter is deprecated usage; use count_attempts in options array). |
| $type | string | The type of redirection to attempt (deprecated, use type in options array). |
| $responseCode | string | The type of HTTP response code HEADER to send for the redirect (deprecated, use responseCode in options array) |

sendUnauthorizedPage(
array $options
=
null
)
:
voidSend the user to the MODX unauthorized page.
| Name | Type | Description |
|---|---|---|
| $options | array | An array of options to provide for the OnPageUnauthorized event and unauthorized page. |
- Uses
- \invokeEvent()

setAttribute(
$attribute, $value
)
:
void| Name | Type | Description |
|---|---|---|
| $attribute | ||
| $value |
- See
- \http://php.net/manual/en/function.pdo-setattribute.php

setDebug(
boolean | int $debug
=
true
)
:
boolean | intSets the debugging features of the modX instance.
| Name | Type | Description |
|---|---|---|
| $debug | boolean | int | Boolean or bitwise integer describing the debug state and/or PHP error reporting level. |
| Type | Description |
|---|---|
| boolean | int | The previous value. |

setLogLevel(
integer $level
=
xPDO::LOG_LEVEL_FATAL
)
:
integer
| Name | Type | Description |
|---|---|---|
| $level | integer | The logging level to switch to. |
| Type | Description |
|---|---|
| integer | The previous log level. |

setLogTarget(
string $target
=
'ECHO'
)
:
mixed
Valid target values include:
- 'ECHO': Returns output to the STDOUT.
- 'HTML': Returns output to the STDOUT with HTML formatting.
- 'FILE': Sends output to a log file.
- An array with at least one element with key 'target' matching one of the valid log targets listed above. For 'target' => 'FILE' you can specify a second element with key 'options' with another associative array with one or both of the elements 'filename' and 'filepath'
| Name | Type | Description |
|---|---|---|
| $target | string | An identifier indicating the target of the logging. |
| Type | Description |
|---|---|
| mixed | The previous log target. |

setOption(
string $key, mixed $value
)
:
void
| Name | Type | Description |
|---|---|---|
| $key | string | The option key. |
| $value | mixed | A value to set for the given option key. |

setPackage(
string $pkg
=
'', string $path
=
'', string | null $prefix
=
null
)
:
boolSets a specific model package to use when looking up classes.
Inherited from: \xPDO::setPackage()This package is of the form package.subpackage.subsubpackage and will be added to the beginning of every xPDOObject class that is referenced in xPDO methods such as {@link xPDO::loadClass()}, {@link xPDO::getObject()}, {@link xPDO::getCollection()}, {@link xPDOObject::getOne()}, {@link xPDOObject::addOne()}, etc.
| Name | Type | Description |
|---|---|---|
| $pkg | string | A package name to use when looking up classes in xPDO. |
| $path | string | The root path for looking up classes in this package. |
| $prefix | string | null | Provide a string to define a package-specific table_prefix. |
| Type | Description |
|---|---|
| bool |

setPackageMeta(
string $pkg, string $path
=
''
)
:
boolAdds metadata information about a package and loads the xPDO::$classMap.
Inherited from: \xPDO::setPackageMeta()| Name | Type | Description |
|---|---|---|
| $pkg | string | A package name to use when looking up classes/maps in xPDO. |
| $path | string | The root path for looking up classes in this package. |
| Type | Description |
|---|---|
| bool |

setPlaceholder(
string $key, mixed $value
)
:
voidSets a placeholder value.
| Name | Type | Description |
|---|---|---|
| $key | string | The unique string key which identifies the placeholder. |
| $value | mixed | The value to set the placeholder to. |

setPlaceholders(
array | object $placeholders, string $namespace
=
''
)
:
voidSets a collection of placeholders stored in an array or as object vars.
An optional namespace parameter can be prepended to each placeholder key in the collection, to isolate the collection of placeholders.
Note that unlike toPlaceholders(), this function does not add separators between the namespace and the placeholder key. Use toPlaceholders() when working with multi-dimensional arrays or objects with variables other than scalars so each level gets delimited by a separator.
| Name | Type | Description |
|---|---|---|
| $placeholders | array | object | An array of values or object to set as placeholders. |
| $namespace | string | A namespace prefix to prepend to each placeholder key. |

stripTags(
string $html, string $allowed
=
'', array $patterns
=
array(), int $depth
=
10
)
:
booleanStrip unwanted HTML and PHP tags and supplied patterns from content.
| Name | Type | Description |
|---|---|---|
| $html | string | The string to strip |
| $allowed | string | An array of allowed HTML tags |
| $patterns | array | An array of patterns to sanitize with; otherwise will use modX::$sanitizePatterns |
| $depth | int | The depth in which the parser will strip given the patterns specified |
| Type | Description |
|---|---|
| boolean | True if anything was stripped |

switchContext(
string $contextKey, boolean $reload
=
false
)
:
booleanSwitches the primary Context for the modX instance.
Be aware that switching contexts does not allow custom session handling classes to be loaded. The gateway defines the session handling that is applied to a single request. To create a context with a custom session handler you must create a unique context gateway that initializes that context directly.
| Name | Type | Description |
|---|---|---|
| $contextKey | string | The key of the context to switch to. |
| $reload | boolean | Set to true to force the context data to be regenerated before being switched to. |
| Type | Description |
|---|---|
| boolean | True if the switch was successful, otherwise false. |

toCache(
string | \xPDOCriteria $signature, object $object, integer $lifetime
=
0, array $options
=
array()
)
:
boolean
| Name | Type | Description |
|---|---|---|
| $signature | string | \xPDOCriteria | A unique string or xPDOCriteria object representing the object. |
| $object | object | An object to place a representation of in the cache. |
| $lifetime | integer | An optional number of seconds the cached result will remain valid, with 0 meaning it will remain valid until replaced or removed. |
| $options | array | Various cache options. |
| Type | Description |
|---|---|
| boolean | Indicates if the object was successfully cached. |

toJSON(
array $array
)
:
string
| Name | Type | Description |
|---|---|---|
| $array | array | The PHP array to convert. |
| Type | Description |
|---|---|
| string | The JSON representation of the source array. |

toPlaceholder(
string $key, mixed $value, string $prefix
=
'', string $separator
=
'.', boolean $restore
=
false
)
:
arrayRecursively validates and sets placeholders appropriate to the value type passed.
| Name | Type | Description |
|---|---|---|
| $key | string | The key identifying the value. |
| $value | mixed | The value to set. |
| $prefix | string | A string prefix to prepend to the key. Recursive calls prepend the parent keys as well. |
| $separator | string | A separator placed in between the prefix and the key. Default is a dot or period: '.'. |
| $restore | boolean | Set to true if you want overwritten placeholder values returned. |
| Type | Description |
|---|---|
| array | A multi-dimensional array containing up to two elements: 'keys' which always contains an array of placeholder keys that were set, and optionally, if the restore parameter is true, 'restore' containing an array of placeholder values that were overwritten by the method. |

toPlaceholders(
array | object $subject, string $prefix
=
'', string $separator
=
'.', boolean $restore
=
false
)
:
arraySets placeholders from values stored in arrays and objects.
Each recursive level adds to the prefix, building an access path using an optional separator.
| Name | Type | Description |
|---|---|---|
| $subject | array | object | An array or object to process. |
| $prefix | string | An optional prefix to be prepended to the placeholder keys. Recursive calls prepend the parent keys. |
| $separator | string | A separator to place in between the prefixes and keys. Default is a dot or period: '.'. |
| $restore | boolean | Set to true if you want overwritten placeholder values returned. |
| Type | Description |
|---|---|
| array | A multi-dimensional array containing up to two elements: 'keys' which always contains an array of placeholder keys that were set, and optionally, if the restore parameter is true, 'restore' containing an array of placeholder values that were overwritten by the method. |

toQueryString(
array $parameters
=
array(), string $numPrefix
=
'', string $argSeparator
=
'&'
)
:
stringTurn an associative or numeric array into a valid query string.
| Name | Type | Description |
|---|---|---|
| $parameters | array | An associative or numeric-indexed array of parameters. |
| $numPrefix | string | A string prefix added to the numeric-indexed array keys. Ignored if associative array is used. |
| $argSeparator | string | The string used to separate arguments in the resulting query string. |
| Type | Description |
|---|---|
| string | A valid query string representing the parameters. |
- Static

unsetPlaceholder(
string $key
)
:
voidUnset a placeholder value by key.
| Name | Type | Description |
|---|---|---|
| $key | string | The key of the placeholder to unset. |

unsetPlaceholders(
string | array $keys
)
:
voidUnset multiple placeholders, either by prefix or an array of keys.
| Name | Type | Description |
|---|---|---|
| $keys | string | array | A string prefix or an array of keys indicating the placeholders to unset. |

updateCollection(
string $className, array $set, mixed $criteria
=
null
)
:
bool | intUpdate field values across a collection of xPDOObjects.
Inherited from: \xPDO::updateCollection()| Name | Type | Description |
|---|---|---|
| $className | string | Name of the class to update fields of. |
| $set | array | An associative array of field/value pairs representing the updates to make. |
| $criteria | mixed | An xPDOCriteria object or representation. |
| Type | Description |
|---|---|
| bool | int | The number of instances affected by the update or false on failure. |