* 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
*/
$this->getStackerInstance()->pushNamed(self::STACKER_NAME_PENDING_PUBLISHING, $current);
} // END - while
}
+
+ /**
+ * Checks whether there are entries pending publication
+ *
+ * @return $isPending Whether there are entries pending publication
+ */
+ public function hasEntriesPendingPublication () {
+ // Determine it if it is not empty
+ $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;
+ }
+
+ /**
+ * Publishes next entry found in stack. This method shall also update the
+ * 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 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);
+ }
}
// [EOF]