Jump to main content Jump to doc navigation

modX::addExtensionPackage

Writes a package entry into the extension_packages system setting, creating the setting first when it does not exist. The stored value is a JSON array: each entry maps a package name to its options and stores the path under the path key.

The package loads on the next initialization, not in the running request: the settings cache must be refreshed first. Then initialize() reads the setting, expands path tokens such as [[++core_path]] and calls xPDO::addPackage().

The package classes become available to loadClass(), newObject() and getTableName(). serviceName and serviceClass go to xPDO::getService(), which is itself deprecated in favour of the service container.

The core marked the setting-based store deprecated in 2.3; modExtensionPackage records replace it. The code still announces a removal that never happened, so the setting keeps working in this version.

Syntax

boolean addExtensionPackage (string $name, string $path, [array $options = array()])
  • $name (string) package name, used as the key of the entry
  • $path (string) directory that holds the package model
  • $options (array) tablePrefix, serviceName and serviceClass values, by default array()

Example

$modx->addExtensionPackage('mypkg', MODX_CORE_PATH . 'components/mypkg/model/', array(
    'tablePrefix' => 'mypkg_',
));

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