user1098965
user1098965

Reputation:

Check if a role is granted using a regular expression in Symfony2?

My roles are something like SEND_SMS_100, SEND_SMS_200 or more in general SEND_SMS_X where X is an integer. It's the maximum number of small text message that an user can send over a month. An user should have at max one of this role. I'm looking for:

AFAIK this will not support regular expression based search:

$this->get('security.context')->isGranted($roleName);

Upvotes: 0

Views: 1429

Answers (1)

Chris McKinnel
Chris McKinnel

Reputation: 15082

I think this is bad design - this shouldn't be something that is controlled by roles.

You should probably have a $smsPerMonth property on your user entity so you can call getSmsPerMonth() instead of using many different roles to figure out how many SMS messages a user can send.

Upvotes: 6

Related Questions