protected function getReloadData() { $modx =& $this->modx; $scriptProperties =& $this->scriptProperties; $reloadData = array(); // get reload data if reload token found in registry if (array_key_exists('reload', $scriptProperties) && !empty($scriptProperties['reload'])) { if (!isset($modx->registry)) { $modx->getService('registry', 'registry.modRegistry'); } /** @var modRegistry $modx->registry */ if (isset($modx->registry)) { $modx->registry->addRegister('resource_reload', 'registry.modDbRegister', array('directory' => 'resource_reload')); $this->reg = $modx->registry->resource_reload; if ($this->reg->connect()) { $topic = '/resourcereload/' . $scriptProperties['reload']; $this->reg->subscribe($topic); $msgs = $this->reg->read(array('poll_limit' => 1, 'remove_read' => true)); if (is_array($msgs)) { $reloadData = reset($msgs); } if (!is_array($reloadData)) { $reloadData = array(); } $this->reg->unsubscribe($topic); } } } return $reloadData; }
/** * Subscribe to register and read it * @return mixed */ public function readRegister() { $this->register->subscribe($this->topic); return $this->register->read($this->options); }