コード例 #1
0
 /**
  * @param bool $fresh
  * @return CRM_Cxn_CiviCxnHttp
  */
 public static function singleton($fresh = FALSE)
 {
     if (self::$singleton === NULL || $fresh) {
         $cache = CRM_Utils_Cache::create(array('name' => 'CiviCxnHttp', 'type' => Civi::settings()->get('debug_enabled') ? 'ArrayCache' : array('SqlGroup', 'ArrayCache'), 'prefetch' => FALSE));
         self::$singleton = new CRM_Cxn_CiviCxnHttp($cache);
     }
     return self::$singleton;
 }
コード例 #2
0
ファイル: CiviCxnHttp.php プロジェクト: kidaa30/yes
 /**
  * @param bool $fresh
  * @return CRM_Cxn_CiviCxnHttp
  */
 public static function singleton($fresh = FALSE)
 {
     if (self::$singleton === NULL || $fresh) {
         $config = CRM_Core_Config::singleton();
         if ($config->debug) {
             $cache = new CRM_Utils_Cache_Arraycache(array());
         } else {
             $cache = new CRM_Utils_Cache_SqlGroup(array('group' => 'CiviCxnHttp', 'prefetch' => FALSE));
         }
         self::$singleton = new CRM_Cxn_CiviCxnHttp($cache);
     }
     return self::$singleton;
 }
コード例 #3
0
ファイル: CxnApp.php プロジェクト: nielosz/civicrm-core
/**
 * Get a list of applications available for connections.
 *
 * @param array $params
 * @return array
 * @throws API_Exception
 * @throws CRM_Core_Exception
 * @throws \Civi\Cxn\Rpc\Exception\InvalidMessageException
 */
function civicrm_api3_cxn_app_get($params)
{
    // You should not change CIVICRM_CXN_APPS_URL in production; this is for local development.
    $url = defined('CIVICRM_CXN_APPS_URL') ? CIVICRM_CXN_APPS_URL : \Civi\Cxn\Rpc\Constants::OFFICIAL_APPMETAS_URL;
    list($headers, $blob, $code) = CRM_Cxn_CiviCxnHttp::singleton()->send('GET', $url, '');
    if ($code != 200) {
        throw new API_Exception("Failed to download application list.");
    }
    $agent = new \Civi\Cxn\Rpc\Agent(NULL, NULL);
    $agent->setCertValidator(CRM_Cxn_BAO_Cxn::createCertificateValidator());
    $message = $agent->decode(array(AppMetasMessage::NAME, GarbledMessage::NAME), $blob);
    if ($message instanceof AppMetasMessage) {
        return _civicrm_api3_basic_array_get('CxnApp', $params, $message->getData(), 'appId', array('appId', 'appUrl', 'desc', 'appCert', 'perm'));
    } elseif ($message instanceof GarbledMessage) {
        return civicrm_api3_create_error('Received garbled response', array('garbled_message' => $message->getData()));
    } else {
        return civicrm_api3_create_error("Unrecognized message");
    }
}
コード例 #4
0
ファイル: Cxn.php プロジェクト: kidaa30/yes
 /**
  * @return DefaultCertificateValidator
  * @throws CRM_Core_Exception
  */
 public static function createCertificateValidator()
 {
     $caCert = self::getCACert();
     if ($caCert === NULL) {
         return new DefaultCertificateValidator(NULL, NULL, NULL, NULL);
     } else {
         return new DefaultCertificateValidator($caCert, DefaultCertificateValidator::AUTOLOAD, DefaultCertificateValidator::AUTOLOAD, CRM_Cxn_CiviCxnHttp::singleton());
     }
 }