本文整理汇总了PHP中sfGuardPermissionPeer::retrieveByName方法的典型用法代码示例。如果您正苦于以下问题:PHP sfGuardPermissionPeer::retrieveByName方法的具体用法?PHP sfGuardPermissionPeer::retrieveByName怎么用?PHP sfGuardPermissionPeer::retrieveByName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfGuardPermissionPeer
的用法示例。
在下文中一共展示了sfGuardPermissionPeer::retrieveByName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPermission
/**
* Get a permission given to an id or a name.
* @param Mixed $permission
* @return Boolean
*/
public static function getPermission($permission)
{
$return = sfGuardPermissionPeer::retrieveByPK($permission);
if (!$return) {
$return = sfGuardPermissionPeer::retrieveByName($permission);
}
return $return;
}
示例2: addPermissionByName
public function addPermissionByName($name, $con = null)
{
$permission = sfGuardPermissionPeer::retrieveByName($name);
if (!$permission) {
throw new Exception(sprintf('The permission "%s" does not exist.', $name));
}
$up = new sfGuardUserPermission();
$up->setsfGuardUser($this);
$up->setPermissionId($permission->getId());
$up->save($con);
}
示例3: grantProjectGroupPermission
public function grantProjectGroupPermission($group_name, $permission_name)
{
$permission = sfGuardPermissionPeer::retrieveByName($this->getUuid() . '-' . $permission_name);
$group = sfGuardGroupPeer::retrieveByName($this->getUuid() . '-' . $group_name);
if ($permission == null) {
sfContext::getInstance()->getLogger()->info('permission not found: [' . $this->getUuid() . $permission_name . ']');
return false;
} elseif ($group == null) {
sfContext::getInstance()->getLogger()->info('group not found: [' . $this->getUuid() . $group_name . ']');
return false;
}
// TODO: make sure that the group permission name does not already exist
$groupPermission = new sfGuardGroupPermission();
$groupPermission->setGroupId($group->getPrimaryKey());
$groupPermission->setPermissionId($permission->getId());
$groupPermission->save();
sfContext::getInstance()->getLogger()->info('group permission saved: [' . $this->getUuid() . $group_name . ']:[' . $this->getUuid() . $permission_name . ']');
}