本文整理汇总了PHP中CRM_Utils_String::parsePrefix方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_String::parsePrefix方法的具体用法?PHP CRM_Utils_String::parsePrefix怎么用?PHP CRM_Utils_String::parsePrefix使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_String
的用法示例。
在下文中一共展示了CRM_Utils_String::parsePrefix方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: translatePermission
/**
* Translate permission.
*
* @param string $perm
* Permission string e.g "administer CiviCRM", "cms:access user record", "Drupal:administer content",
* "Joomla:action:com_asset"
*
* @param string $nativePrefix
* @param array $map
* Array($portableName => $nativeName).
*
* @return NULL|string
* a permission name
*/
public function translatePermission($perm, $nativePrefix, $map)
{
list($civiPrefix, $name) = CRM_Utils_String::parsePrefix(':', $perm, NULL);
switch ($civiPrefix) {
case $nativePrefix:
return $name;
// pass through
// pass through
case 'cms':
return CRM_Utils_Array::value($name, $map, CRM_Core_Permission::ALWAYS_DENY_PERMISSION);
case NULL:
return $name;
default:
return CRM_Core_Permission::ALWAYS_DENY_PERMISSION;
}
}
示例2: translateJoomlaPermission
/**
* @param $perm
*
* @internal param string $name e.g. "administer CiviCRM", "cms:access user record", "Drupal:administer content", "Joomla:example.action:com_some_asset"
* @return ALWAYS_DENY_PERMISSION|ALWAYS_ALLOW_PERMISSION|array(0 => $joomlaAction, 1 => $joomlaAsset)
*/
function translateJoomlaPermission($perm)
{
if ($perm === CRM_Core_Permission::ALWAYS_DENY_PERMISSION || $perm === CRM_Core_Permission::ALWAYS_ALLOW_PERMISSION) {
return $perm;
}
list($civiPrefix, $name) = CRM_Utils_String::parsePrefix(':', $perm, NULL);
switch ($civiPrefix) {
case 'Joomla':
return explode(':', $name);
case 'cms':
// FIXME: This needn't be DENY, but we don't currently have any translations.
return CRM_Core_Permission::ALWAYS_DENY_PERMISSION;
case NULL:
return array('civicrm.' . CRM_Utils_String::munge(strtolower($name)), 'com_civicrm');
default:
return CRM_Core_Permission::ALWAYS_DENY_PERMISSION;
}
}
示例3: testParsePrefix
/**
* @dataProvider parsePrefixData
* @param $input
* @param $defaultPrefix
* @param $expected
*/
public function testParsePrefix($input, $defaultPrefix, $expected)
{
$actual = CRM_Utils_String::parsePrefix(':', $input, $defaultPrefix);
$this->assertEquals($expected, $actual);
}