Merge pull request #16177 from eileenmcnaughton/sess
[civicrm-core.git] / CRM / Cxn / CiviCxnStore.php
index 8503fa24abdc8385e2015fb0632fc10f6475181a..972fbfa1dbc039a7a75931c05bcc47e7cb57aa08 100644 (file)
@@ -1,15 +1,18 @@
 <?php
 
+/**
+ * Class CRM_Cxn_CiviCxnStore
+ */
 class CRM_Cxn_CiviCxnStore implements Civi\Cxn\Rpc\CxnStore\CxnStoreInterface {
 
-  protected $cxns = array();
+  protected $cxns = [];
 
   /**
    * @inheritDoc
    */
   public function getAll() {
     if (!$this->cxns) {
-      $this->cxns = array();
+      $this->cxns = [];
       $dao = new CRM_Cxn_DAO_Cxn();
       $dao->find();
       while ($dao->fetch()) {
@@ -28,7 +31,7 @@ class CRM_Cxn_CiviCxnStore implements Civi\Cxn\Rpc\CxnStore\CxnStoreInterface {
       return $this->cxns[$cxnId];
     }
     $dao = new CRM_Cxn_DAO_Cxn();
-    $dao->cxn_id = $cxnId;
+    $dao->cxn_guid = $cxnId;
     if ($dao->find(TRUE)) {
       $this->cxns[$cxnId] = $this->convertDaoToCxn($dao);
       return $this->cxns[$cxnId];
@@ -43,10 +46,10 @@ class CRM_Cxn_CiviCxnStore implements Civi\Cxn\Rpc\CxnStore\CxnStoreInterface {
    */
   public function getByAppId($appId) {
     $dao = new CRM_Cxn_DAO_Cxn();
-    $dao->app_id = $appId;
+    $dao->app_guid = $appId;
     if ($dao->find(TRUE)) {
-      $this->cxns[$dao->cxn_id] = $this->convertDaoToCxn($dao);
-      return $this->cxns[$dao->cxn_id];
+      $this->cxns[$dao->cxn_guid] = $this->convertDaoToCxn($dao);
+      return $this->cxns[$dao->cxn_guid];
     }
     else {
       return NULL;
@@ -58,7 +61,7 @@ class CRM_Cxn_CiviCxnStore implements Civi\Cxn\Rpc\CxnStore\CxnStoreInterface {
    */
   public function add($cxn) {
     $dao = new CRM_Cxn_DAO_Cxn();
-    $dao->cxn_id = $cxn['cxnId'];
+    $dao->cxn_guid = $cxn['cxnId'];
     $dao->find(TRUE);
     $this->convertCxnToDao($cxn, $dao);
     $dao->save();
@@ -68,9 +71,9 @@ class CRM_Cxn_CiviCxnStore implements Civi\Cxn\Rpc\CxnStore\CxnStoreInterface {
       WHERE created_date IS NULL
       AND cxn_guid = %1
       ';
-    CRM_Core_DAO::executeQuery($sql, array(
-      1 => array($cxn['cxnId'], 'String'),
-    ));
+    CRM_Core_DAO::executeQuery($sql, [
+      1 => [$cxn['cxnId'], 'String'],
+    ]);
 
     $this->cxns[$cxn['cxnId']] = $cxn;
   }
@@ -79,9 +82,9 @@ class CRM_Cxn_CiviCxnStore implements Civi\Cxn\Rpc\CxnStore\CxnStoreInterface {
    * @inheritDoc
    */
   public function remove($cxnId) {
-    CRM_Core_DAO::executeQuery('DELETE FROM civicrm_cxn WHERE cxn_id = %1', array(
-      1 => array($cxnId, 'String'),
-    ));
+    CRM_Core_DAO::executeQuery('DELETE FROM civicrm_cxn WHERE cxn_guid = %1', [
+      1 => [$cxnId, 'String'],
+    ]);
     unset($this->cxns[$cxnId]);
   }
 
@@ -92,14 +95,14 @@ class CRM_Cxn_CiviCxnStore implements Civi\Cxn\Rpc\CxnStore\CxnStoreInterface {
    */
   protected function convertDaoToCxn($dao) {
     $appMeta = json_decode($dao->app_meta, TRUE);
-    return array(
-      'cxnId' => $dao->cxn_id,
+    return [
+      'cxnId' => $dao->cxn_guid,
       'secret' => $dao->secret,
-      'appId' => $dao->app_id,
+      'appId' => $dao->app_guid,
       'appUrl' => $appMeta['appUrl'],
       'siteUrl' => CRM_Cxn_BAO_Cxn::getSiteCallbackUrl(),
       'perm' => json_decode($dao->perm, TRUE),
-    );
+    ];
   }
 
   /**
@@ -108,12 +111,13 @@ class CRM_Cxn_CiviCxnStore implements Civi\Cxn\Rpc\CxnStore\CxnStoreInterface {
    * @param CRM_Cxn_DAO_Cxn $dao
    */
   protected function convertCxnToDao($cxn, $dao) {
-    $dao->cxn_id = $cxn['cxnId'];
+    $dao->cxn_guid = $cxn['cxnId'];
     $dao->secret = $cxn['secret'];
-    $dao->app_id = $cxn['appId'];
+    $dao->app_guid = $cxn['appId'];
     $dao->perm = json_encode($cxn['perm']);
 
     // Note: we don't save siteUrl because it's more correct to regenerate on-demand.
     // Note: we don't save appUrl, but other processes will update appMeta.
   }
+
 }