/** * Convenience method that * enqueues for async processing if Redis is available; * otherwise performs sync processing. * Either way, callers should `echo` the return value back to the page. * * @return string */ public function enqueueOrPerform() { if (hasRedis()) { $future = $this->enqueue(); return $future->ajax(); } else { return $this->perform(); } }
function redis() { if (!isset($GLOBALS['REDIS'])) { if (!hasRedis()) { throw new Exception("Redis connection requested but not configured or library not found."); } $redisUrl = WorkbenchConfig::get()->value("redisUrl"); $r = new Redis(); $r->connect(parse_url($redisUrl, PHP_URL_HOST), parse_url($redisUrl, PHP_URL_PORT)); if (!is_array(parse_url($redisUrl, PHP_URL_PASS))) { $r->auth(parse_url($redisUrl, PHP_URL_PASS)); } $GLOBALS['REDIS'] = $r; } return $GLOBALS['REDIS']; }
if (isset($c->autoExec) && !$c->autoExec) { displayError("This URI needs to be completed before executing. " . "For example, it may need a merge field populated (e.g. {ID}) or a query string appended (e.g. ?q=)"); } if (isset($result)) { echo $result; } ?> </div> <script type="text/javascript"> var restExplorer = function() { function showWaitingIndicator() { document.getElementById('waitingIndicator').style.display = 'inline'; } if (<?php echo !hasRedis(); ?> ) { bindEvent(document.getElementById('execBtn'), 'click', showWaitingIndicator); var linkables = document.getElementById('restExplorerResultsContainer').getElementsByClassName('RestLinkable'); for (var link in linkables) { bindEvent(linkables[link], 'click', showWaitingIndicator); } } }(); </script> <?php require_once 'footer.php';