Skip to content

Commit

Permalink
Bug fix for registerTranslations() method. Set it static
Browse files Browse the repository at this point in the history
  • Loading branch information
itstructure committed Jul 17, 2020
1 parent f53c104 commit 35dcc15
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 47 deletions.
80 changes: 34 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
Yii2 RBAC module
==============
# Yii2 RBAC module

1 Introduction
----------------------------
## Introduction

[![Latest Stable Version](https://poser.pugx.org/itstructure/yii2-rbac-module/v/stable)](https://packagist.org/packages/itstructure/yii2-rbac-module)
[![Latest Unstable Version](https://poser.pugx.org/itstructure/yii2-rbac-module/v/unstable)](https://packagist.org/packages/itstructure/yii2-rbac-module)
Expand All @@ -11,41 +9,31 @@ Yii2 RBAC module
[![Build Status](https://scrutinizer-ci.com/g/itstructure/yii2-rbac-module/badges/build.png?b=master)](https://scrutinizer-ci.com/g/itstructure/yii2-rbac-module/build-status/master)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/itstructure/yii2-rbac-module/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/itstructure/yii2-rbac-module/?branch=master)

**Rbac module** -- Module for the Yii2 framework, which provides management with the next data:
**RBAC module** - Module for the Yii2 framework, which provides management with the next data:
- Roles
- Permissions

2 Dependencies
----------------------------
![RBAC extension structure](https://github.com/itstructure/yii2-rbac-module/blob/master/yii2_rbac_structure_en.jpg)

## Dependencies

- php >= 7.1
- composer
- MySql >= 5.5

3 Installation
----------------------------
## Installation

### 3.1 General from remote repository
### General from remote repository

Via composer:

```composer require "itstructure/yii2-rbac-module": "^3.0.0"```

or in section **require** of composer.json file set the following:
```
"require": {
"itstructure/yii2-rbac-module": "^3.0.0"
}
```
and command ```composer install```, if you install yii2 project extensions first,

or command ```composer update```, if all yii2 project extensions are already installed.
`composer require itstructure/yii2-rbac-module "~3.0.1"`

### 3.2 If you are testing this package from local server directory
### If you are testing this package from local server directory

In application ```composer.json``` file set the repository, like in example:
In application `composer.json` file set the repository, like in example:

```
```json
"repositories": [
{
"type": "path",
Expand All @@ -63,9 +51,9 @@ Here,

Then run command:

```composer require itstructure/yii2-rbac-module:dev-master --prefer-source```
`composer require itstructure/yii2-rbac-module:dev-master --prefer-source`

### 3.3 Addition components
### Addition components

In accordance with the [documentation for Yii2](http://www.yiiframework.com/doc-2.0/guide-security-authorization.html), set **authManager** for application:

Expand All @@ -84,27 +72,26 @@ In accordance with the [documentation for Yii2](http://www.yiiframework.com/doc-
yii migrate --migrationPath=@yii/rbac/migrations
```

4 Usage
----------------------------
## Usage

### Main properties

- The **name** of module: `rbac`
- The **namespace** for used classes: `Itstructure\RbacModule`.
- The **alias** to access in to module root directory: `@rbac`.

### 4.1 Main properties
- **There is not a layout !** It's taken from application layout **main** by default **or how it is configured**. You cat set `layout` attribute in module by custom.

- The **name** of module: ```rbac```
- The **namespace** for used classes: ```Itstructure\RbacModule```.
- The **alias** to access in to module root directory: ```@rbac```.
- **There is not a layout !** It's taken from application layout **main** by default **or how it is
configured**.
You cat set ```layout``` attribute in module by custom.
- **View** component is taken by default from the framework like **yii\web\View**. You cat set
**view** component in module by custom.
- **View** component is taken by default from the framework like **yii\web\View**. You cat set **view** component in module by custom.

### 4.2 Application config
### Application config
Base application config must be like in example below:

```php
use Itstructure\RbacModule\Module;
use Itstructure\RbacModule\controllers\{RoleController, PermissionController, ProfileController};
```

```php
'modules' => [
'rbac' => [
Expand All @@ -118,16 +105,17 @@ use Itstructure\RbacModule\controllers\{RoleController, PermissionController, Pr
],
```

### 4.3 Useful module attributes
### Useful module attributes

You can set the following attributes in a module config:

- ```loginUrl``` - set url to be redirected if you are not authorized.
- ```accessRoles``` - The roles of users who are allowed access to work with this package.
- ```urlPrefix``` - Url prefix for redirect and view links (Default is empty).
- ```urlPrefixNeighbor``` - Url prefix for redirect and view links of neighbor entity (Default is empty).
- `loginUrl` - set url to be redirected if you are not authorized.
- `accessRoles` - The roles of users who are allowed access to work with this package.
- `urlPrefix` - Url prefix for redirect and view links (Default is empty).
- `urlPrefixNeighbor` - Url prefix for redirect and view links of neighbor entity (Default is empty).

License
----------------------------
## License

Copyright © 2018 Andrey Girnik girnikandrey@gmail.com.
Copyright © 2018-2020 Andrey Girnik girnikandrey@gmail.com.

Licensed under the [MIT license](http://opensource.org/licenses/MIT). See LICENSE.txt for details.
4 changes: 4 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
### CHANGE LOG:

**3.0.1 July 17, 2020:**
- Bug fix for `registerTranslations()` method. Set it static.
- Readme fixes.

**3.0.0 August 5, 2018:**
- Code fixes according with the PSR standards.
- Rename ```RolesController``` to ```RoleController```.
Expand Down
2 changes: 1 addition & 1 deletion src/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public static function t($category, $message, $params = [], $language = null)
*
* @return void
*/
private function registerTranslations(): void
private static function registerTranslations(): void
{
self::$_translations = [
'modules/rbac/*' => [
Expand Down
Binary file added yii2_rbac_structure_en.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 35dcc15

Please sign in to comment.