Hello,
i have splitted a big module into 3 separate modules.(not finished)
It’s an ISP tool, with which one you could manage customer and contracts, invoice and much more…
I have created composer packages from them
Current Modules:
isptool-customer
isptool-contract
isptool-invoice
isptool-contract/Modules.php:
<?php
namespace xxx\isptool\contract;
use yii\base\Module as BaseModule;
use Yii;
class Module extends BaseModule
{
const VERSION = '0.1';
/** @var array Model map */
public $modelMap = [];
public $urlPrefix = '';
public $dbConnection = 'db';
/** @var array The rules to be used in URL management. */
public $urlRules = [
];
public function init(){
parent::init();
$this->params = require __DIR__ . '/config/params.php';
}
/**
* @return string
*/
public function getDb()
{
return \Yii::$app->get($this->dbConnection);
}
}
isptool-contract/Bootstrap.php:
<?php
namespace xxx\isptool\contract;
use Yii;
use yii\base\BootstrapInterface;
use yii\console\Application as ConsoleApplication;
use yii\i18n\PhpMessageSource;
use yii\web\GroupUrlRule;
class Bootstrap implements BootstrapInterface
{
public function bootstrap($app)
{
if ($app->hasModule('isptool-contract') && ($module = $app->getModule('isptool-contract')) instanceof Module) {
if ($app instanceof ConsoleApplication) {
}else{
$configUrlRule = [
'prefix' => 'isptool',
'rules' => $module->urlRules,
];
if ($module->urlPrefix != 'isptool') {
$configUrlRule['routePrefix'] = '';
}
$rules = new GroupUrlRule($configUrlRule);
$app->urlManager->addRules([$rules],false);
}
}
}
}
Everything works fine, but i don’t like the Urlrules.
Current rules looks like isptool-customer/customer/create i.e
But i want something like
isptool/customer/create
or better
customer/create
Is this possible?