]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/dht/class_BaseDht.php
Added unfinished support for XML-based publishing of DHT entries.
[hub.git] / application / hub / main / dht / class_BaseDht.php
index ad09de3e6a71ec2ca5c18069b797adf2a4811c2b..fecc18cd76c8a0d6f7d03e5416aebc010d528b7b 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 abstract class BaseDht extends BaseHubSystem {
+       /**
+        * "Cached" instance of a publish helper
+        */
+       private $publishHelperInstance = NULL;
+
        /**
         * Stacker name for "INSERT" node data
         */
@@ -173,6 +178,7 @@ abstract class BaseDht extends BaseHubSystem {
                $isPending = ($this->getStackerInstance()->isStackEmpty(self::STACKER_NAME_PENDING_PUBLISHING) === FALSE);
 
                // Return status
+               /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . '] isPending=' . intval($isPending));
                return $isPending;
        }
 
@@ -181,9 +187,26 @@ abstract class BaseDht extends BaseHubSystem {
         * corresponding dabase entry.
         *
         * @return      void
+        * @todo        Find out if loadDescriptorXml() can be called only once to avoid a lot methods working.
         */
        public function publishEntry () {
-               $this->partialStub('Unimplemented method.');
+               // This test must not fail
+               assert($this->hasEntriesPendingPublication());
+
+               // Is there an instance?
+               if (!$this->publishHelperInstance instanceof HelpableDht) {
+                       // Get a helper instance
+                       $this->publishHelperInstance = ObjectFactory::createObjectByConfiguredName('dht_publish_entry_helper_class');
+               } // END - if
+
+               // Load the announcement descriptor
+               $this->publishHelperInstance->loadDescriptorXml($this);
+
+               // Compile all variables
+               $this->publishHelperInstance->getTemplateInstance()->compileConfigInVariables();
+
+               // "Publish" the descriptor by sending it to the bootstrap/list nodes
+               $this->publishHelperInstance->sendPackage($this);
        }
 }