xpdo icon indicating copy to clipboard operation
xpdo copied to clipboard

Enable writeSchema to work with a specific list of tables

Open SnowCreative opened this issue 3 years ago • 1 comments

Feature request

Summary

xPDOGenerator.writeSchema currently takes four values: file name, package name, base class, and prefix. Adding two more would extend the capabilities: restrict to prefix (boolean), and table list (comma-separated list of table names).

Why is it needed?

When developing custom tables, it would nice to be able to use a script to auto-generate the schema for just those tables as part of a package. Currently, it's all or nothing; all tables in the specified prefix get included in the schema for the package you specify, which is not what we want for custom tables. Only using a custom prefix instead of the default MODX table prefix enables making the schema for just the custom tables.

Bob Ray's script CreateXpdoClasses is very useful, and already has the ability to specify tables built in, but that won't work until writeSchema is updated. Here's a note he put in that script:

/* boolean writeSchema (
 *   string $schemaFile,  // Full path to the schema file you want to write
 *   [string $package = ''], //  Name of your component
 *   [string $baseClass = ''], // xPDO base class to use;
 *                                 send '' if using args below
 *   [string $tablePrefix = ''], // Table prefix (of tables to process)
 *   [boolean $restrictPrefix = false]), // Process only tables
 *                                          with $tablePrefix
 *   [mixed $tableList = '' // Array of arrays of
 *                             full-table-name=>className or
 *                             a string with a comma-separated
 *                             list of full table names;
 *                             if you send the string the table
 *                             name will be used as the class name.
*/

SnowCreative avatar Jul 29 '21 17:07 SnowCreative

I'm going to transfer this issue to the xPDO repo.

JoshuaLuckers avatar Jul 31 '21 13:07 JoshuaLuckers