core/model/modx/modx.class.php

Show: inherited
Table of Contents

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

Constant  MODX_CORE_PATH = dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR

\modSystemEvent

Package: modx

Represents a modEvent when invoking events.

Constants

Constant\const  MODE_NEW = 'new'

\const
For new creations of objects in model events
Constant\const  MODE_UPD = 'upd'

\const
For updating objects in model events

Properties

Propertypublicstring  $_output= ''

The current output for the event

Details
Type
string
Propertyprotectedboolean  $_propagate= 'true'

Whether or not to allow further execution of Plugins for this event

Default valuetrueDetails
Type
boolean
Propertypublicboolean  $activated= ''

Whether or not this event has been activated

Details
Type
boolean
Propertypublicstring  $activePlugin= ''''

The name of the active plugin being invoked

Default value''Details
Type
string
Deprecated
 
Propertypublicstring  $name= ''''

The name of the Event

Default value''Details
Type
string
Propertypublicarray  $params= ''

Any params passed to this event

Details
Type
array
Propertypublicstring  $propertySet= ''''

The name of the active property set for the invoked Event
Default value''Details
Type
string
Deprecated
 
Propertypublicmixed  $returnedValues= ''

Any returned values for this event

Details
Type
mixed

Methods

methodpublicalert( string $msg ) : void

Display a message to the user during the event.

Parameters
Name Type Description
$msg string

The message to display.

Details
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.  
methodpublicisPropagatable( ) : boolean

Returns whether the event will propagate or not.

Returns
Type Description
boolean
Details
Access
public  
methodpublicoutput( string $output ) : void

Render output from the event.

Parameters
Name Type Description
$output string

The output to render.

methodpublicresetEventObject( ) : void

Reset the event instance for reuse.

methodpublicstopPropagation( ) : void

Stop further execution of plugins for this event.

\modX

Package: 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

Constant  SESSION_STATE_UNAVAILABLE = -1

The parameter for when a session state is not able to be accessed

Const
SESSION_STATE_UNAVAILABLE  
Constant  SESSION_STATE_UNINITIALIZED = 0

The parameter for when a session has not yet been instantiated

Const
SESSION_STATE_UNINITIALIZED  
Constant  SESSION_STATE_INITIALIZED = 1

The parameter for when a session has been fully initialized

Const
SESSION_STATE_INITIALIZED  
Constant  SESSION_STATE_EXTERNAL = 2

The parameter marking when a session is being controlled by an external provider

Const
SESSION_STATE_EXTERNAL  
Constant  OPT_AUTO_CREATE_TABLES = 'auto_create_tables'
inheritedInherited from: \xPDO::OPT_AUTO_CREATE_TABLES
Inherited_from
\xPDO::OPT_AUTO_CREATE_TABLES  
Constant  OPT_BASE_CLASSES = 'base_classes'
inheritedInherited from: \xPDO::OPT_BASE_CLASSES
Inherited_from
\xPDO::OPT_BASE_CLASSES  
Constant  OPT_BASE_PACKAGES = 'base_packages'
inheritedInherited from: \xPDO::OPT_BASE_PACKAGES
Inherited_from
\xPDO::OPT_BASE_PACKAGES  
Constant  OPT_CACHE_COMPRESS = 'cache_compress'
inheritedInherited from: \xPDO::OPT_CACHE_COMPRESS
Inherited_from
\xPDO::OPT_CACHE_COMPRESS  
Constant  OPT_CACHE_DB = 'cache_db'
inheritedInherited from: \xPDO::OPT_CACHE_DB
Inherited_from
\xPDO::OPT_CACHE_DB  
Constant  OPT_CACHE_DB_COLLECTIONS = 'cache_db_collections'
inheritedInherited from: \xPDO::OPT_CACHE_DB_COLLECTIONS
Constant  OPT_CACHE_DB_OBJECTS_BY_PK = 'cache_db_objects_by_pk'
inheritedInherited from: \xPDO::OPT_CACHE_DB_OBJECTS_BY_PK
Constant  OPT_CACHE_DB_EXPIRES = 'cache_db_expires'
inheritedInherited from: \xPDO::OPT_CACHE_DB_EXPIRES
Inherited_from
\xPDO::OPT_CACHE_DB_EXPIRES  
Constant  OPT_CACHE_DB_HANDLER = 'cache_db_handler'
inheritedInherited from: \xPDO::OPT_CACHE_DB_HANDLER
Inherited_from
\xPDO::OPT_CACHE_DB_HANDLER  
Constant  OPT_CACHE_DB_SIG_CLASS = 'cache_db_sig_class'
inheritedInherited from: \xPDO::OPT_CACHE_DB_SIG_CLASS
Inherited_from
\xPDO::OPT_CACHE_DB_SIG_CLASS  
Constant  OPT_CACHE_DB_SIG_GRAPH = 'cache_db_sig_graph'
inheritedInherited from: \xPDO::OPT_CACHE_DB_SIG_GRAPH
Inherited_from
\xPDO::OPT_CACHE_DB_SIG_GRAPH  
Constant  OPT_CACHE_EXPIRES = 'cache_expires'
inheritedInherited from: \xPDO::OPT_CACHE_EXPIRES
Inherited_from
\xPDO::OPT_CACHE_EXPIRES  
Constant  OPT_CACHE_FORMAT = 'cache_format'
inheritedInherited from: \xPDO::OPT_CACHE_FORMAT
Inherited_from
\xPDO::OPT_CACHE_FORMAT  
Constant  OPT_CACHE_HANDLER = 'cache_handler'
inheritedInherited from: \xPDO::OPT_CACHE_HANDLER
Inherited_from
\xPDO::OPT_CACHE_HANDLER  
Constant  OPT_CACHE_KEY = 'cache_key'
inheritedInherited from: \xPDO::OPT_CACHE_KEY
Inherited_from
\xPDO::OPT_CACHE_KEY  
Constant  OPT_CACHE_PATH = 'cache_path'
inheritedInherited from: \xPDO::OPT_CACHE_PATH
Inherited_from
\xPDO::OPT_CACHE_PATH  
Constant  OPT_CACHE_PREFIX = 'cache_prefix'
inheritedInherited from: \xPDO::OPT_CACHE_PREFIX
Inherited_from
\xPDO::OPT_CACHE_PREFIX  
Constant  OPT_CACHE_ATTEMPTS = 'cache_attempts'
inheritedInherited from: \xPDO::OPT_CACHE_ATTEMPTS
Inherited_from
\xPDO::OPT_CACHE_ATTEMPTS  
Constant  OPT_CACHE_ATTEMPT_DELAY = 'cache_attempt_delay'
inheritedInherited from: \xPDO::OPT_CACHE_ATTEMPT_DELAY
Inherited_from
\xPDO::OPT_CACHE_ATTEMPT_DELAY  
Constant  OPT_CALLBACK_ON_REMOVE = 'callback_on_remove'
inheritedInherited from: \xPDO::OPT_CALLBACK_ON_REMOVE
Inherited_from
\xPDO::OPT_CALLBACK_ON_REMOVE  
Constant  OPT_CALLBACK_ON_SAVE = 'callback_on_save'
inheritedInherited from: \xPDO::OPT_CALLBACK_ON_SAVE
Inherited_from
\xPDO::OPT_CALLBACK_ON_SAVE  
Constant  OPT_CONNECTIONS = 'connections'
inheritedInherited from: \xPDO::OPT_CONNECTIONS
Inherited_from
\xPDO::OPT_CONNECTIONS  
Constant  OPT_CONN_INIT = 'connection_init'
inheritedInherited from: \xPDO::OPT_CONN_INIT
Inherited_from
\xPDO::OPT_CONN_INIT  
Constant  OPT_CONN_MUTABLE = 'connection_mutable'
inheritedInherited from: \xPDO::OPT_CONN_MUTABLE
Inherited_from
\xPDO::OPT_CONN_MUTABLE  
Constant  OPT_HYDRATE_FIELDS = 'hydrate_fields'
inheritedInherited from: \xPDO::OPT_HYDRATE_FIELDS
Inherited_from
\xPDO::OPT_HYDRATE_FIELDS  
Constant  OPT_HYDRATE_ADHOC_FIELDS = 'hydrate_adhoc_fields'
inheritedInherited from: \xPDO::OPT_HYDRATE_ADHOC_FIELDS
Constant  OPT_HYDRATE_RELATED_OBJECTS = 'hydrate_related_objects'
inheritedInherited from: \xPDO::OPT_HYDRATE_RELATED_OBJECTS
Constant  OPT_LOADER_CLASSES = 'loader_classes'
inherited

Inherited from: \xPDO::OPT_LOADER_CLASSES
Inherited_from
\xPDO::OPT_LOADER_CLASSES  
See
\call()  
Constant  OPT_ON_SET_STRIPSLASHES = 'on_set_stripslashes'
inheritedInherited from: \xPDO::OPT_ON_SET_STRIPSLASHES
Inherited_from
\xPDO::OPT_ON_SET_STRIPSLASHES  
Constant  OPT_SETUP = 'setup'
inheritedInherited from: \xPDO::OPT_SETUP
Inherited_from
\xPDO::OPT_SETUP  
Constant  OPT_TABLE_PREFIX = 'table_prefix'
inheritedInherited from: \xPDO::OPT_TABLE_PREFIX
Inherited_from
\xPDO::OPT_TABLE_PREFIX  
Constant  OPT_VALIDATE_ON_SAVE = 'validate_on_save'
inheritedInherited from: \xPDO::OPT_VALIDATE_ON_SAVE
Inherited_from
\xPDO::OPT_VALIDATE_ON_SAVE  
Constant  OPT_VALIDATOR_CLASS = 'validator_class'
inheritedInherited from: \xPDO::OPT_VALIDATOR_CLASS
Inherited_from
\xPDO::OPT_VALIDATOR_CLASS  
Constant  LOG_LEVEL_FATAL = 0
inheritedInherited from: \xPDO::LOG_LEVEL_FATAL
Inherited_from
\xPDO::LOG_LEVEL_FATAL  
Constant  LOG_LEVEL_ERROR = 1
inheritedInherited from: \xPDO::LOG_LEVEL_ERROR
Inherited_from
\xPDO::LOG_LEVEL_ERROR  
Constant  LOG_LEVEL_WARN = 2
inheritedInherited from: \xPDO::LOG_LEVEL_WARN
Inherited_from
\xPDO::LOG_LEVEL_WARN  
Constant  LOG_LEVEL_INFO = 3
inheritedInherited from: \xPDO::LOG_LEVEL_INFO
Inherited_from
\xPDO::LOG_LEVEL_INFO  
Constant  LOG_LEVEL_DEBUG = 4
inheritedInherited from: \xPDO::LOG_LEVEL_DEBUG
Inherited_from
\xPDO::LOG_LEVEL_DEBUG  
Constant  SCHEMA_VERSION = '1.1'
inheritedInherited from: \xPDO::SCHEMA_VERSION
Inherited_from
\xPDO::SCHEMA_VERSION  

Properties

Propertypublic\modSystemEvent  $Event= 'null'

Default valuenullDetails
Type
\modSystemEvent
Deprecated
 
Propertypublicboolean  $_cacheEnabled= 'false'
inherited

A global cache flag that can be used to enable/disable all xPDO caching.

All caching is disabled by default.Inherited from: \xPDO::$$_cacheEnabled
Default valuefalseDetails
Type
boolean
Access
public  
Inherited_from
\xPDO::$$_cacheEnabled  
Propertyprotectedarray  $_config= 'null'

A config array that stores the bootstrap settings.
Default valuenullDetails
Type
array
Propertyprivatearray  $_connections= 'array()'
inherited

PDO connections managed by this xPDO instance.Inherited from: \xPDO::$$_connections
Default valuearray()Details
Type
array
Inherited_from
\xPDO::$$_connections  
Propertyprotectedboolean  $_debug= 'false'
inherited

Indicates the debug state of this instance.

Default is false.Inherited from: \xPDO::$$_debug
Default valuefalseDetails
Type
boolean
Access
protected  
Inherited_from
\xPDO::$$_debug  
Propertypublicstring  $_escapeCharClose= ''''
inherited

Indicates the closing escape character used for a particular database engine.

Inherited from: \xPDO::$$_escapeCharClose
Default value''Details
Type
string
Access
public  
Inherited_from
\xPDO::$$_escapeCharClose  
Propertypublicstring  $_escapeCharOpen= ''''
inherited

Indicates the opening escape character used for a particular database engine.

Inherited from: \xPDO::$$_escapeCharOpen
Default value''Details
Type
string
Access
public  
Inherited_from
\xPDO::$$_escapeCharOpen  
Propertyprotectedboolean  $_initialized= 'false'

Indicates if modX has been successfully initialized for a modContext.
Default valuefalseDetails
Type
boolean
Propertyprotectedint  $_logSequence= '0'

The current log sequence
Default value0Details
Type
int
Propertypublicstring  $_quoteChar= '"'"'
inherited

Represents the character used for quoting strings for a particular driver.

Inherited from: \xPDO::$$_quoteChar
Default value"'"Details
Type
string
Inherited_from
\xPDO::$$_quoteChar  
Propertyprotectedinteger  $_sessionState= 'modX::SESSION_STATE_UNINITIALIZED'

An integer representing the session state of modX.
Default valuemodX::SESSION_STATE_UNINITIALIZEDDetails
Type
integer
Propertypublicarray  $_systemConfig= 'null'

A config array that stores the system-wide settings.
Default valuenullDetails
Type
array
Propertypublicarray  $_userConfig= 'array()'

A config array that stores the user settings.
Default valuearray()Details
Type
array
Propertypublicarray  $actionMap= 'null'

A map of actions registered to the manager interface.
Default valuenullDetails
Type
array
Propertypublicarray  $aliasMap= 'null'

A lookup listing of Resource alias values and associated Resource Ids
Default valuenullDetails
Type
array
Propertypublic\xPDOCacheManager  $cacheManager= 'null'
inherited

The cache service provider registered for this xPDO instance.Inherited from: \xPDO::$$cacheManager
Default valuenullDetails
Type
\xPDOCacheManager
Inherited_from
\xPDO::$$cacheManager  
Propertyprivatestring  $cachePath= 'null'
inherited

A root path for file-based caching services to use.Inherited from: \xPDO::$$cachePath
Default valuenullDetails
Type
string
Inherited_from
\xPDO::$$cachePath  
Propertypublic  $classMap= 'array()'
inheritedInherited from: \xPDO::$$classMap
Default valuearray()Details
Type
n/a
Inherited_from
\xPDO::$$classMap  
Propertypublicarray  $config= 'null'
inherited

Configuration options for the xPDO instance.Inherited from: \xPDO::$$config
Default valuenullDetails
Type
array
Inherited_from
\xPDO::$$config  
Propertypublic\xPDOConnection  $connection= 'null'
inherited

The current xPDOConnection for this xPDO instance.Inherited from: \xPDO::$$connection
Default valuenullDetails
Type
\xPDOConnection
Inherited_from
\xPDO::$$connection  
Propertypublicarray  $contentTypes= 'null'

Represents the modContentType instances that can be delivered by this modX deployment.
Default valuenullDetails
Type
array
Propertypublic\modContext  $context= 'null'

The Context represents a unique section of the site which this modX instance is controlling.
Default valuenullDetails
Type
\modContext
Propertypublicarray  $contexts= 'array()'

An array of secondary contexts loaded on demand.
Default valuearray()Details
Type
array
Propertypublic\modManagerController  $controller= 'null'

A controller object that represents a page in the manager
Default valuenullDetails
Type
\modManagerController
Propertypublicstring  $cultureKey= ''''

The preferred Culture key for the current request.
Default value''Details
Type
string
Propertypublicstring  $documentOutput= 'null'

Default valuenullDetails
Type
string
Deprecated
 
Propertypublic\xPDODriver  $driver= 'null'
inherited

An xPDODriver instance for the xPDOConnection instances to use.Inherited from: \xPDO::$$driver
Default valuenullDetails
Type
\xPDODriver
Inherited_from
\xPDO::$$driver  
Propertypublicarray  $elementCache= 'array ()'

A map of already processed Elements.
Default valuearray ()Details
Type
array
Propertypublic\modError  $error= 'null'

An error response class for the request
Default valuenullDetails
Type
\modError
Propertypublic\modErrorHandler|object  $errorHandler= 'null'

An error_handler for the modX instance.
Default valuenullDetails
Type
\modErrorHandler | object
Propertypublic\modSystemEvent  $event= 'null'

The current event being handled by modX.
Default valuenullDetails
Type
\modSystemEvent
Propertypublicarray  $eventMap= 'null'

A map of elements registered to specific events.
Default valuenullDetails
Type
array
Propertypublicint  $executedQueries= '0'
inherited

The number of direct DB queries executed during a request.Inherited from: \xPDO::$$executedQueries
Default value0Details
Type
int
Inherited_from
\xPDO::$$executedQueries  
Propertyprotectedarray  $instances= 'array()'
staticinherited

A static collection of xPDO instances.Inherited from: \xPDO::$$instances
Default valuearray()Details
Type
array
Inherited_from
\xPDO::$$instances  
Propertypublicarray  $jscripts= 'array ()'

An array of javascript content to be inserted into the BODY of an HTML resource.
Default valuearray ()Details
Type
array
Propertypublic\modLexicon  $lexicon= 'null'

Represents a localized dictionary of common words and phrases.
Default valuenullDetails
Type
\modLexicon
Propertypublicarray  $loadedjscripts= 'array ()'

An array of already loaded javascript/css code
Default valuearray ()Details
Type
array
Propertyprotectedinteger  $logLevel= 'xPDO::LOG_LEVEL_FATAL'
inherited

The logging level for the xPDO instance.Inherited from: \xPDO::$$logLevel
Default valuexPDO::LOG_LEVEL_FATALDetails
Type
integer
Inherited_from
\xPDO::$$logLevel  
Propertyprotectedstring  $logTarget= ''ECHO''
inherited

The default logging target for the xPDO instance.Inherited from: \xPDO::$$logTarget
Default value'ECHO'Details
Type
string
Inherited_from
\xPDO::$$logTarget  
Propertypublic\modMail  $mail= ''

Details
Type
\modMail
Propertypublic\xPDOManager  $manager= 'null'
inherited

{@link xPDOManager} instance, loaded only if needed to manage datasource containers, data structures, etc.

Inherited from: \xPDO::$$manager
Default valuenullDetails
Type
\xPDOManager
Access
public  
Inherited_from
\xPDO::$$manager  
Propertypublicarray  $map= 'array ()'
inherited

A map of data source meta data for all loaded classes.

Inherited from: \xPDO::$$map
Default valuearray ()Details
Type
array
Access
public  
Inherited_from
\xPDO::$$map  
Propertypublicstring  $package= ''''
inherited

A default package for specifying classes by name.

Inherited from: \xPDO::$$package
Default value''Details
Type
string
Access
public  
Inherited_from
\xPDO::$$package  
Propertypublicarray  $packages= 'array ()'
inherited

An array storing packages and package-specific information.

Inherited from: \xPDO::$$packages
Default valuearray ()Details
Type
array
Access
public  
Inherited_from
\xPDO::$$packages  
Propertypublic\modParser  $parser= 'null'

The modParser registered for this modX instance, responsible for content tag parsing, and loaded only on demand.
Default valuenullDetails
Type
\modParser
Propertypublic\PDO  $pdo= 'null'
inherited

A reference to the PDO instance used by the current xPDOConnection.Inherited from: \xPDO::$$pdo
Default valuenullDetails
Type
\PDO
Inherited_from
\xPDO::$$pdo  
Propertypublicarray  $placeholders= 'array ()'

An array of key=> value pairs that can be used by any Resource or Element.
Default valuearray ()Details
Type
array
Propertypublicarray  $pluginCache= 'array()'

An array of plugins that have been cached for execution
Default valuearray()Details
Type
array
Propertypublicarray  $processors= 'array()'

An array of loaded processors and their class name
Default valuearray()Details
Type
array
Propertypublicint  $queryTime= '0'
inherited

The amount of request handling time spent with DB queries.Inherited from: \xPDO::$$queryTime
Default value0Details
Type
int
Inherited_from
\xPDO::$$queryTime  
Propertypublic\modRegistry  $registry= ''

Details
Type
\modRegistry
Propertypublic\modRequest  $request= 'null'

Represents a web request and provides helper methods for dealing with request parameters and other attributes of a request.
Default valuenullDetails
Type
\modRequest
Propertypublic\modResource  $resource= 'null'

An instance of the current modResource controlling the request.
Default valuenullDetails
Type
\modResource
Used_by
\modFieldTag  
Propertypublicboolean  $resourceGenerated= 'false'

Indicates if the resource was generated during this request.
Default valuefalseDetails
Type
boolean
Propertypublicmixed  $resourceIdentifier= 'null'

The resource id or alias being requested.
Default valuenullDetails
Type
mixed
Propertypublicarray  $resourceListing= 'null'

A listing of site Resources and Context-specific meta data.
Default valuenullDetails
Type
array
Propertypublicarray  $resourceMap= 'null'

A hierarchy map of Resources.
Default valuenullDetails
Type
array
Propertypublicstring  $resourceMethod= 'null'

The method to use to locate the Resource, 'id' or 'alias'.
Default valuenullDetails
Type
string
Propertypublic\modResponse  $response= 'null'

Represents a web response, providing helper methods for managing response header attributes and the body containing the content of the response.
Default valuenullDetails
Type
\modResponse
Propertypublic\modRestClient  $rest= ''

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

An array of regex patterns regulary cleansed from content.
Default valuearray( 'scripts' => '@<script[^>]*?>.*?</script>@si', 'entities' => '@&#(\d+);@e', 'tags' => '@\[\[(.[^\[\[]*?)\]\]@si', )Details
Type
array
Propertypublicarray  $services= 'array ()'
An array of supplemental service classes for this modX instance.

Default valuearray ()Details
Type
array
Propertypublicarray  $sjscripts= 'array ()'

An array of javascript content to be inserted into the HEAD of an HTML resource.
Default valuearray ()Details
Type
array
Propertypublicarray  $sourceCache= 'array( 'modChunk' => array() ,'modSnippet' => array() ,'modTemplateVar' => array() )'

The elemnt source cache used for caching and preparing Element data
Default valuearray( 'modChunk' => array() ,'modSnippet' => array() ,'modTemplateVar' => array() )Details
Type
array
Propertypublicfloat  $startTime= '0'
inherited

Start time of the request, initialized when the constructor is called.Inherited from: \xPDO::$$startTime
Default value0Details
Type
float
Inherited_from
\xPDO::$$startTime  
Propertypublic\modUser  $user= 'null'

The current user object, if one is authenticated for the current request and context.
Default valuenullDetails
Type
\modUser
Propertypublicarray  $version= 'null'

Version information for this MODX deployment.
Default valuenullDetails
Type
array
Propertypublicstring  $virtualDir= ''

Stores the virtual path for a request to MODX if the friendly_alias_paths option is enabled.
Details
Type
string

Methods

methodpublic__construct( string $configPath = '', array $options = null, array $driverOptions = null ) : \modX

Construct a new modX instance.

This method is used to create a new xPDO object with a connection to a specific database container.

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

Returns
Type Description
\modX A new modX instance.
methodprivate_getFullTableName( string $baseTableName, boolean $includeDb = false ) : string
inherited

Adds the table prefix, and optionally database name, to a given table.

Inherited from: \xPDO::_getFullTableName()
Parameters
Name Type Description
$baseTableName string

The table name as specified in the object model.

$includeDb boolean

Qualify the table name with the database name.

Returns
Type Description
string The fully-qualified and quoted table name for the
methodprotected_getLogLevel( integer $level ) : string
inherited

Gets a logging level as a string representation.

Inherited from: \xPDO::_getLogLevel()
Parameters
Name Type Description
$level integer

The logging level to retrieve a string for.

Returns
Type Description
string The string representation of a valid logging level.
methodprotected_initContext( string $contextKey, boolean $regenerate = false,  $options = null ) : boolean

Loads a specified Context.

Merges any context settings with the modX::$config, and performs any other context specific initialization tasks.

Parameters
Name Type Description
$contextKey string

A context identifier.

$regenerate boolean

If true, force regeneration of the context even if already initialized.

$options
Returns
Type Description
boolean True if the context was properly initialized
Details
Access
protected  
methodprotected_initCulture( array | null $options = null ) : void

Initializes the culture settings.

Parameters
Name Type Description
$options array | null

Options for the culture initialization process.

methodprotected_initErrorHandler( array | null $options = null ) : void

Loads the error handler for this instance.

Parameters
Name Type Description
$options array | null

An array of options for the errorHandler.

methodprotected_initEventMap( string $contextKey ) : void

Populates the map of events and registered plugins for each.

Parameters
Name Type Description
$contextKey string

Context identifier.

methodprotected_initSession( array | null $options = null ) : void

Loads the session handler and starts the session.

Parameters
Name Type Description
$options array | null

Options to override Settings explicitly.

methodprotected_loadClass(  $class,  $fqn,  $included = false,  $path = '',  $transient = false ) : void
inherited

Inherited from: \xPDO::_loadClass()
Parameters
Name Type Description
$class
$fqn
$included
$path
$transient
methodprotected_loadConfig( ) : boolean

Loads the modX system configuration settings.

Returns
Type Description
boolean True if successful.
Details
Access
protected  
methodprotected_loadExtensionPackages( array | null $options = null ) : void

Loads any specified extension packages.

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

methodprotected_log( integer $level, string $msg, string $target = '', string $def = '', string $file = '', string $line = '' ) : void

Provides modX the ability to use modRegister instances as log targets.

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

methodprotected_logInRegister( \modRegister $register, int $level, string $msg, string $def, string $file, string $line ) : void

Provides custom logging functionality for modRegister targets.

Parameters
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

Details
Access
protected  
methodpublic_postProcess( ) : void

Executed after the response is sent and execution is completed.

Details
Access
protected  
methodpublicaddConnection( string $dsn, string $username = '', string $password = '', array $options = array(), null $driverOptions = null ) : boolean
inherited

Add an xPDOConnection instance to the xPDO connection pool.

Inherited from: \xPDO::addConnection()
Parameters
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.

Returns
Type Description
boolean True if a valid connection was added.
methodpublicaddDerivativeCriteria( string $className, \xPDOCriteria $criteria ) : void
inherited

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

Parameters
Name Type Description
$className string

A valid xPDOObject derivative table class.

$criteria \xPDOCriteria

A valid xPDOCriteria instance.

methodpublicaddEventListener( string $event, integer $pluginId ) : boolean

Add a plugin to the eventMap within the current execution cycle.

Parameters
Name Type Description
$event string

Name of the event.

$pluginId integer

Plugin identifier to add to the event.

Returns
Type Description
boolean true if the event is successfully added, otherwise false.
methodpublicaddExtensionPackage( string $name, string $path, array $options = array() ) : boolean

Add an extension package to MODX

Parameters
Name Type Description
$name string
$path string
$options array
Returns
Type Description
boolean
methodpublicaddPackage( string $pkg = '', string $path = '', string | null $prefix = null ) : bool
inherited

Adds a model package and base class path for including classes and/or maps from.

Inherited from: \xPDO::addPackage()
Parameters
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.

Returns
Type Description
bool
methodpublicbeforeProcessing( ) : void

Executed before parser processing of an element.

methodpublicbeforeRender( ) : void

Executed before the response is rendered.

methodpublicbeforeRequest( ) : void

Executed before the handleRequest function.

methodpublicbeginTransaction( ) : void
inherited

Inherited from: \xPDO::beginTransaction()
Details
See
\http://php.net/manual/en/function.pdo-begintransaction.php  
methodpubliccall( string $class, string $method, array $args = array(), boolean $transient = false ) : mixed | null
inherited

Call a static method from a valid package class with arguments.

Inherited from: \xPDO::call()

Will always search for database-specific class files first.

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

Returns
Type Description
mixed | null The callback method's return value or null if no valid method is found.
methodpubliccheckForLocks( integer $id, string $action, string $type ) : string | boolean

Checks for locking on a page.

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

Returns
Type Description
string | boolean If locked, will return a locked message
methodpubliccheckSession( string $sessionContext = 'web' ) : boolean

Checks to see if the user has a session in the specified context.

Parameters
Name Type Description
$sessionContext string

The context to test for a session key in.

Returns
Type Description
boolean True if the user is valid in the context specified.
methodpubliccheckSiteStatus( ) : boolean

Determines the current site_status.

Returns
Type Description
boolean True if the site is online or the user has a valid user session in the 'mgr' context; false otherwise.
methodpubliccommit( ) : void
inherited

Inherited from: \xPDO::commit()
Details
See
\http://php.net/manual/en/function.pdo-commit.php  
methodpublicconnect( array $driverOptions = array (),  $options = array() ) : boolean
inherited

Get or create a PDO connection to a database specified in the configuration.

Inherited from: \xPDO::connect()
Parameters
Name Type Description
$driverOptions array

An optional array of driver options to use when creating the connection.

$options
Returns
Type Description
boolean Returns true if the PDO connection was created successfully.
methodpublicerrorCode( ) : void
inherited

Inherited from: \xPDO::errorCode()
Details
See
\http://php.net/manual/en/function.pdo-errorcode.php  
methodpublicerrorInfo( ) : void
inherited

Inherited from: \xPDO::errorInfo()
Details
See
\http://php.net/manual/en/function.pdo-errorinfo.php  
methodpublicescSplit( string $char, string $str, string $escToken = '`', integer $limit = 0 ) : array
staticinherited

Splits a string on a specified character, ignoring escaped content.

Inherited from: \xPDO::escSplit()
Parameters
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.

Returns
Type Description
array An array of results from the split operation, or an empty array.
Details
Static
 
methodpublicescape( string $string ) : string
inherited

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

Parameters
Name Type Description
$string string

A string to escape using the platform-specific escape characters.

Returns
Type Description
string The string escaped with the platform-specific escape characters.
methodpublicexec(  $query ) : void
inherited

Inherited from: \xPDO::exec()
Parameters
Name Type Description
$query
Details
See
\http://php.net/manual/en/function.pdo-exec.php  
methodpublicfromCache( string | \xPDOCriteria $signature, string $class = '', array $options = array() ) : array | string | null
inherited

Retrieves a result array from the object cache.

Inherited from: \xPDO::fromCache()
Parameters
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.

Returns
Type Description
array | string | null A PHP array or JSON object representing the result set, or null if no cache representation is found.
methodpublicfromJSON( string $src, boolean $asArray = true ) : mixed
inherited

Converts a JSON source string into an equivalent PHP representation.

Inherited from: \xPDO::fromJSON()
Parameters
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.

Returns
Type Description
mixed The PHP representation of the JSON source.
methodpublicgetAggregates( string $className ) : array
inherited

Gets a collection of aggregate foreign key relationship definitions.

Inherited from: \xPDO::getAggregates()
Parameters
Name Type Description
$className string

The fully-qualified name of the class.

Returns
Type Description
array An array of aggregate foreign key relationship definitions.
methodpublicgetAncestry( string $className, boolean $includeSelf = true ) : array
inherited

Retrieves the complete ancestry for a class.

Inherited from: \xPDO::getAncestry()
Parameters
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.

Returns
Type Description
array An array of string class names representing the class hierarchy, or an empty array if unsuccessful.
methodpublicgetAttribute(  $attribute ) : void
inherited

Inherited from: \xPDO::getAttribute()
Parameters
Name Type Description
$attribute
Details
See
\http://php.net/manual/en/function.pdo-getattribute.php  
methodpublicgetAuthenticatedUser( string $contextKey = '' ) : \modUser | null

Gets the user authenticated in the specified context.

Parameters
Name Type Description
$contextKey string

Optional context key; uses current context by default.

Returns
Type Description
\modUser | null The user object that is authenticated in the specified context, or null if no user is authenticated.
methodpublicgetCacheManager( string $class = 'cache.xPDOCacheManager', array $options = array('path' => XPDO_CORE_PATH, 'ignorePkg' => true) ) : \modCacheManager

Get an extended xPDOCacheManager instance responsible for MODX caching.

This class is responsible for handling all types of caching operations for the xPDO core.

Parameters
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

Returns
Type Description
\modCacheManager A modCacheManager instance registered for this modX instance.
methodpublicgetCachePath( ) : string
inherited

Gets the absolute path to the cache directory.

Inherited from: \xPDO::getCachePath()
Returns
Type Description
string The full cache directory path.
methodpublicgetChildIds( integer $id = null, integer $depth = 10, array $options = array() ) : array

Gets all of the child resource ids for a given resource.

Parameters
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

Returns
Type Description
array An array of all the child resource ids for the specified resource.
Details
See
\getTree  
methodpublicgetChunk( string $chunkName, array $properties = array () ) : string

Process and return the output from a Chunk by name.

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

Returns
Type Description
string The processed output of the Chunk.
methodpublicgetCollection( string $className, object | array | string $criteria = null, mixed $cacheFlag = true ) : array | null
inherited

Retrieves a collection of xPDOObjects by the specified xPDOCriteria.

Inherited from: \xPDO::getCollection()
Parameters
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.

Returns
Type Description
array | null An array of class instances retrieved.
Details
Uses
\xPDOObject::loadCollection()  
methodpublicgetCollectionGraph( string $className, string | array $graph, mixed $criteria = null, boolean $cacheFlag = true ) : array
inherited

Retrieves a collection of xPDOObject instances with related objects.

Inherited from: \xPDO::getCollectionGraph()
Parameters
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.

Returns
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.
Details
Uses
\xPDOQuery::bindGraph()  
methodpublicgetComposites( string $className ) : array
inherited

Gets a collection of composite foreign key relationship definitions.

Inherited from: \xPDO::getComposites()
Parameters
Name Type Description
$className string

The fully-qualified name of the class.

Returns
Type Description
array An array of composite foreign key relationship definitions.
methodpublicgetConfig( ) : array

Get the configuration for the site.

Returns
Type Description
array An associate array of configuration key/values
methodpublicgetConnection( array $options = array() ) : \xPDOConnection | null
inherited

Get an xPDOConnection from the xPDO connection pool.

Inherited from: \xPDO::getConnection()
Parameters
Name Type Description
$options array

An array of options for getting the connection.

Returns
Type Description
\xPDOConnection | null An xPDOConnection instance or null if no connection could be retrieved.
methodpublicgetContext( string $contextKey ) : \modContext

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

Parameters
Name Type Description
$contextKey string

The context to retrieve.

Returns
Type Description
\modContext A modContext object retrieved from cache or database.
Details
Access
public  
methodpublicgetCount( string $className, mixed $criteria = null ) : integer
inherited

Retrieves a count of xPDOObjects by the specified xPDOCriteria.

Inherited from: \xPDO::getCount()
Parameters
Name Type Description
$className string

Class of xPDOObject to count instances of.

$criteria mixed

Any valid xPDOCriteria object or expression.

Returns
Type Description
integer The number of instances found by the criteria.
methodpublicgetCriteria( string $className, string $type = null, boolean | integer $cacheFlag = true ) : \xPDOCriteria
inherited

Convert any valid criteria into an xPDOQuery instance.

Inherited from: \xPDO::getCriteria()
Parameters
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.

Returns
Type Description
\xPDOCriteria A criteria object or null if not found.
methodpublicgetCriteriaType( mixed $criteria ) : string | null
inherited

Validate and return the type of a specified criteria variable.

Inherited from: \xPDO::getCriteriaType()
Parameters
Name Type Description
$criteria mixed

An xPDOCriteria instance or any valid criteria variable.

Returns
Type Description
string | null The type of valid criteria passed, or null if the criteria is not valid.
methodpublicgetDebug( ) : boolean
inherited

Returns the debug state for the xPDO instance.

Inherited from: \xPDO::getDebug()
Returns
Type Description
boolean The current debug state for the instance, true for on, false for off.
methodpublicgetDebugBacktrace( ) : array
inherited

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

Returns
Type Description
array The abbreviated backtrace.
methodpublicgetDescendants( string $className ) : array
inherited

Gets a list of derivative classes for the specified xPDOObject instance.

Inherited from: \xPDO::getDescendants()

NOTE: Will not work with xPDOObject/xPDOSimpleObject.

Parameters
Name Type Description
$className string

The name of the class to retrieve derivatives for.

Returns
Type Description
array An array of derivative classes or an empty array.
methodpublicgetDriver( ) : \xPDODriver | null
inherited

Gets the driver class for this xPDO connection.

Inherited from: \xPDO::getDriver()

The driver class provides baseline data and operations for a specific database driver.

Returns
Type Description
\xPDODriver | null An xPDODriver instance for the xPDO connection, or null if a driver class can not be instantiated.
methodpublicgetEventMap( string $contextKey ) : array

Gets 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

Parameters
Name Type Description
$contextKey string

Context identifier.

Returns
Type Description
array A map of events and registered plugins for each.
methodpublicgetFKDefinition( string $parentClass, string $alias ) : array
inherited

Gets an aggregate or composite relation definition from a class.

Inherited from: \xPDO::getFKDefinition()
Parameters
Name Type Description
$parentClass string

The class from which the relation is defined.

$alias string

The alias identifying the related class.

Returns
Type Description
array The aggregate or composite definition details in an array or null if no definition is found.
methodpublicgetFieldAliases( string $className ) : array
inherited

Gets a collection of field aliases for an object by class name.

Inherited from: \xPDO::getFieldAliases()
Parameters
Name Type Description
$className string

The name of the class to lookup field aliases for.

Returns
Type Description
array An array of field aliases with aliases as keys and actual field names as values.
methodpublicgetFieldMeta( string $className, boolean $includeExtended = false ) : array
inherited

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

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

Returns
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.
methodpublicgetFields( string $className ) : array
inherited

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

Parameters
Name Type Description
$className string

The name of the class to lookup fields for.

Returns
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.
methodpublicgetGraph( string $className, int $depth = 3, array $parents = array(), array $visited = array() ) : array
inherited

Get a complete relation graph for an xPDOObject class.

Inherited from: \xPDO::getGraph()
Parameters
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.

Returns
Type Description
array An xPDOObject relation graph, or an empty array if no graph can be constructed.
methodpublicgetIndexMeta( string $className ) : array
inherited

Get indices defined for a table class.

Inherited from: \xPDO::getIndexMeta()
Parameters
Name Type Description
$className string

The name of the class to lookup indices for.

Returns
Type Description
array An array of indices and their details for the specified class.
methodpublicgetInherit( \$className $className ) : string
inherited

Indicates the inheritance model for the xPDOObject class specified.

Inherited from: \xPDO::getInherit()
Parameters
Name Type Description
$className \$className

The class to determine the table inherit type from.

Returns
Type Description
string single, multiple, or none
methodpublicgetInstance( string | int | null $id = null, array | null $config = null, bool $forceNew = false ) : \modX
static

Create, retrieve, or update specific modX instances.

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

Returns
Type Description
\modX An instance of modX.
Throws
Exception Description
\xPDOException
Details
Static
 
methodpublicgetIterator( string $className, mixed $criteria = null, bool $cacheFlag = true ) : \xPDOIterator
inherited

Retrieves an iterable representation of a collection of xPDOObjects.

Inherited from: \xPDO::getIterator()
Parameters
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.

Returns
Type Description
\xPDOIterator An iterable representation of a collection.
methodpublicgetLogLevel( ) : integer
inherited

Inherited from: \xPDO::getLogLevel()
Returns
Type Description
integer The current log level.
methodpublicgetLogTarget( ) : integer
inherited

Inherited from: \xPDO::getLogTarget()
Returns
Type Description
integer The current log level.
methodpublicgetLoginUserID( string $context = '' ) : integer

Returns the current user ID, for the current or specified context.

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

Returns
Type Description
integer The ID of the current user.
methodpublicgetLoginUserName( string $context = '' ) : string

Returns the current user name, for the current or specified context.

Parameters
Name Type Description
$context string

The key of a valid modContext so you can retrieve the username from a different context than the current.

Returns
Type Description
string The username of the current user.
methodpublicgetManager( ) : \xPDOManager | null
inherited

Gets the manager class for this xPDO connection.

Inherited from: \xPDO::getManager()

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.

Returns
Type Description
\xPDOManager | null An xPDOManager instance for the xPDO connection, or null if a manager class can not be instantiated.
methodpublicgetMicroTime( ) : float
inherited

Convert current microtime() result into seconds.

Inherited from: \xPDO::getMicroTime()
Returns
Type Description
float
methodpublicgetModelVersion( string $className ) : string
inherited

Gets the version string of the schema the specified class was generated from.

Inherited from: \xPDO::getModelVersion()
Parameters
Name Type Description
$className string

The name of the class to get the model version from.

Returns
Type Description
string The version string for the schema model the class was generated from.
methodpublicgetObject( string $className, mixed $criteria = null, mixed $cacheFlag = true ) : object | null
inherited

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

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

Returns
Type Description
object | null An instance of the class, or null if it could not be instantiated.
Details
Uses
\xPDOObject::load()  
methodpublicgetObjectGraph( string $className, string | array $graph, mixed $criteria = null, boolean | integer $cacheFlag = true ) : object
inherited

Retrieves an xPDOObject instance with specified related objects.

Inherited from: \xPDO::getObjectGraph()
Parameters
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.

Returns
Type Description
object The object instance with related objects from the graph hydrated, or null if no instance can be located by the criteria.
Details
Uses
\xPDO::getCollectionGraph()  
methodpublicgetObjectLoader( string $className, string $method ) : \callable
inherited

Finds the class responsible for loading instances of the specified class.

Inherited from: \xPDO::getObjectLoader()
Parameters
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).

Returns
Type Description
\callable A callable loader function.
methodpublicgetOption( string $key, array $options = null, mixed $default = null,  $skipEmpty = false ) : mixed
inherited

Get an xPDO configuration option value by key.

Inherited from: \xPDO::getOption()
Parameters
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
Returns
Type Description
mixed The configuration option value.
methodpublicgetPDOType( mixed $value ) : int | null
inherited

Get the appropriate PDO::PARAM_ type constant from a PHP value.

Inherited from: \xPDO::getPDOType()
Parameters
Name Type Description
$value mixed

Any PHP scalar or null value

Returns
Type Description
int | null
methodpublicgetPK( string $className ) : mixed
inherited

Gets the primary key field(s) for a class.

Inherited from: \xPDO::getPK()
Parameters
Name Type Description
$className string

The name of the class to lookup the primary key for.

Returns
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.
methodpublicgetPKType( string $className,  $pk = false ) : string
inherited

Gets the type of primary key field for a class.

Inherited from: \xPDO::getPKType()
Parameters
Name Type Description
$className string

className The name of the class to lookup the primary key type for.

$pk
Returns
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.
methodpublicgetPackage( string $className ) : string
inherited

Gets the package name from a specified class name.

Inherited from: \xPDO::getPackage()
Parameters
Name Type Description
$className string

The name of the class to lookup the package for.

Returns
Type Description
string The package the class belongs to.
methodpublicgetParentIds( integer $id = null, integer $height = 10, array $options = array() ) : array

Gets all of the parent resource ids for a given resource.

Parameters
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

Returns
Type Description
array An array of all the parent resource ids for the specified resource.
methodpublicgetParser( ) : \modParser

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

Returns
Type Description
\modParser The modParser for this modX instance.
methodpublicgetPlaceholder( string $key ) : mixed

Get a placeholder value by key.

Parameters
Name Type Description
$key string

The key of the placeholder to a return a value from.

Returns
Type Description
mixed The value of the requested placeholder, or an empty string if not located.
Details
Used_by
\modPlaceholderTag  
methodpublicgetRegisteredClientScripts( ) : string

Returns all registered JavaScripts.

Returns
Type Description
string The parsed HTML of the client scripts.
Details
Access
public  
methodpublicgetRegisteredClientStartupScripts( ) : string

Returns all registered startup CSS, JavaScript, or HTML blocks.

Returns
Type Description
string The parsed HTML of the startup scripts.
Details
Access
public  
methodpublicgetRequest( string $class = 'modRequest', string $path = '' ) : boolean

Attempt to load the request handler class, if not already loaded.

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

Returns
Type Description
boolean Returns true if a valid request handler object was loaded on this or any previous call to the function, false otherwise.
Details
Access
public  
methodpublicgetResponse( string $class = 'modResponse', string $path = '' ) : boolean

Attempt to load the response handler class, if not already loaded.

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

Returns
Type Description
boolean Returns true if a valid response handler object was loaded on this or any previous call to the function, false otherwise.
Details
Access
public  
methodpublicgetSelectColumns( string $className, string $tableAlias = '', string $columnPrefix = '', array $columns = array (), boolean $exclude = false ) : string
inherited

Gets select columns from a specific class for building a query.

Inherited from: \xPDO::getSelectColumns()
Parameters
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.

Returns
Type Description
string A valid SQL string of column names for a SELECT statement.
Details
Uses
\xPDOObject::getSelectColumns()  
methodpublicgetService( string $name, string $class = '', string $path = '', array $params = array () ) : object | null
inherited

Load and return a named service class instance.

Inherited from: \xPDO::getService()
Parameters
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.

Returns
Type Description
object | null A reference to the service class instance or null if it could not be loaded.
methodpublicgetSessionState( ) : integer

Returns 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

Returns
Type Description
integer Returns an integer representing the session state.
methodpublicgetTableClass( string $className ) : null | string
inherited

Get the class which defines the table for a specified className.

Inherited from: \xPDO::getTableClass()
Parameters
Name Type Description
$className string

The name of a class to determine the table class from.

Returns
Type Description
null | string The name of a class defining the table for the specified className; null if not found.
methodpublicgetTableMeta( string $className ) : string
inherited

Gets the actual run-time table metadata from a specified class name.

Inherited from: \xPDO::getTableMeta()
Parameters
Name Type Description
$className string

The name of the class to lookup a table name for.

Returns
Type Description
string The table meta data for the class, or null if unsuccessful.
methodpublicgetTableName( string $className, boolean $includeDb = false ) : string
inherited

Gets the actual run-time table name from a specified class name.

Inherited from: \xPDO::getTableName()
Parameters
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.

Returns
Type Description
string The table name for the class, or null if unsuccessful.
methodpublicgetTree( int | array $id = null, int $depth = 10 ) : array

Get a site tree from a single or multiple modResource instances.

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

Returns
Type Description
array An array containing the tree structure.
Details
See
\getChildIds  
methodpublicgetUser( string $contextKey = '', boolean $forceLoadSettings = false ) : \modUser

Get the current authenticated User and assigns it to the modX instance.

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

Returns
Type Description
\modUser The user object authenticated for the request.
methodpublicgetValidationRules( string $className ) : array
inherited

Gets a set of validation rules defined for an object by class name.

Inherited from: \xPDO::getValidationRules()
Parameters
Name Type Description
$className string

The name of the class to lookup validation rules for.

Returns
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.
methodpublicgetValue( \PDOStatement $stmt, null | integer $column = null ) : mixed
inherited

Execute a PDOStatement and get a single column value from the first row of the result set.

Inherited from: \xPDO::getValue()
Parameters
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.

Returns
Type Description
mixed The value of the specified column from the first row of the result set, or null.
methodpublicgetVersionData( ) : array

Gets the modX core version data.

Returns
Type Description
array The version data loaded from the config version file.
methodpublichandleRequest( ) : mixed

Initialize, cleanse, and process a request made to a modX site.

Returns
Type Description
mixed The result of the request handler.
methodpublichasPermission( string $pm ) : boolean

Returns true if user has the specified policy permission.

Parameters
Name Type Description
$pm string

Permission key to check.

Returns
Type Description
boolean
methodprotectedinitConfig( string | array $data ) : array
inherited

Initialize an xPDO config array.

Inherited from: \xPDO::initConfig()
Parameters
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).

Returns
Type Description
array An array of xPDO config data.
methodpublicinitialize( string $contextKey = 'web', array | null $options = null ) : bool

Initializes 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

Parameters
Name Type Description
$contextKey string

Indicates the context to initialize.

$options array | null

An array of options for the initialization.

Returns
Type Description
bool True if initialized successfully, or already initialized.
methodpublicinvokeEvent( string $eventName, array $params = array () ) : boolean

Invokes a specified Event with an optional array of parameters.

Parameters
Name Type Description
$eventName string

Name of an event to invoke.

$params array

Optional params provided to the elements registered with an event.

Returns
Type Description
boolean
Details
Access
public  
Todo
refactor this completely, yuck!!  
methodpublicisInitialized( ) : boolean

Returns whether modX instance has been initialized or not.

Returns
Type Description
boolean
Details
Access
public  
methodpubliclastInsertId( ) : void
inherited

Inherited from: \xPDO::lastInsertId()
Details
See
\http://php.net/manual/en/function.pdo-lastinsertid.php  
methodpubliclexicon( string $key, array $params = array(), string $language = '' ) : null | string

Grabs a processed lexicon string.

Parameters
Name Type Description
$key string
$params array
$language string
Returns
Type Description
null | string The translated string, or null if none is set
Details
Access
public  
methodpublicliteral( string $string ) : string
inherited

Use to insert a literal string into a SQL query without escaping or quoting.

Inherited from: \xPDO::literal()
Parameters
Name Type Description
$string string

A string to return as a literal, unescaped and unquoted.

Returns
Type Description
string The string with any escape or quote characters trimmed.
methodpublicloadClass( string $fqn,  $path = '',  $ignorePkg = false,  $transient = false ) : string | boolean
inherited

Load a class by fully qualified name.

Inherited from: \xPDO::loadClass()

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

Parameters
Name Type Description
$fqn string

The fully-qualified name of the class to load.

$path
$ignorePkg
$transient
Returns
Type Description
string | boolean The actual classname if successful, or false if not.
methodprotectedloadConfig( string $configPath = '', array $data = array(), null $driverOptions = null ) : array

Load the modX configuration when creating an instance of modX.

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

Returns
Type Description
array The merged config data ready for use by the modX::__construct() method.
methodpubliclog( integer $level, string $msg, string $target = '', string $def = '', string $file = '', string $line = '' ) : void
inherited

Log a message with details about where and when an event occurs.

Inherited from: \xPDO::log()
Parameters
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.

methodpubliclogManagerAction( string $action, string $class_key, mixed $item ) : \modManagerLog

Logs a manager action.

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

Returns
Type Description
\modManagerLog The newly created modManagerLog object.
methodpublicmakeUrl( integer $id, string $context = '', string $args = '', mixed $scheme = -1, array $options = array() ) : string

Generates a URL representing a specified resource.

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

Returns
Type Description
string The URL for the resource.
methodpublicmessageQuit( string $msg = 'unspecified error', string $query = '', bool $is_error = true, string $nr = '', string $file = '', string $source = '', string $text = '', string $line = '' ) : void

Legacy fatal error message.

Parameters
Name Type Description
$msg string
$query string
$is_error bool
$nr string
$file string
$source string
$text string
$line string
Details
Deprecated
 
methodpublicnewObject( string $className, array $fields = array () ) : object | null
inherited

Creates a new instance of a specified class.

Inherited from: \xPDO::newObject()

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.

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

Returns
Type Description
object | null A new instance of the specified class, or null if a new object could not be instantiated.
methodpublicnewQuery( string $class, mixed $criteria = null, boolean | integer $cacheFlag = true ) : \xPDOQuery
inherited

Creates an new xPDOQuery for a specified xPDOObject class.

Inherited from: \xPDO::newQuery()
Parameters
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).

Returns
Type Description
\xPDOQuery The resulting xPDOQuery instance or false if unsuccessful.
methodpublicparseBindings( string $sql, array $bindings ) : string
inherited

Parses parameter bindings in SQL prepared statements.

Inherited from: \xPDO::parseBindings()
Parameters
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.

Returns
Type Description
string The SQL with the binding placeholders replaced.
methodpublicparseChunk( string $chunkName, array $chunkArr, string $prefix = '[[+', string $suffix = ']]' ) : string

Parse a chunk using an associative array of replacement variables.

Parameters
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 ]].

Returns
Type Description
string The processed chunk with the placeholders replaced.
methodpublicparseDSN( string $string ) : array
staticinherited

Parses a DSN and returns an array of the connection details.

Inherited from: \xPDO::parseDSN()
Parameters
Name Type Description
$string string

The DSN to parse.

Returns
Type Description
array An array of connection details from the DSN.
Details
Static
 
methodpublicprepare(  $statement,  $driver_options = array () ) : void
inherited

Inherited from: \xPDO::prepare()
Parameters
Name Type Description
$statement
$driver_options
Details
See
\http://php.net/manual/en/function.pdo-prepare.php  
methodpublicprotect( ) : void
static

Harden the environment against common security flaws.

Details
Static
 
methodpublicquery(  $query ) : void
inherited

Inherited from: \xPDO::query()
Parameters
Name Type Description
$query
Details
See
\http://php.net/manual/en/function.pdo-query.php  
methodpublicquote(  $string,  $parameter_type = PDO::PARAM_STR ) : void
inherited

Inherited from: \xPDO::quote()
Parameters
Name Type Description
$string
$parameter_type
Details
See
\http://php.net/manual/en/function.pdo-quote.php  
methodpublicregClientCSS( string $src ) : void

Register CSS to be injected inside the HEAD tag of a resource.

Parameters
Name Type Description
$src string

The CSS to be injected before the closing HEAD tag in an HTML response.

methodpublicregClientHTMLBlock( string $html ) : void

Register HTML to be injected before the closing BODY tag.

Parameters
Name Type Description
$html string

The HTML to be injected.

methodpublicregClientScript( string $src, boolean $plaintext = false ) : void

Register JavaScript to be injected before the closing BODY tag.

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

methodpublicregClientStartupHTMLBlock( string $html ) : void

Register HTML to be injected before the closing HEAD tag.

Parameters
Name Type Description
$html string

The HTML to be injected.

methodpublicregClientStartupScript( string $src, boolean $plaintext = false ) : void

Register JavaScript to be injected inside the HEAD tag of a resource.

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

methodpublicreloadConfig( ) : array

Reload the config settings.

Returns
Type Description
array An associative array of configuration key/values
methodpublicreloadContext( string $key = null ) : boolean

Reload data for a specified Context, without switching to it.

Note that the Context will be loaded even if it is not already.

Parameters
Name Type Description
$key string

The key of the Context to (re)load.

Returns
Type Description
boolean True if the Context was (re)loaded successfully; false otherwise.
methodpublicremoveAllEventListener( ) : void

Remove all registered events for the current request.

methodpublicremoveCollection( string $className, mixed $criteria ) : boolean | integer
inherited

Remove a collection of instances by the supplied className and criteria.

Inherited from: \xPDO::removeCollection()
Parameters
Name Type Description
$className string

The name of the class to remove a collection of.

$criteria mixed

Valid xPDO criteria for selecting a collection.

Returns
Type Description
boolean | integer False if the remove encounters an error, otherwise an integer value representing the number of rows that were removed.
methodpublicremoveEventListener( string $event ) : boolean

Remove an event from the eventMap so it will not be invoked.

Parameters
Name Type Description
$event string
Returns
Type Description
boolean false if the event parameter is not specified or is not present in the eventMap.
methodpublicremoveExtensionPackage( string $name ) : boolean

Remove an extension package from MODX

Parameters
Name Type Description
$name string
Returns
Type Description
boolean
methodpublicremoveObject( string $className, mixed $criteria ) : boolean
inherited

Remove an instance of the specified className by a supplied criteria.

Inherited from: \xPDO::removeObject()
Parameters
Name Type Description
$className string

The name of the class to remove an instance of.

$criteria mixed

Valid xPDO criteria for selecting an instance.

Returns
Type Description
boolean True if the instance is successfully removed.
methodpublicrollBack( ) : void
inherited

Inherited from: \xPDO::rollBack()
Details
See
\http://php.net/manual/en/function.pdo-rollback.php  
methodpublicrunProcessor( string $action = '', array $scriptProperties = array(), array $options = array() ) : mixed

Loads and runs a specific processor.

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

Returns
Type Description
mixed The result of the processor.
methodpublicrunSnippet( string $snippetName, array $params = array () ) : string

Process and return the output from a PHP snippet by name.

Parameters
Name Type Description
$snippetName string

The name of the snippet.

$params array

An associative array of properties to pass to the snippet.

Returns
Type Description
string The processed output of the snippet.
methodpublicsanitize( array $target, array | string $patterns = array(), integer $depth = 3, integer $nesting = 10 ) : array
static

Sanitize values of an array using regular expression patterns.

Parameters
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

Returns
Type Description
array The sanitized array.
Details
Static
 
methodpublicsanitizeString( string $str, array $chars = array('/',"'",'"','(',')',';','>','<'), string $allowedTags = '' ) : string

Sanitizes a string

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

Returns
Type Description
string The sanitized string.
methodpublicsendError( string $type = '', array $options = array() ) : void

Send the user to a type-specific core error page and halt PHP execution.

Parameters
Name Type Description
$type string

The type of error to present.

$options array

An array of options to provide for the error file.

methodpublicsendErrorPage( array $options = null ) : void

Send the user to a MODX virtual error page.

Parameters
Name Type Description
$options array

An array of options to provide for the OnPageNotFound event and error page.

Details
Uses
\invokeEvent()  
methodpublicsendForward( integer $id, string $options = null ) : void

Forwards the request to another resource without changing the URL.

Parameters
Name Type Description
$id integer

The resource identifier.

$options string

An array of options for the process.

methodpublicsendRedirect( string $url, array | boolean $options = false, string $type = '', string $responseCode = '' ) : void

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

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

methodpublicsendUnauthorizedPage( array $options = null ) : void

Send the user to the MODX unauthorized page.

Parameters
Name Type Description
$options array

An array of options to provide for the OnPageUnauthorized event and unauthorized page.

Details
Uses
\invokeEvent()  
methodpublicsetAttribute(  $attribute,  $value ) : void
inherited

Inherited from: \xPDO::setAttribute()
Parameters
Name Type Description
$attribute
$value
Details
See
\http://php.net/manual/en/function.pdo-setattribute.php  
methodpublicsetDebug( boolean | int $debug = true ) : boolean | int

Sets the debugging features of the modX instance.

Parameters
Name Type Description
$debug boolean | int

Boolean or bitwise integer describing the debug state and/or PHP error reporting level.

Returns
Type Description
boolean | int The previous value.
methodpublicsetLogLevel( integer $level = xPDO::LOG_LEVEL_FATAL ) : integer
inherited

Sets the logging level state for the xPDO instance.

Inherited from: \xPDO::setLogLevel()
Parameters
Name Type Description
$level integer

The logging level to switch to.

Returns
Type Description
integer The previous log level.
methodpublicsetLogTarget( string $target = 'ECHO' ) : mixed
inherited

Sets the log target for xPDO::_log() calls.

Inherited from: \xPDO::setLogTarget()

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'
Parameters
Name Type Description
$target string

An identifier indicating the target of the logging.

Returns
Type Description
mixed The previous log target.
methodpublicsetOption( string $key, mixed $value ) : void
inherited

Sets an xPDO configuration option value.

Inherited from: \xPDO::setOption()
Parameters
Name Type Description
$key string

The option key.

$value mixed

A value to set for the given option key.

methodpublicsetPackage( string $pkg = '', string $path = '', string | null $prefix = null ) : bool
inherited

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

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

Returns
Type Description
bool
methodpublicsetPackageMeta( string $pkg, string $path = '' ) : bool
inherited

Adds metadata information about a package and loads the xPDO::$classMap.

Inherited from: \xPDO::setPackageMeta()
Parameters
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.

Returns
Type Description
bool
methodpublicsetPlaceholder( string $key, mixed $value ) : void

Sets a placeholder value.

Parameters
Name Type Description
$key string

The unique string key which identifies the placeholder.

$value mixed

The value to set the placeholder to.

methodpublicsetPlaceholders( array | object $placeholders, string $namespace = '' ) : void

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

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

methodpublicstripTags( string $html, string $allowed = '', array $patterns = array(), int $depth = 10 ) : boolean

Strip unwanted HTML and PHP tags and supplied patterns from content.

Parameters
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

Returns
Type Description
boolean True if anything was stripped
Details
See
\modX::$sanitizePatterns  
methodpublicswitchContext( string $contextKey, boolean $reload = false ) : boolean

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

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

Returns
Type Description
boolean True if the switch was successful, otherwise false.
methodpublictoCache( string | \xPDOCriteria $signature, object $object, integer $lifetime = 0, array $options = array() ) : boolean
inherited

Places a result set in the object cache.

Inherited from: \xPDO::toCache()
Parameters
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.

Returns
Type Description
boolean Indicates if the object was successfully cached.
methodpublictoJSON( array $array ) : string
inherited

Converts a PHP array into a JSON encoded string.

Inherited from: \xPDO::toJSON()
Parameters
Name Type Description
$array array

The PHP array to convert.

Returns
Type Description
string The JSON representation of the source array.
methodpublictoPlaceholder( string $key, mixed $value, string $prefix = '', string $separator = '.', boolean $restore = false ) : array

Recursively validates and sets placeholders appropriate to the value type passed.

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

Returns
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.
methodpublictoPlaceholders( array | object $subject, string $prefix = '', string $separator = '.', boolean $restore = false ) : array

Sets placeholders from values stored in arrays and objects.

Each recursive level adds to the prefix, building an access path using an optional separator.

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

Returns
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.
methodpublictoQueryString( array $parameters = array(), string $numPrefix = '', string $argSeparator = '&' ) : string
static

Turn an associative or numeric array into a valid query string.

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

Returns
Type Description
string A valid query string representing the parameters.
Details
Static
 
methodpublicunsetPlaceholder( string $key ) : void

Unset a placeholder value by key.

Parameters
Name Type Description
$key string

The key of the placeholder to unset.

methodpublicunsetPlaceholders( string | array $keys ) : void

Unset multiple placeholders, either by prefix or an array of keys.

Parameters
Name Type Description
$keys string | array

A string prefix or an array of keys indicating the placeholders to unset.

methodpublicupdateCollection( string $className, array $set, mixed $criteria = null ) : bool | int
inherited

Update field values across a collection of xPDOObjects.

Inherited from: \xPDO::updateCollection()
Parameters
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.

Returns
Type Description
bool | int The number of instances affected by the update or false on failure.
Documentation was generated by DocBlox 0.18.1.