public static function createCachedPermissions() { $auth = \Yii::$app->authManager; $newLine = "\r\n"; $content = '<?php' . $newLine; $permissionContent = ''; $categories = $auth->getChildren('root_permission'); foreach ($categories as $category) { $content .= '$cachedPermissionCategories[\'' . $category->name . '\'] = [' . $newLine; $content .= AuthItem::createItem($category); $content .= "\t'permissions' => [" . $newLine; $permissions = $auth->getChildren($category->name); foreach ($permissions as $permission) { $content .= "\t\t'" . $permission->name . "'," . $newLine; $permissionContent .= '$cachedPermissions[\'' . $permission->name . '\'] = [' . $newLine; $permissionContent .= AuthItem::getCacheItemValue('category', $category->name); $permissionContent .= AuthItem::createItem($permission); $permissionContent .= "];" . $newLine; } $content .= ' ],' . $newLine; $content .= "];" . $newLine; } $content .= $permissionContent; $dataRoot = \Yii::getAlias('@data'); TFileHelper::writeFile([$dataRoot, 'cache', 'cachedPermissions.php'], $content); }