Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
schmunk42 committed May 11, 2020
2 parents b7d8a8c + 99fb7fa commit ce6b441
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
17 changes: 16 additions & 1 deletion Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,22 @@ class Module extends \yii\base\Module
* @var array
*/
public $availableViews = [];


/**
* Whether access_domain should be used as constraint in default/page action select
*
* @var bool
*/
public $pageCheckAccessDomain = false;

/**
* Whether to search fallbackPage according to domain_id
*
* see: \dmstr\modules\pages\controllers\DefaultController::resolveFallbackPage
* @var bool
*/
public $pageUseFallbackPage = true;

/**
* @inheritdoc
*/
Expand Down
10 changes: 10 additions & 0 deletions controllers/DefaultController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

namespace dmstr\modules\pages\controllers;

use dmstr\db\traits\ActiveRecordAccessTrait;
use dmstr\modules\backend\interfaces\ContextMenuItemsInterface;
use dmstr\modules\pages\assets\PagesBackendAsset;
use dmstr\modules\pages\helpers\PageHelper;
Expand Down Expand Up @@ -140,6 +141,10 @@ public function actionPage($pageId)
]
);

if ($this->module->pageCheckAccessDomain) {
$pageQuery->andWhere(['access_domain' => [\Yii::$app->language, ActiveRecordAccessTrait::$_all]]);
}

// get page
/** @var $page Tree */
$page = $pageQuery->one();
Expand Down Expand Up @@ -202,6 +207,11 @@ public function actionPage($pageId)
*/
private function resolveFallbackPage($pageId)
{

if (!$this->module->pageUseFallbackPage) {
return false;
}

$original = Tree::find()->where(['id' => $pageId])->one();

if (empty($original)) {
Expand Down

0 comments on commit ce6b441

Please sign in to comment.