M
M
Maxim2018-09-19 13:26:22
Yii
Maxim, 2018-09-19 13:26:22

Yii how to change link when moving controller?

Hello everyone) There is such a sore subject as changing project links. Now the links are done like this:

Html::a(Html::encode($model->profile->fullName), ['/user/profile/view', 'id' => $model->profile->id])

Everything works well until one moment. Until you suddenly decide to change the location or move the files to another location. For example, I decided to change the module to "Director". And he threw them from one place to another and the path became like this:
Html::a(Html::encode($model->profile->fullName), ['/director/profile/view', 'id' => $model->profile->id])

Now you need to search throughout the code where I put
['/user/profile/view', 'id' => $model->profile->id]
and change to
['/director/profile/view', 'id' => $model->profile->id]

Of course, you can use the IDE search engine and change everything through it, but I would not want to do this without intervention. I just want to transfer the files and not worry about the wrong routes. After all, I can forget to change one route and a 404 error flies. Thus, after the transfer, it is constantly required to look where everything has not been changed.
Maybe it makes sense to put the url in the module methods?
Maybe it makes sense to make a train?
Can somehow prescribe routes differently?
Maybe you need to use Alias?
Tell me which way is better to go? Perhaps there are some Yii solutions?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lander, 2018-09-19
@myks92

Maybe it makes sense to put the url in the module methods?
Maybe it makes sense to make a train?
Can somehow prescribe routes differently?
Maybe you need to use Alias?
Or maybe change the rules in the router.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question