<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.6 |
+ | CiviCRM version 4.7 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2016 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
CRM_Utils_System::loadBootStrap(array(), FALSE);
-$apiServer = new \Civi\Cxn\Rpc\ApiServer(new CRM_Cxn_CiviCxnStore());
-$apiServer->setLog(new CRM_Utils_SystemLogger());
-$apiServer->setRouter(function ($cxn, $entity, $action, $params) {
- require_once 'api/v3/utils.php';
-
- // Note: cxnId is authenticated before router is called.
- $dao = new CRM_Cxn_DAO_Cxn();
- $dao->cxn_id = $cxn['cxnId'];
- if (empty($cxn['cxnId']) || !$dao->find(TRUE) || !$dao->cxn_id) {
- return civicrm_api3_create_error('Failed to lookup connection authorizations.');
- }
- if (!$dao->is_active) {
- return civicrm_api3_create_error('Connection is inactive');
- }
-
- // FIXME: apply $dao->perm
-
- return civicrm_api($entity, $action, $params);
-
-});
-$apiServer->handleAndRespond(file_get_contents('php://input'));
+CRM_Cxn_BAO_Cxn::createApiServer()
+ ->handle(file_get_contents('php://input'))
+ ->send();