You could use the hasReference()
function on the model.
E.g. your model Customer
has a relation to User
like this:
Customer:
relations:
user:
local: id
foreignID: id
foreignAlias: customer
Then you can test whether the user is of type customer (in the controller):
$this->getUser()->getGuardUser()->hasReference('customer');
To make this easier you can add this method to your myUser
class:
public function isCustomer() {
return $this->getGuardUser()->hasReference('customer');
}
Same of course for Enterprise.
Even using two different tables, you can make use of the hasCredential()
method, and this is the easiest way if you only want to check for permission.
If you want to access certain attributes of the enterprise and customer user you can also combine both approaches.
Update:
Well, assuming that Customers and Enterprise users have different permissions, I would go with the user group approach. This fits better to the group model of sfGuard. If you then know that a user is in group Customer
, you know that the user has a reference to a customer object.
But this means of course that you have to assign the the right group to a new user in order to work correctly.