@jaredfhealy @markh @opengeek
I’m back here looking for help on ClassExtender. I can’t get it to run successfully in MODX 3.
These steps all return success:
// parse schema file and generate the class files
$this->generator->parseSchema($path, $this->modelPath); )
/* Add package */
$this->modx->addPackage($this->ce_package_name,
$this->modelPath, $this->ce_table_prefix);
$manager = $this->modx->getManager();
When I get to $manager->createObjectContainer(‘userData’), it fails because it can’t instantiate the object. So the table is not created. The error is: core\vendor\xpdo\xpdo\src\xPDO\xPDO.php : 666) Could not load class: userData from mysql.userdata
In the schema:
<object class="extUser" extends="modUser">
...
<object class="userData" table="user_data" extends="xPDOSimpleObject">
In MODX 2 the two class files look like this (no namespace):
class extUser extends modUser {}
class userData extends xPDOSimpleObject {}
In MODX 3, I get this for the two class files:
namespace extendeduser;
namespace extendeduser;
class extUser extends \extendeduser\extUser
namespace extendeduser;
class userData extends \xPDOSimpleObject
MODX 2 metadata file:
$xpdo_meta_map = array (
'modUser' =>
array (
0 => 'extUser',
),
'xPDOSimpleObject' =>
array (
0 => 'userData',
),
);
$modx 3 metadata file:
$xpdo_meta_map = array (
'modUser' =>
array (
0 => 'extendeduser\\extUser',
),
'xPDOSimpleObject' =>
array (
0 => 'extendeduser\\userData',
),
);
In MODX 2, the two class files have an include
statement to include the files listed above, the MODX 3 files don’t, so it’s possible that I’m supposed to set things up so the files can be autoloaded, but I suspect that there may be more serious problems.
I’ve created a test file that seems to expose the problem. It puts these in the $_POST array (these are the default values in the form):
$fields = array(
'ce_package_name' => 'extendeduser',
'ce_class' => 'modUser',
'ce_parent_object' => 'modUser',
'ce_table_prefix' => '_ext',
'ce_table_name' => 'user_data',
'ce_schema_tpl_name' => 'ExtUserSchema',
);
I can step through the createObjectContainer(‘userData’) method in the debugger. I can see where it fails, but so far I can’t see why.
Should the two schema files be different?
I’d like to make the extra run in both MODX 2 and MODX 3, but I’m wondering if that’s possible.