I'd like to be able to add helper methods to all entities, or to all nodes, etc, but I'm not sure the best way to do this since WdEntityWrapper, WdNodeWrapper, etc, all live outside of the generated custom module. Do you think it would be feasible to always generate custom empty classes extending WdEntityWrapper, WdNodeWrapper, etc, and have all the generated bundle classes extend those empty classes? This way I could dump helper methods into those empty classes.

Comments

zengenuity’s picture

The system doesn't generate any empty intermediate classes, but you can do this pretty easily manually. Just create your new node wrapper class and extend WdNodeWrapper. Then, implement hook_wrappers_delight_base_classes_alter() in your module. There's an example in wrappers_delight.api.php. You can override the base class used for node wrappers in that hook and point it at your new class. This won't update any previously generated bundle wrapper classes, but should work for any new classes generated after implementing the hook.

zengenuity’s picture

Also, the system doesn't do any autoloading of classes, so be sure to include your new wrapper class in your .info or make sure it's loaded by some other method.

brockfanning’s picture

Status: Active » Closed (works as designed)

Nice, thanks very much for the info.