I'd say the "bug" here is a poorly implemented configurable class feature in the Mage_Captcha
module -- although it could be argued the developer did this specifically to restrict capcha class to the capcha
model group, and therefore also restrict it to the Mage_Capcha
module. If that's the case, this developer didn't comprehend the power of a fully operational Magento rewrite system.
Magento's rewrite feature is designed to allow a rewrite of any class irrespective of code pool, so I'd say that's a feature, and you should be able to rely on it. A few caveats follow.
The one thing you left out of your post is how you plan on changing
<type>zend</type>
to
<type>recapcha</type>
If you're going to change this directly in Mage_Capcha
, or you're going to use the core_config_data
table and/or system configuration fields, you'll run into a problem if this configuration exists, but your module with the rewrite is disabled/removed. Your module is removed, Magento tried to instantiate a capcha/recapcha
model, can't find it, dies.
So make sure you replace this value either by creating the same node structure in your module such that your value is merged over the above value, or by (at runtime) dynamically replacing the value in the configuration with with Mage::getConfig()->setNode()
.
Finally, if it was me, since you need a rewrite to do this anyway, I'd just rewrite the getCaptcha
function in the capcha/data
helper class to instantiate the model you want.
That looks like Magento 2 is using Knockout.js, a MVVM framework that uses HTML data bindings (and in some cases HTML comments, like the one you found) to link model and view.
Here, this comment is a virtual element, "template" probably a custom binding from Magento (see: http://knockoutjs.com/documentation/custom-bindings-for-virtual-elements.html), getTemplate()
obviously a JavaScript function that is responsible to render the real element(s).
To understand knockout, go through their interactive tutorial at knockoutjs.com, I found it easy to grasp and the tutorial/documentation is really great.
Best Answer
Di configuration was moved to di.xml files, and format was modified. Now preferences look like this (di.xml):