public function process() { $date = $this->ga->getDates(); $url = $this->ga->buildUrl($date['begin'], $date['end'], $this->dimension, $this->metrics, array('-ga:visits'), $this->filters, $this->limit); $cacheKey = $this->ga->cacheKey; $fromCache = $this->modx->cacheManager->get($cacheKey); if (!empty($fromCache)) { return $this->success('Fetched data from cache', $fromCache, true); } if (!$this->ga->loadOAuth()) { return $this->failure('Could not load the OAuth file.'); } if (!$this->ga->getReport($url)) { return $this->failure($this->ga->getOutput()); } $this->visits = $this->ga->getTotalVisits($date['begin'], $date['end']); $response = $this->iterate(); $this->modx->cacheManager->set($cacheKey, $response, $this->ga->getOption('cache_timeout')); return $this->success('Fetched data from Google', $response); }