How to customize the RESTful Data Model of Yii2

Source: Internet
Author: User
How to Write a Model to inherit yiibaseModel to implement all RESTful operations. Now my main problem is that I use RESTful and RBAC of Yii2. Now I want users to modify their permissions in the background. For example, permission management PermissionManager column... how to write a Model inheritance yii\base\ModelTo implement all RESTful operations.

Now my main problem is that I use RESTful and RBAC of Yii2. Now I want users to modify their permissions in the background.

For example, Permission management Permission Manager

The real code that lists all permissions. This is the data source.

$ Auth = Yii: $ app-> getAuthManager ();
$ Permissions = $ auth-> getPermissions ();

Create a permission:
Of course, permissionName is the value input by the recipient.

$ Auth = Yii: $ app-> getAuthManager ();
$ PermissionNode = $ auth-> createPermission ($ permissionName );
$ Auth-> add ($ permissionNode );

In any case, you are welcome to give more suggestions and implementation methods.

Reply content:

How to Write a Model inheritance by yourselfyii\base\ModelTo implement all RESTful operations.

Now my main problem is that I use RESTful and RBAC of Yii2. Now I want users to modify their permissions in the background.

For example, Permission management Permission Manager

The real code that lists all permissions. This is the data source.

$ Auth = Yii: $ app-> getAuthManager ();
$ Permissions = $ auth-> getPermissions ();

Create a permission:
Of course, permissionName is the value input by the recipient.

$ Auth = Yii: $ app-> getAuthManager ();
$ PermissionNode = $ auth-> createPermission ($ permissionName );
$ Auth-> add ($ permissionNode );

In any case, you are welcome to give more suggestions and implementation methods.

Use a custom public interface.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.