I am working on a PHP application and I would like to add access control to some of my objects. I did not mark this question as PHP, since I feel that this question is language independent.
Say I have a "class of service"
abstract class Service {
}
Many services use this as a base class. One pseudo example:
class Companies extends Service {
function getCompanyInfo($id) {
}
}
Later on the road, I want to add access control. The getCompanyInfoById example is a read operation, so this will require the “read” privilege.
At this point, I can implement this as follows:
- Add accesscontrol to the service class. Each method (for example, getCompanyInfoById) must first call the hasPrivilege method before completing the operation and returning the result.
- - -, .
- "" .
:
- ,
,
. ,
.
- ,
.
,
.
- , , . "", .
?