Skip to content

Commit

Permalink
Implementation of new luya base module $apiRules. #174
Browse files Browse the repository at this point in the history
  • Loading branch information
nadar committed Jul 9, 2018
1 parent b510d43 commit b3b1c10
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ All notable changes to this project will be documented in this file. This projec

### Added

+ [#174](https://github.com/luyadev/luya-module-admin/issues/174) Implementation of new luya base module $apiRules.
+ [#164](https://github.com/luyadev/luya-module-admin/pull/164) Turkish translations for admin and core modules.
+ [#161](https://github.com/luyadev/luya-module-admin/issues/161) NgRest CRUD exporter provides now the option to download xlsx.
+ [#157](https://github.com/luyadev/luya-module-admin/issues/157) Added `getTitle()` method for Active Windows in order to provide model context modal titles.
Expand Down
18 changes: 15 additions & 3 deletions src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,14 @@ final class Module extends \luya\admin\base\Module implements CoreModuleInterfac
'api-admin-proxybuild' => 'luya\admin\apis\ProxyBuildController',
'api-admin-proxy' => 'luya\admin\apis\ProxyController',
'api-admin-config' => 'luya\admin\apis\ConfigController',

];

/**
* @var array An array with all apis from every module, this property is assigned by the {{luya\web\Bootstrap::run()}} method.
* @since 1.2.2
*/
public $apiDefintions = [];

/**
* @var array This property is used by the {{luya\web\Bootstrap::run()}} method in order to set the collected asset files to assign.
*/
Expand All @@ -219,12 +224,19 @@ public static function onLoad()
*/
public function getUrlRules()
{
return [
['class' => 'luya\admin\components\UrlRule', 'cacheFlag' => Yii::$app->request->isAdmin],
$rules = [
['pattern' => 'file/<id:\d+>/<hash:\w+>/<fileName:(.*?)+>', 'route' => 'admin/file/download'],
['pattern' => 'admin', 'route' => 'admin/default/index'],
['pattern' => 'admin/login', 'route' => 'admin/login/index'],
];

foreach ($this->apiDefintions as $definition) {
$definition['class'] = 'luya\admin\components\UrlRule';
$definition['cacheFlag'] = Yii::$app->request->isAdmin;
$rules[] = $definition;
}

return $rules;
}

/**
Expand Down
5 changes: 4 additions & 1 deletion src/components/UrlRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class UrlRule extends \yii\rest\UrlRule
{
/**
* @var boolean This is used for ensure the url rule caching since 2.0.14
* @var boolean This is used to ensure the url rule caching works with yii version 2.0.14
* @see https://github.com/luyadev/luya-module-admin/issues/68
*/
public $cacheFlag;
Expand All @@ -31,6 +31,7 @@ class UrlRule extends \yii\rest\UrlRule
/**
* @inheritdoc
*/
/*
public function init()
{
// get all controller mappings
Expand All @@ -41,6 +42,7 @@ public function init()
if (count($map) > 0) {
// assign the url rule from the admins controller map
foreach ($map as $alias => $className) {
// effect controller roule would be: `admin/api-admin-user` as its registered in the controller map of the admin module`.
$this->controller[] = sprintf('%s/%s', 'admin', $alias);
}
Expand All @@ -52,4 +54,5 @@ public function init()
// an error.
$this->controller = [];
}
*/
}

0 comments on commit b3b1c10

Please sign in to comment.