I have searched through a lot of articles, Stackoverflow and more, but no solution helped me.
I have created a Module, which one, i install through composer and a private Repository.
Everything works, but now i want to overwrite the rules, for a better usability.
It’s a Yii2 Advanced template ,<vendor> is a masked Vendorname
Url I liked to use:
admin/customer/update/2
admin/customer
admin/customer/2
admin/customer/delete/2
config/main.php:
'urlManager' => [
'scriptUrl'=>'/admin/index.php',
'enablePrettyUrl' => true,
'showScriptName' => false,
'rules' => [],
]
<vendor>/ispman-customer/Module.php
<?php
namespace <vendor>\ispman\customer;
use yii\base\Module as BaseModule;
use Yii;
class Module extends BaseModule
{
const VERSION = '0.1';
/** @var array Model map */
public $modelMap = [];
public $urlPrefix = 'ispman';
/** @var array The rules to be used in URL management. */
public $urlRules = [
'customer/update/<id:\d+>' => 'ispman-customer/customer/update',
];
public function init(){
parent::init();
}
}
<vendor>/ispman-customer/Bootstrap.php:
class Bootstrap implements BootstrapInterface
{
public function bootstrap($app)
{
/** @var Module $module */
if ($app->hasModule('ispman-customer') && ($module = $app->getModule('ispman-customer')) instanceof Module) {
if ($app instanceof ConsoleApplication) {
}else{
$configUrlRule = [
'prefix' => 'ispman',
'rules' => $module->urlRules,
];
if ($module->urlPrefix != 'ispman') {
$configUrlRule['routePrefix'] = '';
}
$rules = new GroupUrlRule($configUrlRule);
$app->urlManager->addRules([$rules],false);
}
if (!isset($app->get('i18n')->translations['ispman*'])) {
$app->get('i18n')->translations['ispman*'] = [
'class' => PhpMessageSource::className(),
'basePath' => __DIR__ . '/messages',
'sourceLanguage' => 'en-US'
];
}
}
}
}
Remove from Urlprefix also don’t help, hope someone could help .
Thanks in advance