diff --git a/docs/development/models/cookie-settings.md b/docs/development/models/cookie-settings.md new file mode 100644 index 000000000..7d54b79bc --- /dev/null +++ b/docs/development/models/cookie-settings.md @@ -0,0 +1,32 @@ +--- +lang: php +--- + + + +# Cookie Settings Model + +**class `ExpressionEngine\Model\Cookie\CookieSetting`** + +[TOC] + +## Properties + +- `cookie_id` +- `cookie_provider` +- `cookie_name` +- `cookie_lifetime` +- `cookie_enforced_lifetime` +- `cookie_title` +- `cookie_description` + +## Relationships + +- `ConsentRequestVersion` \ No newline at end of file diff --git a/docs/development/models/working-with-models.md b/docs/development/models/working-with-models.md index fdf713519..c9e3a6f03 100644 --- a/docs/development/models/working-with-models.md +++ b/docs/development/models/working-with-models.md @@ -33,6 +33,7 @@ These are the most commonly used models in ExpressionEngine. For a full list, se - [Channel Field Model](development/models/channel-field.md) - [Comment Model](development/models/comment.md) - [Comment Subscription Model](development/models/comment-subscription.md) +- [Cookie Settings Model](development/models/cookie-settings.md) - [CP Log Model](development/models/cp-log.md) - [Developer Log Model](development/models/developer-log.md) - [Email Console Log Model](development/models/email-console-cache.md) diff --git a/docs/development/services/cookie-registry.md b/docs/development/services/cookie-registry.md new file mode 100644 index 000000000..fd0c095c0 --- /dev/null +++ b/docs/development/services/cookie-registry.md @@ -0,0 +1,142 @@ + + +# Cookie Registry Service + +[TOC] + +For the cookies set in ExpressionEngine, site owners can set the cookie lifetime, title and description in [Cookie Settings](control-panel/settings/cookie-settings.md). + +`CookieRegistry` is the underlying service that makes saving and using those settings possible. + +NOTE: Normally, the add-ons that have their cookies properly [registered](development/addon-setup-php-file.html#cookies) do not need to call this service directly. + +## Cookie Registry Constants + +There are 4 different types of cookies that can be registered, and this class is defining a constant for each of those. + + // Necessary cookies (0) + ee('CookieRegistry)::NECESSARY; + + //Functionality cookies (1) + ee('CookieRegistry)::FUNCTIONALITY; + + // Performance cookies (2) + ee('CookieRegistry)::PERFORMANCE; + + // Targeting cookies (4) + ee('CookieRegistry)::TARGETING; + +## Cookie Registry Methods + +**class `ExpressionEngine\Service\Consent\CookieRegistry`** + +### `registerNecessary($name)` + +Register a cookie as Necessary + +| Parameter | Type | Description | +| ------------- | --------- | ----------------------------------------------------- | +| \$name | `String` | Name of the cookie | + +### `registerFunctionality($name)` + +Register a cookie as Functionality + +| Parameter | Type | Description | +| ------------- | --------- | ----------------------------------------------------- | +| \$name | `String` | Name of the cookie | + + +### `registerPerformance($name)` + +Register a cookie as Performance + +| Parameter | Type | Description | +| ------------- | --------- | ----------------------------------------------------- | +| \$name | `String` | Name of the cookie | + + +### `registerTargeting($name)` + +Register a cookie as Targeting + +| Parameter | Type | Description | +| ------------- | --------- | ----------------------------------------------------- | +| \$name | `String` | Name of the cookie | + + +### `isNecessary($name)` + +Check whether cookie is Necessary. Returns `true` or `false` + +| Parameter | Type | Description | +| ------------- | --------- | ----------------------------------------------------- | +| \$name | `String` | Name of the cookie | + +### `isFunctionality($name)` + +Check whether cookie is Functionality. Returns `true` or `false` + +| Parameter | Type | Description | +| ------------- | --------- | ----------------------------------------------------- | +| \$name | `String` | Name of the cookie | + +### `isPerformance($name)` + +Check whether cookie is Performance. Returns `true` or `false` + +| Parameter | Type | Description | +| ------------- | --------- | ----------------------------------------------------- | +| \$name | `String` | Name of the cookie | + +### `isTargeting($name)` + +Check whether cookie is Targeting. Returns `true` or `false` + +| Parameter | Type | Description | +| ------------- | --------- | ----------------------------------------------------- | +| \$name | `String` | Name of the cookie | + +### `isRegistered($name)` + +Check whether or not the cookie is in the registry. Returns `true` or `false` + +| Parameter | Type | Description | +| ------------- | --------- | ----------------------------------------------------- | +| \$name | `String` | Name of the cookie | + +### `getType($name)` + +Get Cookie Type. Returns type int (from the list of constants) of registered cookie, `false` if cookie is not registered + +| Parameter | Type | Description | +| ------------- | --------- | ----------------------------------------------------- | +| \$name | `String` | Name of the cookie | + +### `loadCookiesSettings()` + +Load settings of all cookies into memory + +### `registerCookieSettings()` + +Register settings for the given cookie into memory + +| Parameter | Type | Description | +| ------------- | ---------------- | -------------------------------------------- | +| \$cookie | `CookieSetting` | Cookie object instance | + + +### `getCookieSettings($name)` + +Get lifetime for cookie to be set. Returns cookie lifetime in seconds, or `null`` if value provided in code should be used + +| Parameter | Type | Description | +| ------------- | --------- | ----------------------------------------------------- | +| \$name | `String` | Name of the cookie | diff --git a/docs/toc_sections/_advanced_usage_toc.yml b/docs/toc_sections/_advanced_usage_toc.yml index 2d4fb8191..335477e3e 100644 --- a/docs/toc_sections/_advanced_usage_toc.yml +++ b/docs/toc_sections/_advanced_usage_toc.yml @@ -326,6 +326,8 @@ href: development/services/consent.md - name: Cookie href: development/services/cookie.md + - name: Cookie Registry + href: development/services/cookie-registry.md - name: CSV Library href: development/services/csv.md - name: Encrypt Service @@ -426,6 +428,8 @@ href: development/models/comment.md - name: Comment Subscription Model href: development/models/comment-subscription.md + - name: Cookie Settings Model + href: development/models/cookie-settings.md - name: CP Log Model href: development/models/cp-log.md - name: Developer Log Model