本文整理汇总了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;
}