-
☆ A M B ☆
- 2,475 Posts
Where is the correct place to use the addPackage method when building a custom resource class? It's easy enough to a line to the beginning of a Snippet, but I'm not at all clear what gets included or when... addExtensionPackage gets some things on the radar, but not my custom database tables.
How to force custom database tables to be created?
-
MODX Staff
- 10,725 Posts
Tables should be created/updated by the transport package installation using the xPDOManager API, but this is outside the scope of calling addPackage to load a Custom Resource Class.
addExtensionPackage is a helper method for changing a complex System Setting, and is not intended for run-time usage in the same request AFAIK. This is used to make the package available (via addPackage() calls on the defined extension_packages) during initialization of a Context.
-
☆ A M B ☆
- 2,475 Posts
I think I figured out my immediate problem: I needed to add some calls to createObjectContainer in my build-script's resolvers.
The docs are out of date I think -- didn't it used to be that calling getCollection on a defined object would trigger the table to be created? That no longer appears to be the behavior...
I think that used to be true, but isn't any longer.
BTW, there's some info about addPackage() and its relatives here:
http://bobsguides.com/blog.html/2013/05/25/understanding-addpackage(),-loadclass(),-and-getservice()/