implement module viewPath in all views instead of static file reference

This commit is contained in:
tonis ormisson
2022-09-08 09:41:08 +03:00
parent 0009db637a
commit 569b049011
20 changed files with 57 additions and 20 deletions

View File

@ -74,6 +74,7 @@ abstract class AbstractAuthItemController extends Controller
[ [
'searchModel' => $searchModel, 'searchModel' => $searchModel,
'dataProvider' => $searchModel->search(Yii::$app->request->get()), 'dataProvider' => $searchModel->search(Yii::$app->request->get()),
'module' => $this->module
] ]
); );
} }
@ -101,6 +102,7 @@ abstract class AbstractAuthItemController extends Controller
[ [
'model' => $model, 'model' => $model,
'unassignedItems' => $this->authHelper->getUnassignedItems($model), 'unassignedItems' => $this->authHelper->getUnassignedItems($model),
'module' => $this->module
] ]
); );
} }
@ -130,6 +132,7 @@ abstract class AbstractAuthItemController extends Controller
[ [
'model' => $model, 'model' => $model,
'unassignedItems' => $this->authHelper->getUnassignedItems($model), 'unassignedItems' => $this->authHelper->getUnassignedItems($model),
'module' => $this->module
] ]
); );
} }

View File

@ -178,7 +178,10 @@ class AdminController extends Controller
} }
} }
return $this->render('_account', ['user' => $user]); return $this->render('_account', [
'user' => $user,
'module' => $this->module
]);
} }
public function actionUpdateProfile($id) public function actionUpdateProfile($id)
@ -211,6 +214,7 @@ class AdminController extends Controller
[ [
'user' => $user, 'user' => $user,
'profile' => $profile, 'profile' => $profile,
'module' => $this->module
] ]
); );
} }
@ -224,6 +228,7 @@ class AdminController extends Controller
'_info', '_info',
[ [
'user' => $user, 'user' => $user,
'module' => $this->module
] ]
); );
} }
@ -238,6 +243,7 @@ class AdminController extends Controller
[ [
'user' => $user, 'user' => $user,
'params' => Yii::$app->request->post(), 'params' => Yii::$app->request->post(),
'module' => $this->module
] ]
); );
} }
@ -372,6 +378,7 @@ class AdminController extends Controller
'searchModel' => $searchModel, 'searchModel' => $searchModel,
'dataProvider' => $dataProvider, 'dataProvider' => $dataProvider,
'user' => $user, 'user' => $user,
'module' => $this->module
]); ]);
} }

View File

@ -67,6 +67,7 @@ class RuleController extends Controller
[ [
'searchModel' => $searchModel, 'searchModel' => $searchModel,
'dataProvider' => $dataProvider, 'dataProvider' => $dataProvider,
'module' => $this->module
] ]
); );
} }
@ -89,7 +90,8 @@ class RuleController extends Controller
return $this->render( return $this->render(
'create', 'create',
[ [
'model' => $model 'model' => $model,
'module' => $this->module
] ]
); );
} }
@ -104,7 +106,7 @@ class RuleController extends Controller
[ [
'previousName' => $name, 'previousName' => $name,
'name' => $rule->name, 'name' => $rule->name,
'className' => get_class($rule) 'className' => get_class($rule),
] ]
); );
@ -123,6 +125,7 @@ class RuleController extends Controller
'update', 'update',
[ [
'model' => $model, 'model' => $model,
'module' => $this->module
] ]
); );
} }

View File

@ -12,13 +12,16 @@
namespace Da\User\Service; namespace Da\User\Service;
use Da\User\Contracts\ServiceInterface; use Da\User\Contracts\ServiceInterface;
use Da\User\Traits\ModuleAwareTrait;
use Yii; use Yii;
use yii\mail\BaseMailer; use yii\mail\BaseMailer;
use yii\mail\MailerInterface; use yii\mail\MailerInterface;
class MailService implements ServiceInterface class MailService implements ServiceInterface
{ {
protected $viewPath = '@Da/User/resources/views/mail'; use ModuleAwareTrait;
protected $viewPath = '';
protected $type; protected $type;
protected $from; protected $from;
@ -48,6 +51,7 @@ class MailService implements ServiceInterface
$this->view = $view; $this->view = $view;
$this->params = $params; $this->params = $params;
$this->mailer = $mailer; $this->mailer = $mailer;
$this->viewPath = $this->getModule()->viewPath . '/mail';
$this->mailer->setViewPath($this->viewPath); $this->mailer->setViewPath($this->viewPath);
$this->mailer->getView()->theme = Yii::$app->view->theme; $this->mailer->getView()->theme = Yii::$app->view->theme;
} }

View File

@ -12,17 +12,22 @@
namespace Da\User\Widget; namespace Da\User\Widget;
use Da\User\Form\LoginForm; use Da\User\Form\LoginForm;
use Da\User\Traits\ModuleAwareTrait;
use Yii; use Yii;
use yii\base\Widget; use yii\base\Widget;
/**
* @deprecated this seems to be unused by this module. To be deleted in future!
*/
class LoginWidget extends Widget class LoginWidget extends Widget
{ {
use ModuleAwareTrait;
public $validate = true; public $validate = true;
public function run() public function run()
{ {
return $this->render( return $this->render(
'@Da/User/resources/views/widgets/login/form', $this->getModule()->$this->viewPath .'/widgets/login/form',
[ [
'model' => Yii::createObject(LoginForm::class), 'model' => Yii::createObject(LoginForm::class),
] ]

View File

@ -14,10 +14,11 @@ use yii\helpers\Html;
/** @var yii\web\View $this */ /** @var yii\web\View $this */
/** @var Da\User\Model\User $user */ /** @var Da\User\Model\User $user */
/** @var \Da\User\Module $module */
?> ?>
<?php $this->beginContent('@Da/User/resources/views/admin/update.php', ['user' => $user]) ?> <?php $this->beginContent($module->viewPath. '/admin/update.php', ['user' => $user]) ?>
<?php $form = ActiveForm::begin( <?php $form = ActiveForm::begin(
[ [

View File

@ -14,10 +14,11 @@ use Da\User\Widget\AssignmentsWidget;
/** @var yii\web\View $this */ /** @var yii\web\View $this */
/** @var Da\User\Model\User $user */ /** @var Da\User\Model\User $user */
/** @var string[] $params */ /** @var string[] $params */
/** @var \Da\User\Module $module */
?> ?>
<?php $this->beginContent('@Da/User/resources/views/admin/update.php', ['user' => $user]) ?> <?php $this->beginContent($module->viewPath. '/admin/update.php', ['user' => $user]) ?>
<?= yii\bootstrap\Alert::widget( <?= yii\bootstrap\Alert::widget(
[ [

View File

@ -11,10 +11,11 @@
/** @var yii\web\View $this */ /** @var yii\web\View $this */
/** @var Da\User\Model\User $user */ /** @var Da\User\Model\User $user */
/** @var \Da\User\Module $module */
?> ?>
<?php $this->beginContent('@Da/User/resources/views/admin/update.php', ['user' => $user]) ?> <?php $this->beginContent($module->viewPath. '/admin/update.php', ['user' => $user]) ?>
<table class="table"> <table class="table">
<tr> <tr>

View File

@ -16,11 +16,12 @@ use yii\helpers\Html;
* @var yii\web\View $this * @var yii\web\View $this
* @var \Da\User\Model\User $user * @var \Da\User\Model\User $user
* @var \Da\User\Model\Profile $profile * @var \Da\User\Model\Profile $profile
* @var \Da\User\Module $module
*/ */
?> ?>
<?php $this->beginContent('@Da/User/resources/views/admin/update.php', ['user' => $user]) ?> <?php $this->beginContent($module->viewPath. '/admin/update.php', ['user' => $user]) ?>
<?php $form = ActiveForm::begin( <?php $form = ActiveForm::begin(
[ [

View File

@ -23,10 +23,11 @@ use yii\data\ActiveDataProvider;
* @var SessionHistorySearch $searchModel * @var SessionHistorySearch $searchModel
* @var ActiveDataProvider $dataProvider * @var ActiveDataProvider $dataProvider
* @var \Da\User\Model\User $user * @var \Da\User\Model\User $user
* @var \Da\User\Module $module
*/ */
?> ?>
<?php $this->beginContent('@Da/User/resources/views/admin/update.php', ['user' => $user]) ?> <?php $this->beginContent($module->viewPath. '/admin/update.php', ['user' => $user]) ?>
<div class="row"> <div class="row">
<div class="col-xs-12"> <div class="col-xs-12">
<?= Html::a( <?= Html::a(

View File

@ -27,7 +27,7 @@ $this->params['breadcrumbs'][] = $this->title;
$module = Yii::$app->getModule('user'); $module = Yii::$app->getModule('user');
?> ?>
<?php $this->beginContent('@Da/User/resources/views/shared/admin_layout.php') ?> <?php $this->beginContent($module->viewPath . '/shared/admin_layout.php') ?>
<?php Pjax::begin() ?> <?php Pjax::begin() ?>
<div class="table-responsive"> <div class="table-responsive">

View File

@ -13,6 +13,7 @@
* @var yii\web\View $this * @var yii\web\View $this
* @var Da\User\Model\Permission $model * @var Da\User\Model\Permission $model
* @var string[] $unassignedItems * @var string[] $unassignedItems
* @var \Da\User\Module $module
*/ */
$this->title = Yii::t('usuario', 'Create new permission'); $this->title = Yii::t('usuario', 'Create new permission');
@ -20,7 +21,7 @@ $this->params['breadcrumbs'][] = $this->title;
?> ?>
<?php $this->beginContent('@Da/User/resources/views/shared/admin_layout.php') ?> <?php $this->beginContent($module->viewPath . '/shared/admin_layout.php') ?>
<?= $this->render( <?= $this->render(
'/permission/_form', '/permission/_form',

View File

@ -13,6 +13,7 @@
* @var \yii\data\ActiveDataProvider $dataProvider * @var \yii\data\ActiveDataProvider $dataProvider
* @var yii\web\View $this * @var yii\web\View $this
* @var \Da\User\Search\PermissionSearch $searchModel * @var \Da\User\Search\PermissionSearch $searchModel
* @var \Da\User\Module $module
*/ */
use yii\grid\ActionColumn; use yii\grid\ActionColumn;
use yii\grid\GridView; use yii\grid\GridView;
@ -23,7 +24,7 @@ $this->params['breadcrumbs'][] = $this->title;
?> ?>
<?php $this->beginContent('@Da/User/resources/views/shared/admin_layout.php') ?> <?php $this->beginContent($module->viewPath . '/shared/admin_layout.php') ?>
<div class="table-responsive"> <div class="table-responsive">
<?= GridView::widget( <?= GridView::widget(
[ [

View File

@ -13,6 +13,7 @@
* @var yii\web\View $this * @var yii\web\View $this
* @var Da\User\Model\Permission $model * @var Da\User\Model\Permission $model
* @var string[] $unassignedItems * @var string[] $unassignedItems
* @var \Da\User\Module $module
*/ */
$this->title = Yii::t('usuario', 'Update permission'); $this->title = Yii::t('usuario', 'Update permission');
@ -20,7 +21,7 @@ $this->params['breadcrumbs'][] = $this->title;
?> ?>
<?php $this->beginContent('@Da/User/resources/views/shared/admin_layout.php') ?> <?php $this->beginContent($module->viewPath . '/shared/admin_layout.php') ?>
<?= $this->render( <?= $this->render(
'/permission/_form', '/permission/_form',

View File

@ -13,13 +13,14 @@
* @var yii\web\View $this * @var yii\web\View $this
* @var \Da\User\Model\Role $model * @var \Da\User\Model\Role $model
* @var string[] $unassignedItems * @var string[] $unassignedItems
* @var \Da\User\Module $module
*/ */
$this->title = Yii::t('usuario', 'Create new role'); $this->title = Yii::t('usuario', 'Create new role');
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
<?php $this->beginContent('@Da/User/resources/views/shared/admin_layout.php') ?> <?php $this->beginContent($module->viewPath . '/shared/admin_layout.php') ?>
<?= $this->render( <?= $this->render(
'/role/_form', '/role/_form',

View File

@ -17,6 +17,7 @@ use yii\helpers\Url;
* @var \yii\data\DataProviderInterface $dataProvider * @var \yii\data\DataProviderInterface $dataProvider
* @var \Da\User\Search\RoleSearch $searchModel * @var \Da\User\Search\RoleSearch $searchModel
* @var yii\web\View $this * @var yii\web\View $this
* @var \Da\User\Module $module
*/ */
$this->title = Yii::t('usuario', 'Roles'); $this->title = Yii::t('usuario', 'Roles');
@ -24,7 +25,7 @@ $this->params['breadcrumbs'][] = $this->title;
?> ?>
<?php $this->beginContent('@Da/User/resources/views/shared/admin_layout.php') ?> <?php $this->beginContent($module->viewPath . '/shared/admin_layout.php') ?>
<div class="table-responsive"> <div class="table-responsive">
<?= GridView::widget( <?= GridView::widget(
[ [

View File

@ -13,13 +13,14 @@
* @var yii\web\View $this * @var yii\web\View $this
* @var \Da\User\Model\Role $model * @var \Da\User\Model\Role $model
* @var string[] $unassignedItems * @var string[] $unassignedItems
* @var \Da\User\Module $module
*/ */
$this->title = Yii::t('usuario', 'Update role'); $this->title = Yii::t('usuario', 'Update role');
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
<?php $this->beginContent('@Da/User/resources/views/shared/admin_layout.php') ?> <?php $this->beginContent($module->viewPath . '/shared/admin_layout.php') ?>
<?= $this->render( <?= $this->render(
'/role/_form', '/role/_form',

View File

@ -13,13 +13,14 @@
* @var yii\web\View $this * @var yii\web\View $this
* @var \Da\User\Model\Rule $model * @var \Da\User\Model\Rule $model
* @var string[] $unassignedItems * @var string[] $unassignedItems
* @var \Da\User\Module $module
*/ */
$this->title = Yii::t('usuario', 'Create new rule'); $this->title = Yii::t('usuario', 'Create new rule');
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
<?php $this->beginContent('@Da/User/resources/views/shared/admin_layout.php') ?> <?php $this->beginContent($module->viewPath . '/shared/admin_layout.php') ?>
<?= $this->render( <?= $this->render(
'/rule/_form', '/rule/_form',

View File

@ -9,6 +9,7 @@ use yii\rbac\Rule;
* @var \yii\data\ActiveDataProvider $dataProvider * @var \yii\data\ActiveDataProvider $dataProvider
* @var \Da\User\Search\RuleSearch $searchModel * @var \Da\User\Search\RuleSearch $searchModel
* @var yii\web\View $this * @var yii\web\View $this
* @var \Da\User\Module $module
*/ */
$this->title = Yii::t('usuario', 'Rules'); $this->title = Yii::t('usuario', 'Rules');
@ -16,7 +17,7 @@ $this->params['breadcrumbs'][] = $this->title;
?> ?>
<?php $this->beginContent('@Da/User/resources/views/shared/admin_layout.php') ?> <?php $this->beginContent($module->viewPath . '/shared/admin_layout.php') ?>
<div class="table-responsive"> <div class="table-responsive">
<?= GridView::widget( <?= GridView::widget(
[ [

View File

@ -13,14 +13,16 @@
* @var yii\web\View $this * @var yii\web\View $this
* @var \Da\User\Model\Rule $model * @var \Da\User\Model\Rule $model
* @var string[] $unassignedItems * @var string[] $unassignedItems
* @var \Da\User\Module $module
*/ */
$this->title = Yii::t('usuario', 'Update rule'); $this->title = Yii::t('usuario', 'Update rule');
$this->params['breadcrumbs'][] = ['label' => Yii::t('usuario', 'Rules'), 'url' => ['index']]; $this->params['breadcrumbs'][] = ['label' => Yii::t('usuario', 'Rules'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title; $this->params['breadcrumbs'][] = $this->title;
?> ?>
<?php $this->beginContent('@Da/User/resources/views/shared/admin_layout.php') ?> <?php $this->beginContent($module->viewPath . '/shared/admin_layout.php') ?>
<?= $this->render( <?= $this->render(
'/rule/_form', '/rule/_form',