Pimcore\Google\Analytics::getSiteConfig PHP Метод

getSiteConfig() публичный статический Метод

public static getSiteConfig ( null $site = null ) : boolean
$site null
Результат boolean
    public static function getSiteConfig($site = null)
    {
        $siteKey = \Pimcore\Tool\Frontend::getSiteKey($site);
        $config = Config::getReportConfig();
        if (!$config->analytics) {
            return false;
        }
        if ($config->analytics->sites->{$siteKey}) {
            return Config::getReportConfig()->analytics->sites->{$siteKey};
        }
        return false;
    }

Usage Example

Пример #1
0
 public function dataExplorerAction()
 {
     $config = Google\Analytics::getSiteConfig($this->getSite());
     $startDate = date("Y-m-d", time() - 86400 * 31);
     $endDate = date("Y-m-d");
     $metric = "ga:pageviews";
     $dimension = "ga:date";
     $descending = true;
     $limit = 10;
     if ($this->getParam("dateFrom") && $this->getParam("dateTo")) {
         $startDate = date("Y-m-d", strtotime($this->getParam("dateFrom")));
         $endDate = date("Y-m-d", strtotime($this->getParam("dateTo")));
     }
     if ($this->getParam("dimension")) {
         $dimension = $this->getParam("dimension");
     }
     if ($this->getParam("metric")) {
         $metric = $this->getParam("metric");
     }
     if ($this->getParam("sort")) {
         if ($this->getParam("sort") == "asc") {
             $descending = false;
         }
     }
     if ($this->getParam("limit")) {
         $limit = $this->getParam("limit");
     }
     if ($filterPath = $this->getFilterPath()) {
         $filters[] = "ga:pagePath==" . $filterPath;
     }
     $opts = ["dimensions" => $dimension, "max-results" => $limit, "sort" => ($descending ? "-" : "") . $metric];
     if (!empty($filters)) {
         $opts["filters"] = implode(";", $filters);
     }
     $result = $this->service->data_ga->get("ga:" . $config->profile, $startDate, $endDate, $metric, $opts);
     $data = [];
     foreach ($result["rows"] as $row) {
         $data[] = ["dimension" => $this->formatDimension($dimension, $row[0]), "metric" => (double) $row[1]];
     }
     $this->_helper->json(["data" => $data]);
 }
All Usage Examples Of Pimcore\Google\Analytics::getSiteConfig