`XenForo_Model::create("{$class}")` and `new {$class}`

vbresults

Well-known member
What are the full benefits and drawbacks of each one? I know that XenForo_Model::create allows classes to be extended using the XFCP system, and I know that `new {$class}` is less code. I also know that the first choice allows me to immediately call non-static methods while the second option does not. Can someone add to this list of pros/cons so I can better know when to use one and not the other?
 
You should always use XenForo_Model::create('Class') instead of new class.

Indeed. You should never use "new Model", the reasons are the ones you've just pointed, basically it means it can't be extended by add-ons.
 
Top Bottom