本文整理汇总了PHP中CRM_Contact_BAO_ContactType::contactTypes方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Contact_BAO_ContactType::contactTypes方法的具体用法?PHP CRM_Contact_BAO_ContactType::contactTypes怎么用?PHP CRM_Contact_BAO_ContactType::contactTypes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Contact_BAO_ContactType
的用法示例。
在下文中一共展示了CRM_Contact_BAO_ContactType::contactTypes方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetMethods
/**
* Test contactTypes() and subTypes() methods with valid data
* success expected
*/
public function testGetMethods()
{
// check all contact types
$contactTypes = array('Individual', 'Organization', 'Household');
$result = CRM_Contact_BAO_ContactType::contactTypes('Individual');
foreach ($contactTypes as $type) {
$this->assertEquals(in_array($type, $result), TRUE);
}
// check for type:Individual
$result = CRM_Contact_BAO_ContactType::subTypes('Individual');
foreach ($result as $subtype) {
$subTypeName = in_array($subtype, $this->subTypesIndividual);
if (!empty($subTypeName)) {
$this->assertEquals($subTypeName, TRUE);
}
$this->assertEquals(in_array($subtype, $this->subTypesOrganization), FALSE);
$this->assertEquals(in_array($subtype, $this->subTypesHousehold), FALSE);
}
// check for type:Organization
$result = CRM_Contact_BAO_ContactType::subTypes('Organization');
foreach ($result as $subtype) {
$this->assertEquals(in_array($subtype, $this->subTypesIndividual), FALSE);
$subTypeName = in_array($subtype, $this->subTypesOrganization);
if (!empty($subTypeName)) {
$this->assertEquals($subTypeName, TRUE);
}
$subTypeName = in_array($subTypeName, $this->subTypesHousehold);
if (empty($subTypeName)) {
$this->assertEquals($subTypeName, FALSE);
}
}
// check for type:Household
$result = CRM_Contact_BAO_ContactType::subTypes('Household');
foreach ($result as $subtype) {
$this->assertEquals(in_array($subtype, $this->subTypesIndividual), FALSE);
$this->assertEquals(in_array($subtype, $this->subTypesOrganization), FALSE);
$this->assertEquals(in_array($subtype, $this->subTypesHousehold), TRUE);
}
// check for all conatct types
$result = CRM_Contact_BAO_ContactType::subTypes();
foreach ($this->subTypesIndividual as $subtype) {
$this->assertEquals(in_array($subtype, $result), TRUE);
}
foreach ($this->subTypesOrganization as $subtype) {
$this->assertEquals(in_array($subtype, $result), TRUE);
}
foreach ($this->subTypesHousehold as $subtype) {
$this->assertEquals(in_array($subtype, $result), TRUE);
}
}
示例2: isProviderEnabled
/**
* Check if a provider is allowed to add stuff.
* If correspondig setting is empty, all are allowed
*
* @param string $providerName
*/
public static function isProviderEnabled($providerName)
{
// Join contact types to providerName 'Contact'
$contactTypes = CRM_Contact_BAO_ContactType::contactTypes(TRUE);
if (in_array($providerName, $contactTypes)) {
$providerName = 'Contact';
}
$allowed = TRUE;
// Use core setting recentItemsProviders if configured
$providersPermitted = Civi::settings()->get('recentItemsProviders');
if ($providersPermitted) {
$allowed = in_array($providerName, $providersPermitted);
}
// Else allow
return $allowed;
}