Piwik\Plugins\Goals\API::getGoals PHP Method

getGoals() public method

Returns all Goals for a given website, or list of websites
public getGoals ( string | array $idSite ) : array
$idSite string | array Array or Comma separated list of website IDs to request the goals for
return array Array of Goal attributes
    public function getGoals($idSite)
    {
        $cacheId = self::getCacheId($idSite);
        $cache = $this->getGoalsInfoStaticCache();
        if (!$cache->contains($cacheId)) {
            $idSite = Site::getIdSitesFromIdSitesString($idSite);
            if (empty($idSite)) {
                return array();
            }
            Piwik::checkUserHasViewAccess($idSite);
            $goals = $this->getModel()->getActiveGoals($idSite);
            $cleanedGoals = array();
            foreach ($goals as &$goal) {
                $cleanedGoals[$goal['idgoal']] = $this->formatGoal($goal);
            }
            $cache->save($cacheId, $cleanedGoals);
        }
        return $cache->fetch($cacheId);
    }

Usage Example

Beispiel #1
0
 private function getGoals()
 {
     return $this->api->getGoals($this->idSite);
 }