A free and open-source book on Zend Framework for beginners


17.7. Implementing Role Management

In the Role Demo sample, we will create a convenient user interface for managing roles.

You can access the role management page by logging in as admin@example.com and opening menu Admin -> Manage Roles.

The role management will be implemented inside the RoleController controller living in the User\Controller namespace. The action methods of the RoleController are listed in table 17.4:

Table 17.4. Actions of the RoleController controller
Action Name Description
addAction() Allows to add a new role.
deleteAction() Deletes an existing role.
editAction() Allows to edit an existing role.
editPermissionsAction() Allows to assign permissions to a role.
indexAction() Displays the list of existing roles.
viewAction() Displays the details of a role.

The RoleController works in pair with the RoleManager service which lives in User\Service namespace.

The RoleController and RoleManager contain nothing new and special, so we will skip their discussion here and will just provide some screenshots of the resulting user interface below.

You can find the complete code of the RoleController and RoleManager classes in the Role Demo sample.

Figure 17.3 The list of roles Figure 17.3 The list of roles

Figure 17.4 Create a new role Figure 17.4 Create a new role

Figure 17.5 View details of a role Figure 17.5 View details of a role

Figure 17.6 Edit an existing role Figure 17.6 Edit an existing role

Figure 17.7 Assign permissions to a role Figure 17.7 Assign permissions to a role


Top