Just getting back into playing around with Modx again . And perhaps work on some updates, enhancements, for ExtraBuilder.
This specific question is a clarification on custom tables/models when calling $modx->newObject("myClass"). Is there a way to make this work with the short class name? Or on MODX v3 you just need to use the full class?
In my view it’s a bad idea.
It defeats the purpose of having namespaces (which is avoiding naming conflicts), if class aliases are created for every custom class.
To avoid having to write the full class name all the time, it’s better (in my opinion) to use a use-statement at the top:
use MODX\Revolution\modResource;
...
$modx->getObject(modResource::class, ...);
Ah, right. Thanks for the reminder about “use” statements.
So, the bootstrap “use” statement doesn’t carry-over to the Snippet processing? It seems you have to put “use” statements at the top of your Snippet for any classes you want to use.
I guess that’s partially the point so that you know for that specific PHP what classes are being used?
This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.