Piwik\

SiteContentDetector

This class provides detection functions for specific content on a site.

Note: Calling the detectContent() method will create a HTTP request to the site to retrieve data, only the main site URL will be checked

Usage:

$contentDetector = new SiteContentDetector(); $contentDetector->detectContent([GoogleAnalytics3::getId()]); if ($contentDetector->ga3) { // site is using GA3 }

Properties

This class defines the following properties:

$detectedContent

Signature

  • It is a Piwik\array<string, value.

$connectedConsentManagers

Signature

  • Its type is not specified.

Methods

The class defines the following methods:

__construct()

Signature

  • It accepts the following parameter(s):
    • $cache (Matomo\Cache\Lazy|null) —

getSiteContentDetectionsByType()

Signature

  • Returns: array — SiteContentDetectionAbstract[]>

getSiteContentDetectionById()

Returns the site content detection object with the provided id, or null if it can't be found

Signature

  • It accepts the following parameter(s):

    • $id (string) —
  • Returns: Piwik\Piwik\Plugins\SitesManager\SiteContentDetection\SiteContentDetectionAbstract|null

detectContent()

This will query the site and populate the class properties with the details of the detected content

Signature

  • It accepts the following parameter(s):
    • $detectContent (array) — Array of content type for which to check, defaults to all, limiting this list will speed up the detection check. Allowed values are: * empty array - to run all detections * an array containing ids of detections, e.g. Wordpress::getId() or any of the type constants, e.g. SiteContentDetectionAbstract::TYPE_TRACKER
    • $idSite (int|null) — Override the site ID, will use the site from the current request if null
    • $siteResponse (array|null) — String containing the site data to search, if blank then data will be retrieved from the current request site via an http request
    • $timeOut (int) — How long to wait for the site to response, defaults to 5 seconds
  • It returns a void value.

wasDetected()

Returns if the detection with the provided id was detected or not

Note: self::detectContent needs to be called before.

Signature

  • It accepts the following parameter(s):

    • $detectionClassId (string) —
  • It returns a bool value.

getDetectsByType()

Returns an array containing ids of all detected detections of the given type

Signature

  • It accepts the following parameter(s):
    • $type (int) — One of the SiteContentDetectionAbstract::TYPE_* constants
  • It returns a array value.

getKnownConsentManagers()

Return an array of consent manager definitions which can be used to detect their presence on the site and show the associated guide links

Note: This list is also used to display the known / supported consent managers on the "Ask for Consent" page For adding a new consent manager to this page, it needs to be added here. If a consent manager can't be detected automatically, simply leave the detections empty.

Signature

  • It returns a array value.