Piwik\
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 }
This class defines the following properties:
$detectedContent
Piwik\array<string,
value.$connectedConsentManagers
The class defines the following methods:
__construct()
getSiteContentDetectionsByType()
getSiteContentDetectionById()
— Returns the site content detection object with the provided id, or null if it can't be founddetectContent()
— This will query the site and populate the class properties with the details of the detected contentwasDetected()
— Returns if the detection with the provided id was detected or notgetDetectsByType()
— Returns an array containing ids of all detected detections of the given typegetKnownConsentManagers()
— Return an array of consent manager definitions which can be used to detect their presence on the site and show the associated guide links__construct()
$cache
(Matomo\Cache\Lazy
|null
) —getSiteContentDetectionsByType()
array
—
SiteContentDetectionAbstract[]>getSiteContentDetectionById()
Returns the site content detection object with the provided id, or null if it can't be found
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
$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 secondsvoid
value.wasDetected()
Returns if the detection with the provided id was detected or not
Note: self::detectContent needs to be called before.
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
$type
(int
) —
One of the SiteContentDetectionAbstract::TYPE_* constantsarray
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.
array
value.