Using Custom Loader Classes
Last updated Dec 21st, 2019 | Page history | Improve this page | Report an issue
You can provide any of the following static methods in your custom xPDOObject derivative classes to override their behavior, including in driver-specific classes:
- _loadRows
- _loadInstance
- _loadCollectionInstance
- load
- loadCollection
- loadCollectionGraph
This is done with the help of the xPDO::call()
method.
Overriding these methods allows you to implement additional behavior or completely change the behavior of loading your table objects via the object and collection methods provided by xPDO and xPDOObject. For instance, it can be used to perform security checks or to add i18n processing before allowing a row to be loaded.
Prior to 2.0.0-pl, you can specify custom loader classes that extend or override the behavior of the default object loaders by specifying these classes in the xPDO options array when instantiating an xPDO instance.
$xpdo = new xPDO($dsn, $username, $password, array(
xPDO::OPT_LOADER_CLASSES => array('myCustomLoaderClass')
));
Support the team building MODX with a monthly donation.
The budget raised through OpenCollective is transparent, including payouts, and any contributor can apply to be paid for their work on MODX.
Backers
Budget
$306 per month—let's make that $500!
Learn more