magento2 icon indicating copy to clipboard operation
magento2 copied to clipboard

Clear separation for Controller and controllers required with Full Controller path

Open jigneshthummar opened this issue 14 years ago • 5 comments

-I can't find difference between folder Controller and controllers folder under Catalog ( and some other ) modules its possible to merge both of them or any reason why its like that? -more over is it possible to add full controller path as controllers class name? same like Model and Block class name? i.e Mage_Catalog_IndexController can be converted to Mage_Catalog_controllers_IndexController

jigneshthummar avatar Mar 23 '12 07:03 jigneshthummar

The classes under Controller are meant to be abstract classes which are extended by real controllers.

colinmollenhour avatar Mar 23 '12 19:03 colinmollenhour

any idea why Magento dont include controller folder name in controller class name ? i agree we never need to make object of controller but when we rewrite controller we have to add controller file name which we rewriting. which we dont need when we rewrite block or model

jigneshthummar avatar Mar 25 '12 06:03 jigneshthummar

Organising action controllers in a controllers/ directory and omitting "controllers" in the class name originates from Zend Framework.

mzeis avatar Mar 25 '12 09:03 mzeis

When rewriting controllers sometimes you only want to rewrite specific methods. There are probably other good reasons as well, but in general controllers are quite a bit different than models/helpers/blocks.

colinmollenhour avatar Mar 25 '12 22:03 colinmollenhour

Good question, @jigneshthummar. You are not first, who asks about it. @colinmollenhour and @mzeis are absoluttelly right.

when we rewrite controller we have to add controller file name which we rewriting. which we dont need when we rewrite block or model

If you say about rewritting controller via config.xml, than you don't need to specify file name there. If you say about extending controller classes, than this is not recommended practice.

We'll add documentation page about differences between 'controllers' and 'Controller' directories in Magento Framework section.

magento-team avatar Apr 11 '12 23:04 magento-team