I would like to hear your thoughts about the task I have in front of me. Also if there is any known design pattern for this, a share would do a lot.
The task is to create the architecture of the project.
There will be several types of users :
- normal user
- supervisor
- administrator
- custom (here is the tricky part)
When they open the webpage I need to return every module (page) the user has access to.
I was thinking of polymorphism. I will have a base user which has permissions as protected property and every new class, for ex. supervisor, will add some more or overwrite the base ones.
Every module has components (parts of the webpage) and the result of the get will be something like this
$modulesAccess = [
'baseModel' => array(
'componentOne',
'componentTwo',
),
]
With this the front-end developers will know what exactly to draw.
I was thinking to make these models/components in the database but it is going to be easier to manage them through the code. And polymorphism does good enough job for us there.
The tricky part, custom user. The idea is every Model/Component will have a different ajax request to return specific data. And every upper level user must implement it differently. That is fine, but the custom user, lets say for example is a supervisor, he needs to have access to only one Model/Component from the administrator.
How would you handle this?
Thank you in advance.