本文整理匯總了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);
}