-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added new importer, removed exec command(s), added importer test
- Loading branch information
Showing
25 changed files
with
550 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace admin\importers; | ||
|
||
use Yii; | ||
|
||
class AuthImporter extends \luya\base\Importer | ||
{ | ||
public function run() | ||
{ | ||
$this->getImporter()->addLog('auth', 'start auth importer'); | ||
$modules = Yii::$app->getModules(); | ||
$data = [ | ||
'apis' => [], | ||
'routes' => [], | ||
]; | ||
foreach ($modules as $id => $item) { | ||
$object = Yii::$app->getModule($id); | ||
if (method_exists($object, 'getAuthApis')) { | ||
foreach ($object->getAuthApis() as $item) { | ||
$data['apis'][] = $item['api']; | ||
Yii::$app->auth->addApi($object->id, $item['api'], $item['alias']); | ||
} | ||
} | ||
|
||
if (method_exists($object, 'getAuthRoutes')) { | ||
foreach ($object->getAuthRoutes() as $item) { | ||
$data['routes'][] = $item['route']; | ||
Yii::$app->auth->addRoute($object->id, $item['route'], $item['alias']); | ||
} | ||
} | ||
} | ||
|
||
$toClean = Yii::$app->auth->prepareCleanup($data); | ||
if (count($toClean) > 0) { | ||
foreach ($toClean as $rule) { | ||
$this->getImporter()->addLog('auth', 'old auth rule: "'.$rule['alias_name'].'" in module '.$rule['module_name']. ' will be automaticaly deleted.'); | ||
//echo $this->ansiFormat('old auth rule: "'.$rule['alias_name'].'" in module '.$rule['module_name'], Console::FG_RED).PHP_EOL; | ||
} | ||
|
||
Yii::$app->auth->executeCleanup($toClean); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace admin\importers; | ||
|
||
class FilterImporter extends \luya\base\Importer | ||
{ | ||
public function run() | ||
{ | ||
$this->getImporter()->addLog('filters', 'start filters importer'); | ||
foreach ($this->getImporter()->getDirectoryFiles('filters') as $file) { | ||
$filterClassName = $file['ns']; | ||
if (class_exists($filterClassName)) { | ||
$object = new $filterClassName(); | ||
$this->getImporter()->addLog('filters', implode(", ", $object->save())); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.