))
->setFactoryService(self::SELF)->setFactoryMethod('createApiKernel');
+ $container->setDefinition('cxn_reg_client', new Definition(
+ '\Civi\Cxn\Rpc\RegistrationClient',
+ array()
+ ))
+ ->setFactoryService(self::SELF)->setFactoryMethod('createRegistrationClient');
+
// Expose legacy singletons as services in the container.
$singletons = array(
'resources' => 'CRM_Core_Resources',
return $kernel;
}
+ public function createRegistrationClient() {
+ $cxnStore = new \CRM_Cxn_CiviCxnStore();
+ $client = new \Civi\Cxn\Rpc\RegistrationClient(NULL, $cxnStore, \CRM_Cxn_BAO_Cxn::getSiteCallbackUrl());
+ $client->setLog(new \CRM_Utils_SystemLogger());
+ return $client;
+ }
}
+--------------------------------------------------------------------+
*/
-
/**
* @param array $params
* Array with keys:
}
\Civi\Cxn\Rpc\AppMeta::validate($params['appMeta']);
- // FIXME Move cxnStore and client into Container.
- $cxnStore = new CRM_Cxn_CiviCxnStore();
try {
- $client = new \Civi\Cxn\Rpc\RegistrationClient(NULL, $cxnStore, CRM_Cxn_BAO_Cxn::getSiteCallbackUrl());
- $client->setLog(new CRM_Utils_SystemLogger());
+ /** @var \Civi\Cxn\Rpc\RegistrationClient $client */
+ $client = \Civi\Core\Container::singleton()->get('cxn_reg_client');
list($cxnId, $isOk) = $client->register($params['appMeta']);
CRM_Cxn_BAO_Cxn::updateAppMeta($params['appMeta']);
}
$result = array(
'cxnId' => $cxnId,
);
- return civicrm_api3_create_success();
+ return civicrm_api3_create_success($result);
}
else {
return civicrm_api3_create_error('Connection failed');