Jump to main content Jump to doc navigation

modX::loadClass

Deprecated since 3.0 — reference MODX\Revolution\* classes directly and let the PSR-4 autoloader load them.

The name is resolved in this order:

  1. A namespaced name that already exists is returned unchanged.
  2. A plain or dotted name such as modx.modChunk is mapped onto MODX\Revolution\. The old name gets a class_alias() when it is missing, a deprecation is recorded, and the PSR-4 name is returned.
  3. When that guess fails, the method returns what xPDO::loadClass() answers: the class name or false.

A non-empty $path skips step 2. $path, $ignorePkg and $transient apply only in step 3.

Syntax

bool|string loadClass (string $fqn, [string $path = ''], [bool $ignorePkg = false], [bool $transient = false])
  • $fqn (string) class name, plain, dotted or namespaced
  • $path (string) directory searched by xPDO::loadClass(), by default ''
  • $ignorePkg (bool) skip the package search inside xPDO::loadClass(), by default false
  • $transient (bool) load without the metadata map inside xPDO::loadClass(), by default false

Example

$class = $modx->loadClass('modx.modChunk');
// 'MODX\Revolution\modChunk'

$missing = $modx->loadClass('modMissingClass');
// false, and xPDO logs "Could not load class"

See Also

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
  • Digital Penguin
  • Jens Wittmann – Gestaltung & Entwicklung
  • CrewMark
  • Fabian Christen
  • Sepia River Studios
  • Dannevang Digital
  • Alex
  • A. Moreno
  • Chris Fickling
  • Stéphane Jäggi
  • Murray Wood
  • Anton Tarasov
  • JT Skaggs
  • deJaya
  • Lefthandmedia
  • eydolan
  • Following Sea
  • Guido Gallenkamp
  • YJ
  • Raffy
  • Snow Creative
  • Nick Clark
  • Guest
  • Helen
  • krisznet
  • Yanni
  • Richard

Budget

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

Learn more