/**
 * (Delegated) Implementation of hook_civicrm_caseTypes
 *
 * Find any and return any files matching "xml/case/*.xml"
 *
 * Note: This hook only runs in CiviCRM 4.4+.
 *
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_caseTypes
 */
function _mailchimp_civix_civicrm_caseTypes(&$caseTypes)
{
    if (!is_dir(__DIR__ . '/xml/case')) {
        return;
    }
    foreach (_mailchimp_civix_glob(__DIR__ . '/xml/case/*.xml') as $file) {
        $name = preg_replace('/\\.xml$/', '', basename($file));
        if ($name != CRM_Case_XMLProcessor::mungeCaseType($name)) {
            $errorMessage = sprintf("Case-type file name is malformed (%s vs %s)", $name, CRM_Case_XMLProcessor::mungeCaseType($name));
            CRM_Core_Error::fatal($errorMessage);
            // throw new CRM_Core_Exception($errorMessage);
        }
        $caseTypes[$name] = array('module' => 'uk.co.vedaconsulting.mailchimp', 'name' => $name, 'file' => $file);
    }
}
/**
 * (Delegated) Implements hook_civicrm_angularModules().
 *
 * Find any and return any files matching "ang/*.ang.php"
 *
 * Note: This hook only runs in CiviCRM 4.5+.
 *
 * @link http://wiki.civicrm.org/confluence/display/CRMDOC/hook_civicrm_angularModules
 */
function _mailchimp_civix_civicrm_angularModules(&$angularModules)
{
    if (!is_dir(__DIR__ . '/ang')) {
        return;
    }
    $files = _mailchimp_civix_glob(__DIR__ . '/ang/*.ang.php');
    foreach ($files as $file) {
        $name = preg_replace(':\\.ang\\.php$:', '', basename($file));
        $module = (include $file);
        if (empty($module['ext'])) {
            $module['ext'] = 'uk.co.vedaconsulting.mailchimp';
        }
        $angularModules[$name] = $module;
    }
}