本文整理汇总了PHP中Permission::getFriendlyName方法的典型用法代码示例。如果您正苦于以下问题:PHP Permission::getFriendlyName方法的具体用法?PHP Permission::getFriendlyName怎么用?PHP Permission::getFriendlyName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Permission
的用法示例。
在下文中一共展示了Permission::getFriendlyName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addPermission
function addPermission($permissionCfg)
{
// verify obligatory fields
if (!$permissionCfg->name) {
throw new Exception('Permission name must be set');
}
if (is_null($permissionCfg->partnerId) || $permissionCfg->partnerId === '') {
throw new Exception('Permission partner id must be set');
}
// init new db permission object
$permission = new Permission();
foreach ($permissionCfg as $key => $value) {
$setterCallback = array($permission, "set{$key}");
call_user_func_array($setterCallback, array($value));
}
if (!$permission->getFriendlyName()) {
$permission->setFriendlyName($permission->getName());
}
if (!$permission->getStatus()) {
$permission->setStatus(PermissionStatus::ACTIVE);
}
// add to database
KalturaLog::log('Adding new permission with name [' . $permission->getName() . '] to partner id [' . $permission->getPartnerId() . ']');
try {
PermissionPeer::addToPartner($permission, $permission->getPartnerId());
} catch (kPermissionException $e) {
if ($e->getCode() === kPermissionException::PERMISSION_ALREADY_EXISTS) {
KalturaLog::log('Permission name [' . $permission->getName() . '] already exists for partner id [' . $permission->getPartnerId() . ']');
} else {
throw $e;
}
}
}
示例2: addPermissionToPartner
function addPermissionToPartner($permissionCfg, $partnerId = null)
{
// init new db permission object
if (is_null($partnerId)) {
$partnerId = $permissionCfg->partnerId;
}
PermissionPeer::setUseCriteriaFilter(false);
$permission = PermissionPeer::getByNameAndPartner($permissionCfg->name, $partnerId);
PermissionPeer::setUseCriteriaFilter(true);
if (!$permission) {
$permission = new Permission();
}
foreach ($permissionCfg as $key => $value) {
if ($key == 'partnerPackages') {
continue;
}
$setterCallback = array($permission, "set{$key}");
call_user_func_array($setterCallback, array($value));
}
if (!$permission->getFriendlyName()) {
$permission->setFriendlyName($permission->getName());
}
if ($partnerId != null) {
$permission->setPartnerId($partnerId);
}
$permission->setStatus(PermissionStatus::ACTIVE);
// add to database
KalturaLog::log('Adding new permission with name [' . $permission->getName() . '] to partner id [' . $permission->getPartnerId() . ']');
try {
if ($permission->getId()) {
$permission->save();
} else {
PermissionPeer::addToPartner($permission, $permission->getPartnerId());
}
} catch (kPermissionException $e) {
if ($e->getCode() === kPermissionException::PERMISSION_ALREADY_EXISTS) {
KalturaLog::log('Permission name [' . $permission->getName() . '] already exists for partner id [' . $permission->getPartnerId() . ']');
} else {
throw $e;
}
}
}
示例3: Permission
// live stream
$allowedLiveStream = $partner->getFromCustomData("liveEnabled", null, 0);
if ($allowedLiveStream) {
$livePermission = new Permission();
$livePermission->setPartnerId($partner->getId());
$livePermission->setName(PermissionName::FEATURE_LIVE_STREAM);
$livePermission->setFriendlyName('Live stream feature');
$livePermission->setDescription('Permission to use live stream');
$livePermission->setStatus(PermissionStatus::ACTIVE);
$livePermission->setType(PermissionType::SPECIAL_FEATURE);
$newPermissions[] = $livePermission;
}
if (!$dryRun) {
foreach ($newPermissions as $permission) {
KalturaLog::log('SAVING new permission for partner [' . $partner->getId() . ']:');
PermissionPeer::enableForPartner($permission->getName(), $permission->getType(), $partner->getId(), $permission->getFriendlyName(), $permission->getDescription());
KalturaLog::log(print_r($permission, true));
}
} else {
foreach ($newPermissions as $permission) {
KalturaLog::log('DRY RUN ONLY - new permission for partner [' . $partner->getId() . ']:');
KalturaLog::log(print_r($permission, true));
// dry run - no saving!
}
}
file_put_contents($lastPartnerFile, $lastPartner);
}
$partners = getPartners($lastPartner, $partnerLimitEachLoop);
}
$msg = 'Done - ' . ($dryRun ? 'DRY RUN!' : 'REAL RUN!');
KalturaLog::log($msg);