Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Nested Modules and Controllers
 
JonUK
Jr. Member
 
Total Posts:  7
Joined:  2008-11-15
 

Nested modules are incredibly useful (both during development, deployment and for sales purposes) when developing a suite of tightly related modules. Namespaces flow naturally (across 50 odd classes), dependencies become obvious, and the suite can be packaged as a single folder for deployment.

Presently Magento inadvertently supports these for most code structures, but not controllers. The offending line of code resides in

Mage_Core_Controller_Varien_Router_Standard
, within the function

public function getControllerFileName($realModule$controller)
    
{
        $parts 
explode('_'$realModule);
       
[b] $realModule implode('_'array_splice($parts02));[/b]
        $file 
Mage::getModuleDir('controllers'$realModule);
        if (
count($parts)) {
            $file 
.= DS implode(DS$parts);
        
}
        $file 
.= DS.uc_words($controllerDS).'Controller.php';
        return 
$file;
    
}

where the assumption is made that realModule always has a 2 part mantissa:

$realModule implode('_'array_splice($parts02));

This causes controller support to fail when variables are such:

$realModule 'Company_Suite_Group_Functionality';
$controller 'order';

The result at the end of the function is:

$realModule 'Company_Suite';
$file '...../app/code/local/Company/Suite/controllers/Group/Functionality/OrderController'

instead of

$realModule 'Company_Suite_Group_Functionality';
$file '...../app/code/local/Company/Suite/Group/Functionality/controllers/OrderController'

I realise a custom router can be used to change this behaviour, but would the Magento team consider modifying this assumption so that support for deeper modules is natively available?

 
Magento Community Magento Community
Magento Community
Magento Community
 
JonUK
Jr. Member
 
Total Posts:  7
Joined:  2008-11-15
 

I think you mean tightly coupled modules are bad practice - I agree.

I should have said “suite of inter dependent modules” rather than “suite of tightly related modules”.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top