This coversation was quite useful and after some time we decided to go slightly different. Mainly deciding to put the adaptation to the routing in an extension to the module you want to activate.
The steps to follow:
- Create or adapt post_install.php file in your module installation zip file.
- For each module, create a routing file.
- Ensure that your manifest file makes the routing files available.
This should be upgrade safe, and result in no conflicts with other elements.
So, let me just share the code here:
(1) add in your scripts folder of your legacy module (i.e. the zip fileâŚ) , a post_install function as described by suiteCRM, or if you already have one, just add a call to the function I will explain next:
<?php
if (!defined('sugarEntry') || !sugarEntry)
die('Not A Valid Entry Point');
function post_install() {
addLegacyRouting();
...
}
And then the actual logic (should be in the same post_install.php file:
function addLegacyRouting() {
//assumes module_routing.php has previously been copied in "module"/include (in manifest)
$dirname = "../../extensions";
$modules = [ "vde_Common", "vde_Forms", "vde_Views", "vde_vNotes" ];
if (is_dir($dirname)) { //supposedly SuiteCRM 8
foreach ($modules as $module) {
if (is_dir($dirname . "/".$module."/config")) {
copyRouting($dirname, $module);
} else {
mkdir($dirname . "/".$module."/config", 0755, true);
copyRouting($dirname, $module);
}
}
}
}
function copyRouting($dirname, $module) {
copy("modules/".$module."/include/module_routing.php", $dirname."/".$module."/config/module_routing.php");
}
Note: Change $modules to the corresponding values: these would be the ids that would appear in the URL when routed to in suiteCRM v7. Note that it is an array, so even if you only install one module, keep it an array.
(2) Create the corresponding extension file (one for each module that you will install)
The code above assumes that you will put these files in an include folder, just under your main module folder (of the installation zip file). The selected name for the file is: module_routing.php
(note: contents are exactly as suggested by other contributors)
module_routing.php
<?php
use Symfony\Component\DependencyInjection\Container;
if (!isset($container)) {
return;
}
/** @var Container $container */
$routes= $container->getParameter('legacy.module_routing') ?? [];
$routes['vde_Common'] = [
'index' => false,
'list' => false,
'record' => false
];
$container->setParameter('legacy.module_routing', $routes);
Note: change âvde_Commonâ to your module identification (see point 1)
(3) Of course, in your manifest file, you need to have something like:
'copy' =>
array(
0 =>
array(
'from' => '<basepath>/modules',
'to' => 'modules',
),
This will copy everything, also the âincludeâ folder and make it available for the post_install execution.
In this example, I copied part of the logic that we are using for a specific installation that includes 4 modules in one installation (zip) file.
Hope this helps and saves time to other readers.
PD: with this adaptation, the installation would work both for SuiteCRM v7 and v8âŚ