From 11fd23acbd4b86ef8f88753c7edf8f526799d7ec Mon Sep 17 00:00:00 2001
From: Ghislain Loas <ghislo@sandbox.pergame.net>
Date: Tue, 29 Mar 2016 12:04:11 +0200
Subject: [PATCH] dev #35088 start implementing post XML

---
 .../cosmo/controllers/DataProfileControllerTest.php       | 6 ++++++
 library/Class/IntProfilDonnees.php                        | 8 +++++++-
 library/Class/ProfileSerializer.php                       | 5 +++--
 3 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DataProfileControllerTest.php b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DataProfileControllerTest.php
index 8766c78e37c..76442fb3f55 100644
--- a/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DataProfileControllerTest.php
+++ b/cosmogramme/cosmozend/tests/application/modules/cosmo/controllers/DataProfileControllerTest.php
@@ -409,4 +409,10 @@ class Cosmo_DataProfileControllerPostEditUnimarcKohaFileFormatTest extends Cosmo
   public function xmlBaliseAbonneShouldBeSubscribers() {
     $this->assertEquals('subscribers', Class_IntProfilDonnees::find(56)->getXmlBaliseAbonne());
   }
+
+
+  /** @test */
+  public function xmlAbonneIdShouldBeId() {
+    $this->assertEquals('id', Class_IntProfilDonnees::find(56)->getXmlAbonneId());
+  }
 }
\ No newline at end of file
diff --git a/library/Class/IntProfilDonnees.php b/library/Class/IntProfilDonnees.php
index 2cb2c7ad485..9611876969a 100644
--- a/library/Class/IntProfilDonnees.php
+++ b/library/Class/IntProfilDonnees.php
@@ -170,7 +170,8 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract {
     NOVELTY_FORMAT = 'format',
     NOVELTY_VALEURS = 'valeurs',
     XML_SUBSCRIBER_FIELD = 'xml_balise_abonne',
-    XML_SUBSCRIBER_FIELDS = 'xml_champs_abonne';
+    XML_SUBSCRIBER_FIELDS = 'xml_champs_abonne',
+    XML_IDABON = 'IDABON';
 
   protected
     $_table_name = 'profil_donnees',
@@ -711,6 +712,11 @@ class Class_IntProfilDonnees extends Storm_Model_Abstract {
   }
 
 
+  public function getXmlAbonneId() {
+    return $this->getProfilePrefs()->getSubscriberXmlFieldValue(Class_IntProfilDonnees::XML_IDABON);
+  }
+
+
   public function getProfilePrefs() {
     if(!$this->_profile_prefs)
       $this->_profile_prefs = (new Class_ProfilePrefs())->setDatas($this->toArray());
diff --git a/library/Class/ProfileSerializer.php b/library/Class/ProfileSerializer.php
index a889e400350..f517ea462e6 100644
--- a/library/Class/ProfileSerializer.php
+++ b/library/Class/ProfileSerializer.php
@@ -21,6 +21,7 @@
 
 
 class Class_ProfileSerializer {
+  const XML_PREFIX = 'xml_abonne_';
   protected $_datas;
 
 
@@ -76,7 +77,7 @@ class Class_ProfileSerializer {
 
   public function extractSubscribers() {
     return [Class_IntProfilDonnees::XML_SUBSCRIBER_FIELD => $this->extractXmlSubscriber(),
-            $this->extractSubscriberFields()];
+            Class_IntProfilDonnees::XML_SUBSCRIBER_FIELDS => $this->extractSubscriberFields()];
   }
 
 
@@ -101,7 +102,7 @@ class Class_ProfileSerializer {
 
 
   public function extractSubscriberFields() {
-
+    return [Class_IntProfilDonnees::XML_IDABON => $this->_datas[static::XML_PREFIX . Class_IntProfilDonnees::XML_IDABON]];
   }
 }
 ?>
\ No newline at end of file
-- 
GitLab