本文整理匯總了PHP中CRM_Core_BAO_Navigation::getNavItemByUrl方法的典型用法代碼示例。如果您正苦於以下問題:PHP CRM_Core_BAO_Navigation::getNavItemByUrl方法的具體用法?PHP CRM_Core_BAO_Navigation::getNavItemByUrl怎麽用?PHP CRM_Core_BAO_Navigation::getNavItemByUrl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CRM_Core_BAO_Navigation
的用法示例。
在下文中一共展示了CRM_Core_BAO_Navigation::getNavItemByUrl方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testGetNavItemByUrl
/**
* Test that a navigation item can be retrieved by it's url.
*/
public function testGetNavItemByUrl()
{
$random_string = substr(sha1(rand()), 0, 7);
$name = "Test Menu Link {$random_string}";
$url = "civicrm/test/{$random_string}";
$url_params = "reset=1";
$params = array('name' => $name, 'label' => ts($name), 'url' => "{$url}?{$url_params}", 'parent_id' => NULL, 'is_active' => TRUE, 'permission' => array('access CiviCRM'));
CRM_Core_BAO_Navigation::add($params);
$new_nav = CRM_Core_BAO_Navigation::getNavItemByUrl($url, $url_params);
$this->assertObjectHasAttribute('id', $new_nav);
$this->assertNotNull($new_nav->id);
$new_nav->delete();
}
示例2: createOrUpdateReportNavItem
/**
* Create or update a navigation item for a report instance.
*
* The function will check whether create or update is required.
*
* @param string $name
* @param string $url
* @param string $url_params
* @param int $parent_id
* @param string $permission
* @param int $domain_id
*
* @param bool $onlyMatchParentID
* If True then do not match with a url that has a different parent
* (This is because for top level items there is a risk of 'stealing' rows that normally
* live under 'Contact' and intentionally duplicate the report examples.)
*
* @return \CRM_Core_DAO_Navigation
*/
protected static function createOrUpdateReportNavItem($name, $url, $url_params, $parent_id, $permission, $domain_id, $onlyMatchParentID = FALSE, $useWildcard = TRUE)
{
$id = NULL;
$existing_url_params = $useWildcard ? $url_params . '%' : $url_params;
$existing_nav = CRM_Core_BAO_Navigation::getNavItemByUrl($url, $existing_url_params, $onlyMatchParentID ? $parent_id : NULL);
if ($existing_nav) {
$id = $existing_nav->id;
}
$nav = self::createReportNavItem($name, $url, $url_params, $parent_id, $permission, $id, $domain_id);
return $nav;
}