SilverCart\Model\CookieConsent\ExternalResource
Represents an external resource like Google Analytics code, Matomo Analytics code, Facebook Plugin SDK code or similar Javascript or HTML injections.
If the Broarm\CookieConsent module is installed each external resource can be
related to a cookie to be able to prevent to load the
- Author: Sebastian Diel <sdiel@pixeltricks.de>
- Copyright: 2020 pixeltricks GmbH
- License: see license file in modules root directory
Synopsis
class ExternalResource
extends DataObject
implements
TemplateGlobalProvider
{
- // constants
- const POSITION_HTML_HEAD = 'head';
- const POSITION_HTML_BODY = 'body';
- const RESOURCE_GOOGLE_ANALYTICS_TRACKING_CODE = 'GoogleAnalyticsTrackingCode';
- const RESOURCE_GOOGLE_CONVERSION_TRACKING_CODE = 'GoogleConversionTrackingCode';
- const RESOURCE_GOOGLE_WEBMASTER_CODE = 'GoogleWebmasterCode';
- const RESOURCE_MATOMO_TRACKING_CODE = 'MatomoTrackingCode';
- // members
- private static string $table_name = 'SilverCart_CookieConsent_ExternalResource';
- private static array $db = ;
- private static array $summary_fields = ;
- private static array $defaults = ;
- protected static $prepared_defaults = NULL;
- // methods
- public static array get_template_global_variables()
- public static ExternalResource|null getByName()
- public static DBHTMLText RequireExternalResources()
- public static DBHTMLText RequireExternalResourcesForBody()
- public static DBHTMLText RequireExternalResourcesForHead()
- public bool canDelete()
- public bool canRequire()
- public array fieldLabels()
- public FieldList getCMSFields()
- public ExternalResourceValidator getCMSValidator()
- protected void onBeforeWrite()
- public void requireDefaultRecords()
- public void requireTable()
- public array getDefaults()
- public bool isDefault()
- public string getCode()
- // Inherited methods from ExtensibleDataObject
- protected void beforeRequireDefaultRecords()
- protected void beforeUpdateCMSActions()
- protected void beforeUpdateFieldLabels()
- protected void beforeUpdateProvidePermissions()
- public array defaultFieldLabels()
- public static void reset_field_labels()
- protected array scaffoldFieldLabels()
- // Inherited methods from URLSegmentable
- public void requireDefaultURLSegmentableRecords()
- public string generateURLSegment()
- public string getOrGenerateURLSegment()
Hierarchy
Extends
- SilverStripe\ORM\DataObject
Uses
Implements
- SilverStripe\View\TemplateGlobalProvider
Constants
Name | Value |
---|---|
POSITION_HTML_HEAD | 'head' |
POSITION_HTML_BODY | 'body' |
RESOURCE_GOOGLE_ANALYTICS_TRACKING_CODE | 'GoogleAnalyticsTrackingCode' |
RESOURCE_GOOGLE_CONVERSION_TRACKING_CODE | 'GoogleConversionTrackingCode' |
RESOURCE_GOOGLE_WEBMASTER_CODE | 'GoogleWebmasterCode' |
RESOURCE_MATOMO_TRACKING_CODE | 'MatomoTrackingCode' |
Members
private
- $db
—
array
DB attributes. - $defaults
—
array
Default resources to add. - $summary_fields
—
array
Summary fields. - $table_name
—
string
DB table name.
protected
- $defaultFieldLabels
—
array
Default field labels. - $generatedURLSegment
—
array
The generated URL segment. - $prepared_defaults
—
array
Prepared default resources to add.
Methods
protected
- onBeforeWrite() — On before write.
public
- RequireExternalResources() — Requires the external resources for the given $position (default: @see self::POSITION_HTML_BODY).
- RequireExternalResourcesForBody() — Requires the external resources for the HTML body.
- RequireExternalResourcesForHead() — Requires the external resources for the HTML head.
- canDelete() — Returns whether the given $member can delete this record.
- canRequire() — Returns whether the given $member can require this record.
- fieldLabels() — Returns the field labels.
- getByName() — Returns the resource with the given $name.
- getCMSFields() — Returns the CMS fields.
- getCMSValidator() — Returns the custom ExternalResourceValidator to use for CMS field validation.
- getCode() — Returns the code.
- getDefaults() — Returns a prepared list of default resources.
- get_template_global_variables() — Returns the globals to use in template.
- isDefault() — Returns whether this is a default record.
- requireDefaultRecords() — Requires the default records.
- requireTable() — If not happened yet, the SiteConfig DB table column PiwikTrackingCode will be renamed to MatomoTrackingCode.
Inherited from SilverCart\ORM\ExtensibleDataObject
protected
- beforeRequireDefaultRecords() — Allows user code to hook into DataObject::requireDefaultRecords() prior to requireDefaultRecords being called on extensions.
- beforeUpdateCMSActions() — Allows user code to hook into DataObject::getCMSActions prior to updateCMSActions being called on extensions.
- beforeUpdateFieldLabels() — Allows user code to hook into DataObject::fieldLabels() prior to updateFieldLabels being called on extensions.
- beforeUpdateProvidePermissions() — Allows user code to hook into DataObject::updateProvidePermissions() prior to providePermissions being called on extensions.
- scaffoldFieldLabels() — Returns the default field labels for this DataObject.
public
- defaultFieldLabels() — Returns the default field labels.
- reset_field_labels() — Resets the field label cache.
Inherited from SilverCart\Model\URLSegmentable
public
- generateURLSegment() — Generates the URL segment.
- getOrGenerateURLSegment() — Returns the URL segment.
- requireDefaultURLSegmentableRecords() — Requires the default records.