/** * Create instance of register and connect to it * @param $register * @return bool|null|string */ public function connectRegister($register) { $register_class = trim($this->getProperty('register_class', 'registry.modFileRegister')); $this->modx->getService('registry', 'registry.modRegistry'); $this->modx->registry->addRegister($register, $register_class, array('directory' => $register)); $this->register = $this->modx->registry->{$register}; if (!$this->register->connect()) { return $this->modx->lexicon('error'); } return true; }
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; }