public function get(array $handler, array $settings)
    {
        $report = null;
        $this->hook->attach('module.ga_report.get.before', $handler, $settings, $report, $this);

        if (isset($report)) {
            return $report;
        }

        if (empty($settings['ga_profile_id'][$settings['store_id']])) {
            throw new OutOfRangeException("Google Analytics profile ID is empty for store {$settings['store_id']}");
        }

        $settings += array('cache' => 0);
        $settings['ga_profile_id'] = $settings['ga_profile_id'][$settings['store_id']];

        $cache_key = "ga_report.{$handler['id']}.{$settings['store_id']}";
        $cache = $this->cache->get($cache_key, array('lifespan' => $settings['cache']));

        if (!empty($settings['cache']) && isset($cache)) {
            return array(
                'data' => $cache,
                'updated' => $this->cache->getFileMtime()
            );
        }

        try {
            $response = $this->request($settings, $handler);
            $results = $this->getResults($response);
        } catch (Exception $ex) {
            return array('error' => $ex->getMessage());
        }

        $report = array('data' => $results, 'updated' => GC_TIME);
        $this->cache->set($cache_key, $results);

        $this->hook->attach('module.ga_report.get.after', $handler, $settings, $report, $this);
        return $report;
    }
public function get(array $handler, array $settings)
    {
        $report = null;
        $this->hook->attach('module.ga_report.get.before', $handler, $settings, $report, $this);

        if (isset($report)) {
            return $report;
        }

        if (empty($settings['ga_profile_id'][$settings['store_id']])) {
            throw new OutOfRangeException("Google Analytics profile ID is empty for store {$settings['store_id']}");
        }

        $settings += array('cache' => 0);
        $settings['ga_profile_id'] = $settings['ga_profile_id'][$settings['store_id']];

        $cache_key = "ga_report.{$handler['id']}.{$settings['store_id']}";
        $cache = $this->cache->get($cache_key, array('lifespan' => $settings['cache']));

        if (!empty($settings['cache']) && isset($cache)) {
            return array(
                'data' => $cache,
                'updated' => $this->cache->getFileMtime()
            );
        }

        try {
            $response = $this->request($settings, $handler);
            $results = $this->getResults($response);
        } catch (Exception $ex) {
            return array('error' => $ex->getMessage());
        }

        $report = array('data' => $results, 'updated' => GC_TIME);
        $this->cache->set($cache_key, $results);

        $this->hook->attach('module.ga_report.get.after', $handler, $settings, $report, $this);
        return $report;
    }
public function get ( array $ handler , array $ settings ) { $ report = null ; $ this -> hook -> attach ( 'module.ga_report.get.before' , $ handler , $ settings , $ report , $ this ) ; if ( isset ( $ report ) ) { return $ report ; } if ( empty ( $ settings [ 'ga_profile_id' ] [ $ settings [ 'store_id' ] ] ) ) { throw new OutOfRangeException ( "Google Analytics profile ID is empty for store {$settings['store_id']}" ) ; } $ settings += array ( 'cache' => 0 ) ; $ settings [ 'ga_profile_id' ] = $ settings [ 'ga_profile_id' ] [ $ settings [ 'store_id' ] ] ; $ cache_key = "ga_report.{$handler['id']}.{$settings['store_id']}" ; $ cache = $ this -> cache -> get ( $ cache_key , array ( 'lifespan' => $ settings [ 'cache' ] ) ) ; if ( ! empty ( $ settings [ 'cache' ] ) && isset ( $ cache ) ) { return array ( 'data' => $ cache , 'updated' => $ this -> cache -> getFileMtime ( ) ) ; } try { $ response = $ this -> request ( $ settings , $ handler ) ; $ results = $ this -> getResults ( $ response ) ; } catch ( Exception $ ex ) { return array ( 'error' => $ ex -> getMessage ( ) ) ; } $ report = array ( 'data' => $ results , 'updated' => GC_TIME ) ; $ this -> cache -> set ( $ cache_key , $ results ) ; $ this -> hook -> attach ( 'module.ga_report.get.after' , $ handler , $ settings , $ report , $ this ) ; return $ report ; }
Returns an array of parsed reporting data
@param array $handler
@param array $settings
@return array
@throws OutOfRangeException
Returns an array of parsed reporting data