Jump to main content Jump to doc navigation

Change the Way xPDO Loads Data

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.

< 2.0

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

  • modmore
  • STERC
  • Jens Wittmann – Gestaltung & Entwicklung
  • Fabian Christen
  • Dannevang Digital
  • Digital Penguin
  • Sepia River Studios
  • CrewMark
  • Chris Fickling
  • deJaya
  • Following Sea
  • Anton Tarasov
  • eydolan
  • Raffy
  • Lefthandmedia
  • Murray Wood
  • Snow Creative
  • Nick Clark
  • Helen
  • JT Skaggs
  • krisznet
  • YJ
  • Yanni
  • Richard

Budget

$370 per month—let's make that $500!

Learn more