Piwik\Site::setSiteFromArray PHP Method

setSiteFromArray() public static method

Plugins can filter the website attributes before it is cached, eg. to change the website name, creation date, etc.
public static setSiteFromArray ( $idSite, $infoSite )
$idSite
$infoSite
    public static function setSiteFromArray($idSite, $infoSite)
    {
        if (empty($idSite) || empty($infoSite)) {
            throw new UnexpectedWebsiteFoundException("An unexpected website was found in the request: website id was set to '{$idSite}' .");
        }
        self::$infoSites[$idSite] = $infoSite;
    }

Usage Example

Example #1
0
 /**
  * Returns the website information : name, main_url
  *
  * @throws Exception if the site ID doesn't exist or the user doesn't have access to it
  * @param int $idSite
  * @return array
  */
 public function getSiteFromId($idSite)
 {
     Piwik::checkUserHasViewAccess($idSite);
     $site = $this->getModel()->getSiteFromId($idSite);
     Site::setSiteFromArray($idSite, $site);
     return $site;
 }