├── .editorconfig
├── .gitattributes
├── .gitignore
├── .php_cs.dist
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── composer.json
├── composer.lock
├── config
└── croustillon.php
├── phpunit.xml
├── resources
├── lang
│ ├── en
│ │ └── cookies.php
│ ├── fr
│ │ └── cookies.php
│ └── nl
│ │ └── cookies.php
└── views
│ ├── _partials
│ └── categories
│ │ ├── analytics.blade.php
│ │ ├── mandatory.blade.php
│ │ ├── preferences.blade.php
│ │ ├── retargetting.blade.php
│ │ └── social.blade.php
│ ├── banner.blade.php
│ ├── categoriesTable.blade.php
│ ├── cookiesTable.blade.php
│ ├── lang
│ ├── en
│ │ ├── banner
│ │ │ └── content.blade.php
│ │ ├── cookies
│ │ │ ├── analytics.blade.php
│ │ │ ├── mandatory.blade.php
│ │ │ ├── preferences.blade.php
│ │ │ ├── retargetting.blade.php
│ │ │ └── social.blade.php
│ │ └── policy
│ │ │ ├── doesItWorkWithoutCookies.blade.php
│ │ │ ├── howToParameterCookies.blade.php
│ │ │ ├── intro.blade.php
│ │ │ ├── otherQuestions.blade.php
│ │ │ ├── whatIsACookie.blade.php
│ │ │ └── whichCookieDoWeUse.blade.php
│ ├── fr
│ │ ├── banner
│ │ │ └── content.blade.php
│ │ ├── cookies
│ │ │ ├── analytics.blade.php
│ │ │ ├── mandatory.blade.php
│ │ │ ├── preferences.blade.php
│ │ │ ├── retargetting.blade.php
│ │ │ └── social.blade.php
│ │ └── policy
│ │ │ ├── doesItWorkWithoutCookies.blade.php
│ │ │ ├── howToParameterCookies.blade.php
│ │ │ ├── intro.blade.php
│ │ │ ├── otherQuestions.blade.php
│ │ │ ├── whatIsACookie.blade.php
│ │ │ └── whichCookieDoWeUse.blade.php
│ └── nl
│ │ ├── banner
│ │ └── content.blade.php
│ │ ├── cookies
│ │ ├── analytics.blade.php
│ │ ├── mandatory.blade.php
│ │ ├── preferences.blade.php
│ │ ├── retargetting.blade.php
│ │ └── social.blade.php
│ │ └── policy
│ │ ├── doesItWorkWithoutCookies.blade.php
│ │ ├── howToParameterCookies.blade.php
│ │ ├── intro.blade.php
│ │ ├── otherQuestions.blade.php
│ │ ├── whatIsACookie.blade.php
│ │ └── whichCookieDoWeUse.blade.php
│ └── policy.blade.php
├── src
├── Categories
│ ├── Analytics.php
│ ├── CookieCategory.php
│ ├── Mandatory.php
│ ├── Preferences.php
│ ├── Retargetting.php
│ └── Social.php
├── Cookies
│ ├── Cookie.php
│ ├── CookiePolicy.php
│ ├── Session.php
│ └── Xsrf.php
├── Croustillon.php
├── CroustillonServiceProvider.php
├── Exceptions
│ ├── CreateCookieFailed.php
│ └── CreateCookiePolicyFailed.php
├── Facades
│ └── Croustillon.php
├── Http
│ ├── Controllers
│ │ ├── CookiePolicyController.php
│ │ └── CookiesController.php
│ ├── Middlewares
│ │ └── AddCookieBanner.php
│ └── routes.php
├── Policies
│ ├── Basic.php
│ └── Policy.php
├── Traits
│ ├── HasCookies.php
│ └── SetCookiePolicy.php
└── helpers.php
└── tests
├── AddCookieBannerTest.php
├── CookiePolicyTest.php
└── TestCase.php
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | end_of_line = lf
6 | insert_final_newline = true
7 | indent_style = space
8 | indent_size = 4
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | trim_trailing_whitespace = false
13 |
14 | [*.{js,css,scss,vue}]
15 | indent_size = 2
16 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /vendor
2 | /build
3 | .php_cs.cache
4 |
--------------------------------------------------------------------------------
/.php_cs.dist:
--------------------------------------------------------------------------------
1 | notPath('bootstrap')
5 | ->notPath('storage')
6 | ->notPath('vendor')
7 | ->in(__DIR__)
8 | ->name('*.php')
9 | ->notName('*.blade.php')
10 | ->ignoreDotFiles(true)
11 | ->ignoreVCS(true);
12 |
13 | return PhpCsFixer\Config::create()
14 | ->setRules([
15 | '@PSR2' => true,
16 | 'array_syntax' => ['syntax' => 'short'],
17 | 'blank_line_after_opening_tag' => true,
18 | 'blank_line_before_statement' => ['statements' => ['return', 'try', 'throw']],
19 | 'cast_spaces' => ['space' => 'single'],
20 | 'combine_consecutive_issets' => true,
21 | 'combine_consecutive_unsets' => true,
22 | 'compact_nullable_typehint' => true,
23 | 'concat_space' => ['spacing' => 'one'],
24 | 'declare_equal_normalize' => ['space' => 'single'],
25 | 'function_typehint_space' => true,
26 | 'hash_to_slash_comment' => true,
27 | 'include' => true,
28 | 'linebreak_after_opening_tag' => true,
29 | 'list_syntax' => ['syntax' => 'short'],
30 | 'magic_constant_casing' => true,
31 | 'method_separation' => true,
32 | 'native_function_casing' => true,
33 | 'no_blank_lines_after_class_opening' => true,
34 | 'no_blank_lines_after_phpdoc' => true,
35 | 'no_empty_comment' => true,
36 | 'no_empty_phpdoc' => true,
37 | 'no_empty_statement' => true,
38 | 'no_extra_consecutive_blank_lines' => ['tokens' => ['extra']],
39 | 'no_leading_import_slash' => true,
40 | 'no_leading_namespace_whitespace' => true,
41 | 'no_mixed_echo_print' => ['use' => 'echo'],
42 | 'no_multiline_whitespace_around_double_arrow' => true,
43 | 'no_multiline_whitespace_before_semicolons' => true,
44 | 'no_php4_constructor' => true,
45 | 'no_singleline_whitespace_before_semicolons' => true,
46 | 'no_spaces_around_offset' => ['positions' => ['inside', 'outside']],
47 | 'no_trailing_comma_in_list_call' => true,
48 | 'no_trailing_comma_in_singleline_array' => true,
49 | 'no_unneeded_control_parentheses' => [
50 | 'statements' => ['break', 'clone', 'continue', 'echo_print', 'return', 'switch_case', 'yield'],
51 | ],
52 | 'no_unneeded_curly_braces' => true,
53 | 'no_unneeded_final_method' => true,
54 | 'no_unused_imports' => true,
55 | 'no_useless_else' => true,
56 | 'no_useless_return' => true,
57 | 'no_whitespace_before_comma_in_array' => true,
58 | 'no_whitespace_in_blank_line' => true,
59 | 'normalize_index_brace' => true,
60 | 'not_operator_with_space' => false,
61 | 'not_operator_with_successor_space' => false,
62 | 'object_operator_without_whitespace' => true,
63 | 'ordered_imports' => ['sortAlgorithm' => 'length'],
64 | 'phpdoc_align' => ['tags' => ['param', 'return', 'throws', 'type', 'var']],
65 | 'phpdoc_annotation_without_dot' => true,
66 | 'phpdoc_indent' => true,
67 | 'phpdoc_no_alias_tag' => [
68 | 'property-read' => 'property', 'property-write' => 'property', 'type' => 'var', 'link' => 'see',
69 | ],
70 | 'phpdoc_no_empty_return' => true,
71 | 'phpdoc_no_package' => true,
72 | 'phpdoc_no_useless_inheritdoc' => true,
73 | 'phpdoc_return_self_reference' => [
74 | 'this' => '$this',
75 | '@this' => '$this',
76 | '$self' => 'self',
77 | '@self' => 'self',
78 | '$static' => 'static',
79 | '@static' => 'static',
80 | ],
81 | 'phpdoc_scalar' => true,
82 | 'phpdoc_separation' => true,
83 | 'phpdoc_single_line_var_spacing' => true,
84 | 'phpdoc_summary' => true,
85 | 'phpdoc_to_comment' => true,
86 | 'phpdoc_trim' => true,
87 | 'phpdoc_types' => true,
88 | 'phpdoc_types_order' => ['sort_algorithm' => 'alpha'],
89 | 'phpdoc_var_without_name' => true,
90 | 'return_type_declaration' => ['space_before' => 'none'],
91 | 'self_accessor' => true,
92 | 'semicolon_after_instruction' => true,
93 | 'short_scalar_cast' => true,
94 | 'single_blank_line_before_namespace' => true,
95 | 'single_line_comment_style' => ['comment_types' => ['asterisk', 'hash']],
96 | 'single_quote' => true,
97 | 'space_after_semicolon' => false,
98 | 'standardize_not_equals' => true,
99 | 'strict_comparison' => true,
100 | 'ternary_operator_spaces' => true,
101 | 'ternary_to_null_coalescing' => true,
102 | 'trailing_comma_in_multiline_array' => true,
103 | 'trim_array_spaces' => true,
104 | 'unary_operator_spaces' => true,
105 | 'whitespace_after_comma_in_array' => true,
106 | ])
107 | ->setFinder($finder);
108 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6 |
7 | ## Our Standards
8 |
9 | Examples of behavior that contributes to creating a positive environment include:
10 |
11 | * Using welcoming and inclusive language
12 | * Being respectful of differing viewpoints and experiences
13 | * Gracefully accepting constructive criticism
14 | * Focusing on what is best for the community
15 | * Showing empathy towards other community members
16 |
17 | Examples of unacceptable behavior by participants include:
18 |
19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances
20 | * Trolling, insulting/derogatory comments, and personal or political attacks
21 | * Public or private harassment
22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission
23 | * Other conduct which could reasonably be considered inappropriate in a professional setting
24 |
25 | ## Our Responsibilities
26 |
27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28 |
29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30 |
31 | ## Scope
32 |
33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34 |
35 | ## Enforcement
36 |
37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at elhebert@hotmail.be. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38 |
39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40 |
41 | ## Attribution
42 |
43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44 |
45 | [homepage]: http://contributor-covenant.org
46 | [version]: http://contributor-covenant.org/version/1/4/
47 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | Contributions are **welcome** and will be fully **credited**. I accept contributions via Pull Requests on [Github](https://github.com/Elhebert/laravel-croustillon).
4 |
5 | Please read and understand the contribution guide before creating an issue or pull request.
6 |
7 | ## Pull Requests
8 |
9 | Before submitting a pull request:
10 | - Make sure your code is properly linted to match our coding style:
11 | - I'm using [PHP CS Fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer) to help me keep my code clean and coherent. You can use `./vendor/bin/php-cs-fixer fix --allow-risky yes` or `composer cs-fix` to fix your code.
12 | - Make sure to write tests!
13 | - Document any change in behaviour. Make sure the `README.md` and any other relevant documentation are kept up-to-date.
14 | - One pull request per feature. If you want to do more than one thing, send multiple pull requests.
15 | - Send coherent history. Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](http://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
16 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 Elhebert
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Laravel Croustillon
2 |
3 | A package to help you manage your cookie banner and cookie policy with ease.
4 |
5 | > Documentation is still a work in progress.
6 |
7 | ## Why `laravel-croustillon`?
8 |
9 | I'm glad you asked. During the develoment of this packages I used `Cookie` to namespace everything which quickly made it hard to dicerne the Laravel Cookie classes and the Cookie from my package.
10 |
11 | I start thinking about names to use and thought of names like Donuts, Cake, Waffle or Biscuit. I discussed this with a colleague ([@meduzen](https://github.com/meduzen)) and I joked about using `Croustillon` because it would make everything awesome.
12 |
13 | Croustillon is a (french) Belgian word. For the non belgian people out here, Google Translate tells me it's called a donut in english, but I'm sceptical.
14 |
15 | So here's a picture:
16 |
17 | 
18 |
19 | ## Disclaimer
20 |
21 | I'm not a lawyer, so everything here should be taken with a grain of salt, especially the legal documents.
22 |
23 | Therefor I decline all responsability for any legal issues you might encounter by using this package without checking the legal documents with a lawyer.
24 |
25 | ## Installation
26 |
27 | ```bash
28 | composer require elhebert/laravel-croustillon
29 | ```
30 |
31 | This package uses [auto-discovery](https://laravel.com/docs/packages#package-discovery), so you don't have to do anything.
32 |
33 | You can publish the config-file with:
34 |
35 | ```bash
36 | php artisan vendor:publish --provider="Elhebert\Croustillon\CroustillonServiceProvider" --tag="croustillon-config"
37 | ```
38 |
39 | You can publish the language-file with:
40 |
41 | ```bash
42 | php artisan vendor:publish --provider="Elhebert\Croustillon\CroustillonServiceProvider" --tag="croustillon-translations"
43 | ```
44 |
45 | You can publish the view-files with:
46 |
47 | ```bash
48 | php artisan vendor:publish --provider="Elhebert\Croustillon\CroustillonServiceProvider" --tag="croustillon-views"
49 | ```
50 |
51 | You can add a cookie banner to all responses of your app by registering `Elhebert\Croustillon\Http\Middlewares\AddCookieBanner::class` in the http kernel.
52 | ```php
53 | // app/Http/Kernel.php
54 |
55 | ...
56 |
57 | protected $middlewareGroups = [
58 | 'web' => [
59 | ...
60 | \Elhebert\Croustillon\Http\Middlewares\AddCookieBanner::class,
61 | ],
62 | ```
63 |
64 | Alternatively you can apply the middleware on the route or route group level.
65 |
66 | ```php
67 | // in a routes file
68 |
69 | Route::get('my-page', 'MyController')->middleware(Elhebert\Croustillon\Http\Middlewares\AddCookieBanner::class);
70 | ```
71 |
72 | ## Usage
73 |
74 | This package allows you to define a cookie policy. A cookie policy determines which cookies are used within your website and generate a corresponding banner and legal page.
75 |
76 | By default every Laravel application has 2 cookies set, the `laravel_session` cookie and the `XSRF-TOKEN` cookie. Using a new Laravel application as example, here what you can expect:
77 |
78 | ```php
79 | // in a policy
80 |
81 | ...
82 | ->addCookie(Xsrf::class)
83 | ->addCookie(Session::class)
84 | ...
85 | ```
86 |
87 | ### Creating a cookie
88 |
89 | As we all know website are not limited to use the default cookies and might use new ones for all kind of reasons. Which is why you can create custom cookies to add to a policy.
90 |
91 | A cookie is compose of a name, a description, a duration, a purpose, a source and a category.
92 |
93 | ```php
94 | namespace Elhebert\Croustillon\Cookies;
95 |
96 | use Elhebert\Croustillon\Categories\Mandatory;
97 |
98 | class Xsrf extends Cookie
99 | {
100 | public $name = 'XSRF-TOKEN';
101 |
102 | public $category = Mandatory::class;
103 |
104 | public $source = 'Laravel';
105 |
106 | public $duration = '2 hours';
107 |
108 | public $purpose = 'security';
109 | }
110 | ```
111 |
112 | This package comes with pre-defined categories from which you can choose from:
113 |
114 | ```php
115 | Elhebert\Croustillon\Categories\Mandatory::class
116 | Elhebert\Croustillon\Categories\Preferences::class
117 | Elhebert\Croustillon\Categories\Analytics::class
118 | Elhebert\Croustillon\Categories\Social::class
119 | Elhebert\Croustillon\Categories\Retargetting::class
120 | ```
121 |
122 | Depending on which cookies you added to your policy, it'll impact the cookie banner and the legal page.
123 | The banner will add checkboxes for each categories of cookies (to offer fully granularity to the visitor) and the legal page will add the cookies and corresponding categories to the list of cookies.
124 |
125 | If you need to customize the different variables you can use the corresponding functions instead of the variable:
126 |
127 | ```php
128 | public function duration(): string
129 | {
130 | return config('session.lifetime') . ' minutes';
131 | }
132 |
133 | public function purpose(): string
134 | {
135 | return trans('croustillon::cookies.purposes.security');
136 | }
137 | ```
138 |
139 | ### Creatiing a policy
140 |
141 | Once you have all your cookies, you need to create a new policy:
142 |
143 | ```php
144 | namespace App\Service\Croustillon\Policies;
145 |
146 | use Elhebert\Croustillon\Policies\Basic;
147 | use App\Service\Croustillon\Cookie\MyCustomCookie;
148 |
149 | class MyCustomPolicy extends Basic
150 | {
151 | public function configure()
152 | {
153 | parent::configure();
154 |
155 | $this
156 | ->addCookie(MyCustomCookie::class);
157 | }
158 | }
159 | ```
160 |
161 | Don't forget to update the `policy` key of the config file to the class of your policy (in this case it would be `App\Service\Croustillon\Policies\MyCustomPolicy`).
162 |
163 | ### Customising the cookie banner and the legal page
164 |
165 | This package comes with a default cookie banner and legal page that you can (and should) customize, to do so you need to publish the package views:
166 |
167 | ```bash
168 | php artisan vendor:publish --provider="Elhebert\Croustillon\CroustillonServiceProvider" --tag="croustillon-views"
169 | ```
170 |
171 | #### Cookie banner
172 |
173 | The banner will be in `resources/views/vendor/croustillon/banner.blade.php`. By default it's generating the checkboxes for every cookie categories present in your policy. The mandatory category will be checked and disable (because it's _mandatory_).
174 |
175 | It also comes bundle with a controller and a route, so you don't need to worry about creating them in your application.
176 |
177 | The default route is `/croustillon`.
178 |
179 | #### Cookie legal page
180 |
181 | The legal page can be found in `resources/views/vendor/croustillon/policy.blade.php`. The main content of that page is already done, but you still should update it to suit your need and your website.
182 |
183 | The default route for this page is `/croustillon/policy`.
184 |
185 | ## Customization
186 |
187 | This package come with opinions. Like routes, copy and views.
188 |
189 | Everything can be customize.
190 |
191 | ### Routes
192 |
193 | The prefix can be customize in the config file but should you need complete control on the routes you can disable the ones from this package to create your own.
194 |
195 | The routes you need to create are:
196 |
197 | - For the cookie banner form:
198 | - Verb: `POST`
199 | - Action: `\Elhebert\Croustillon\Http\Controllers\CookiesController` (it has an `__invoke` method, so you don't need to reference a method).
200 |
201 | - For the cookie policy legal page:
202 | - Verb: `GET`
203 | - Action: `\Elhebert\Croustillon\Http\Controllers\CookiePolicyController` (it has an `__invoke` method, so you don't need to reference a method).
204 |
205 | ### Translations
206 |
207 | You can overwrite the default translations by publishing the language files.
208 |
209 | ### Views
210 |
211 | You can overwrite the default views by publishing the view files.
212 |
213 | ## Contributing
214 |
215 | Please see [CONTRIBUTING](CONTRIBUTING.md) for more details.
216 |
217 | ## License
218 |
219 | This project and the Laravel framework are open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).
220 |
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "elhebert/laravel-croustillon",
3 | "description": "A package to help you manage your cookie banner and cookie policy with ease",
4 | "keywords": [
5 | "Laravel",
6 | "cookie",
7 | "GDPR",
8 | "croustillon"
9 | ],
10 | "license": "MIT",
11 | "authors": [
12 | {
13 | "name": "Dieter Stinglhamber",
14 | "email": "elhebert@hotmail.be"
15 | }
16 | ],
17 | "require": {
18 | "php": "^7.1.3",
19 | "illuminate/support": "5.7.*",
20 | "illuminate/http": "5.7.*",
21 | "illuminate/view": "5.7.*"
22 | },
23 | "require-dev": {
24 | "friendsofphp/php-cs-fixer": "^2.13",
25 | "orchestra/testbench": "^3.7",
26 | "phpunit/phpunit": "^7.4"
27 | },
28 | "autoload": {
29 | "psr-4": {
30 | "Elhebert\\Croustillon\\": "src/"
31 | },
32 | "files": [
33 | "src/helpers.php"
34 | ]
35 | },
36 | "autoload-dev": {
37 | "psr-4": {
38 | "Elhebert\\Croustillon\\Tests\\": "tests"
39 | }
40 | },
41 | "scripts": {
42 | "cs-fix": [
43 | "./vendor/bin/php-cs-fixer fix --allow-risky yes"
44 | ],
45 | "test": "vendor/bin/phpunit",
46 | "test-coverage": "phpunit --coverage-html coverage"
47 | },
48 | "extra": {
49 | "laravel": {
50 | "providers": [
51 | "Elhebert\\Croustillon\\CroustillonServiceProvider"
52 | ]
53 | },
54 | "aliases": {
55 | "Croustillon": "Elhebert\\Croustillon\\Facades\\Croustillon"
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/config/croustillon.php:
--------------------------------------------------------------------------------
1 | \Elhebert\Croustillon\Policies\Basic::class,
5 |
6 | 'policy_cookie' => env('CROUSTILLON_COOKIE_POLICY', 'cookie_policy'),
7 |
8 | 'path' => '/croustillon',
9 | 'enable_routes' => env('CROUSTILLON_ENABLE_ROUTES', true),
10 |
11 | 'middleware' => ['web'],
12 |
13 | 'types' => [
14 | \Elhebert\Croustillon\Categories\Mandatory::class,
15 | \Elhebert\Croustillon\Categories\Preferences::class,
16 | \Elhebert\Croustillon\Categories\Analytics::class,
17 | \Elhebert\Croustillon\Categories\Social::class,
18 | \Elhebert\Croustillon\Categories\Retargetting::class,
19 | ],
20 | ];
21 |
--------------------------------------------------------------------------------
/phpunit.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
13 |
14 | ./tests
15 |
16 |
17 |
18 |
19 |
20 | ./src
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/resources/lang/en/cookies.php:
--------------------------------------------------------------------------------
1 | [
5 | 'mandatory' => 'mandatory',
6 | 'preferences' => 'preferences',
7 | 'analytics' => 'analytics',
8 | 'social' => 'social',
9 | 'retargetting' => 'retargetting',
10 | ],
11 |
12 | 'purposes' => [
13 | 'security' => 'Security',
14 | 'analytics' => 'Trafic analysis',
15 | 'retargetting' => 'Retargetting',
16 | 'cookie-preferences' => 'Cookies preferences',
17 | 'language-preferences' => 'Language preferences',
18 | ],
19 |
20 | 'banner' => [
21 | 'title' => 'We use cookies',
22 | 'submit' => 'I accept',
23 | ],
24 |
25 | 'policy' => [
26 | 'title' => 'Cookies policy',
27 | 'labels' => [
28 | 'cookie' => 'Cookie type',
29 | 'usage' => 'usage',
30 | 'name' => 'Name',
31 | 'expiration' => 'Expiration',
32 | 'purpose' => 'Purpose',
33 | 'source' => 'Source',
34 | 'consent-level' => 'Level of consent',
35 | ],
36 | ],
37 | ];
38 |
--------------------------------------------------------------------------------
/resources/lang/fr/cookies.php:
--------------------------------------------------------------------------------
1 | [
5 | 'mandatory' => 'indispensables',
6 | 'preferences' => 'préférences',
7 | 'analytics' => 'analytiques',
8 | 'social' => 'social',
9 | 'retargetting' => 'ciblage publicitaire',
10 | ],
11 |
12 | 'purposes' => [
13 | 'security' => 'Sécurité',
14 | 'analytics' => 'Analyse du traffic',
15 | 'retargetting' => 'Ciblage publicitaire',
16 | 'cookie-preferences' => 'Préférences des cookies',
17 | 'language-preferences' => 'Préférence de langue',
18 | ],
19 |
20 | 'banner' => [
21 | 'title' => 'Nous utilisons des cookies',
22 | 'submit' => 'J’accepte',
23 | ],
24 |
25 | 'policy' => [
26 | 'title' => 'Politiques des cookies',
27 | 'labels' => [
28 | 'cookie' => 'Type de cookies',
29 | 'usage' => 'Finalité',
30 | 'name' => 'Nom',
31 | 'expiration' => 'Durée',
32 | 'purpose' => 'Utilisation',
33 | 'source' => 'Source',
34 | 'consent-level' => 'Niveau de consentement',
35 | ],
36 | ],
37 | ];
38 |
--------------------------------------------------------------------------------
/resources/lang/nl/cookies.php:
--------------------------------------------------------------------------------
1 | [
5 | 'mandatory' => 'essentieel',
6 | 'preferences' => 'voorkeuring',
7 | 'analytics' => 'analytisch',
8 | 'social' => 'sociaal',
9 | 'retargetting' => 'commercieel',
10 | ],
11 |
12 | 'purposes' => [
13 | 'security' => 'Veiligheid',
14 | 'analytics' => 'Verkeersanalyse',
15 | 'retargetting' => 'Advertentietargeting',
16 | 'cookie-preferences' => 'Cookies voorkeuren',
17 | 'language-preferences' => 'Taal voorkeuren',
18 | ],
19 |
20 | 'banner' => [
21 | 'title' => 'Wij gebruiken cookies',
22 | 'submit' => 'Ik aanvaard',
23 | ],
24 |
25 | 'policy' => [
26 | 'title' => 'Cookiepolicy',
27 | 'labels' => [
28 | 'cookie' => 'Cookies',
29 | 'usage' => 'Doel / Reden',
30 | 'name' => 'Naam',
31 | 'expiration' => 'Duur',
32 | 'purpose' => 'Gebruik',
33 | 'source' => 'Bron',
34 | 'consent-level' => 'Mate van instemming',
35 | ],
36 | ],
37 | ];
38 |
--------------------------------------------------------------------------------
/resources/views/_partials/categories/analytics.blade.php:
--------------------------------------------------------------------------------
1 | @include("croustillon::lang.{$locale}.cookies.analytics")
2 |
--------------------------------------------------------------------------------
/resources/views/_partials/categories/mandatory.blade.php:
--------------------------------------------------------------------------------
1 | @include("croustillon::lang.{$locale}.cookies.mandatory")
2 |
--------------------------------------------------------------------------------
/resources/views/_partials/categories/preferences.blade.php:
--------------------------------------------------------------------------------
1 | @include("croustillon::lang.{$locale}.cookies.preferences")
2 |
--------------------------------------------------------------------------------
/resources/views/_partials/categories/retargetting.blade.php:
--------------------------------------------------------------------------------
1 | @include("croustillon::lang.{$locale}.cookies.retargetting")
2 |
--------------------------------------------------------------------------------
/resources/views/_partials/categories/social.blade.php:
--------------------------------------------------------------------------------
1 | @include("croustillon::lang.{$locale}.cookies.social")
2 |
--------------------------------------------------------------------------------
/resources/views/banner.blade.php:
--------------------------------------------------------------------------------
1 |
2 | {{ trans('croustillon::cookies.banner.title') }}
3 |
4 | @include("croustillon::lang.{$locale}.banner.content")
5 |
6 |
35 |
36 |
--------------------------------------------------------------------------------
/resources/views/categoriesTable.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{ trans('croustillon::policy.label.cookie') }}
5 | {{ trans('croustillon::policy.label.usage') }}
6 |
7 |
8 |
9 | @foreach (croustillon()->cookiesByCategory()->keys() as $category)
10 |
11 | {{ croustillon()->category($category)->name() }}
12 | {{ croustillon()->category($category)->description() }}
13 |
14 | @endforeach
15 |
16 |
17 |
--------------------------------------------------------------------------------
/resources/views/cookiesTable.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {{ trans('croustillon::policy.label.name') }}
5 | {{ trans('croustillon::policy.label.expiration') }}
6 | {{ trans('croustillon::policy.label.purpose') }}
7 | {{ trans('croustillon::policy.label.source') }}
8 | {{ trans('croustillon::policy.label.category') }}
9 |
10 |
11 |
12 | @foreach (croustillon()->cookies() as $cookie)
13 |
14 | {{ $cookie->name() }}
15 |
16 | {{
17 | \Carbon\CarbonInterval::fromString($cookie->duration())
18 | ->cascade()
19 | ->forHumans()
20 | }}
21 |
22 | {{ $cookie->purpose() }}
23 | {{ $cookie->source() }}
24 | {{ croustillon()->category($cookie->category)->name() }}
25 |
26 | @endforeach
27 |
28 |
29 |
--------------------------------------------------------------------------------
/resources/views/lang/en/banner/content.blade.php:
--------------------------------------------------------------------------------
1 |
2 | We use cookies to gather information about the way users interact with our website.
3 |
4 |
5 |
6 | We use this information to create reports and help us improve the website. If you do not allow theses cookies we will not be able to include your visit in our statistics.
7 |
8 |
--------------------------------------------------------------------------------
/resources/views/lang/en/cookies/analytics.blade.php:
--------------------------------------------------------------------------------
1 |
2 | These cookies are used to gather information about your use of the site to improve the content of the site, to make it more suitable to your needs and to increase its usability.
3 |
4 |
5 |
6 | For example, these cookies show us the pages of the most visited website or help to identify the difficulties that may be encountered during the navigation.
7 |
8 |
--------------------------------------------------------------------------------
/resources/views/lang/en/cookies/mandatory.blade.php:
--------------------------------------------------------------------------------
1 |
2 | These cookies are essential for browsing or providing a service.
3 |
4 |
5 | The removal of this type of cookie may cause navigation difficulties and is strongly discouraged.
6 |
7 |
--------------------------------------------------------------------------------
/resources/views/lang/en/cookies/preferences.blade.php:
--------------------------------------------------------------------------------
1 |
2 | These cookies collect information about your choices and preferences and make your navigation more pleasant and personalized.
3 |
4 |
5 | These cookies make it possible to memorize the language chosen during your first visit of our Site in order to personalize it accordingly.
6 |
7 |
--------------------------------------------------------------------------------
/resources/views/lang/en/cookies/retargetting.blade.php:
--------------------------------------------------------------------------------
1 |
2 | These cookies are used for marketing purposes, in particular to display targeted advertising, conduct market research and evaluate the effectiveness of an advertising campaign.
3 |
4 |
--------------------------------------------------------------------------------
/resources/views/lang/en/cookies/social.blade.php:
--------------------------------------------------------------------------------
1 |
2 | These cookies allow you to share the content of the Site with other people via social networks. Some sharing buttons are integrated via third-party applications that can issue this type of cookies.
3 |
4 |
5 |
6 | This is particularly the case with the buttons [« Facebook », « Twitter », « Google + », « LinkedIn » and « Pinterest »]. Social networks providing such a sharing button are likely to identify you with this button, even if you did not use this button when visiting our Site.
7 |
8 |
9 |
10 | We invite you to consult the privacy policy of these social networks to learn the purpose of using the information collected through these sharing buttons by going to their respective sites.
11 |
12 |
--------------------------------------------------------------------------------
/resources/views/lang/en/policy/doesItWorkWithoutCookies.blade.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Elhebert/laravel-croustillon/4084a4600f4a74791e955edc0deac82af7b63641/resources/views/lang/en/policy/doesItWorkWithoutCookies.blade.php
--------------------------------------------------------------------------------
/resources/views/lang/en/policy/howToParameterCookies.blade.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Elhebert/laravel-croustillon/4084a4600f4a74791e955edc0deac82af7b63641/resources/views/lang/en/policy/howToParameterCookies.blade.php
--------------------------------------------------------------------------------
/resources/views/lang/en/policy/intro.blade.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Elhebert/laravel-croustillon/4084a4600f4a74791e955edc0deac82af7b63641/resources/views/lang/en/policy/intro.blade.php
--------------------------------------------------------------------------------
/resources/views/lang/en/policy/otherQuestions.blade.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Elhebert/laravel-croustillon/4084a4600f4a74791e955edc0deac82af7b63641/resources/views/lang/en/policy/otherQuestions.blade.php
--------------------------------------------------------------------------------
/resources/views/lang/en/policy/whatIsACookie.blade.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Elhebert/laravel-croustillon/4084a4600f4a74791e955edc0deac82af7b63641/resources/views/lang/en/policy/whatIsACookie.blade.php
--------------------------------------------------------------------------------
/resources/views/lang/en/policy/whichCookieDoWeUse.blade.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Elhebert/laravel-croustillon/4084a4600f4a74791e955edc0deac82af7b63641/resources/views/lang/en/policy/whichCookieDoWeUse.blade.php
--------------------------------------------------------------------------------
/resources/views/lang/fr/banner/content.blade.php:
--------------------------------------------------------------------------------
1 |
2 | Nous utilisons des cookies pour collecter des informations sur la manière dont les utilisateurs interagissent avec notre site Web
3 |
4 |
5 |
6 | Nous utilisons ces informations pour créer des rapports et nous aider à améliorer le site web. Si vous n’autorisez pas ces cookies, nous ne pourrons pas inclure votre visite dans nos statistiques.
7 |
8 |
--------------------------------------------------------------------------------
/resources/views/lang/fr/cookies/analytics.blade.php:
--------------------------------------------------------------------------------
1 |
2 | Ces cookies sont utilisés pour rassembler des informations sur l’utilisation que vous faites du site afin d’améliorer le contenu de celui-ci, de le rendre plus adapté à vos besoins et d’augmenter sa facilité d’utilisation.
3 |
4 |
5 |
6 | Par exemple, ces cookies nous montrent les pages du site les plus visitées ou aident à identifier les difficultés qui peuvent être rencontrées au cours de la navigation.
7 |
8 |
--------------------------------------------------------------------------------
/resources/views/lang/fr/cookies/mandatory.blade.php:
--------------------------------------------------------------------------------
1 |
2 | Ces cookies sont indispensables à la navigation ou à la fourniture d’un service.
3 |
4 |
5 | La suppression de ce type de cookies peut entraîner des difficultés de navigation et est fortement déconseillée.
6 |
7 |
--------------------------------------------------------------------------------
/resources/views/lang/fr/cookies/preferences.blade.php:
--------------------------------------------------------------------------------
1 |
2 | Ces cookies recueillent des informations sur vos choix et préférences et rendent votre navigation plus agréable et personnalisée.
3 |
4 |
5 | Ces cookies permettent notamment de mémoriser la langue choisie lors de votre première visite de notre Site aux fins de le personnaliser en conséquence.
6 |
7 |
--------------------------------------------------------------------------------
/resources/views/lang/fr/cookies/retargetting.blade.php:
--------------------------------------------------------------------------------
1 |
2 | Ces cookies sont utilisés à des fins de marketing notamment pour afficher de la publicité ciblée, réaliser des études de marché et évaluer l’efficacité d’une campagne publicitaire.
3 |
4 |
--------------------------------------------------------------------------------
/resources/views/lang/fr/cookies/social.blade.php:
--------------------------------------------------------------------------------
1 |
2 | Ces cookies permettent de partager le contenu du Site avec d’autres personnes via les réseaux sociaux.
3 |
4 |
5 |
6 | Certains boutons de partage sont intégrés via des applications tierces pouvant émettre ce type de cookies. C’est notamment le cas des boutons [« Facebook », « Twitter », « Google + », « LinkedIn » et « Pinterest »]. Les réseaux sociaux fournissant un tel bouton de partage sont susceptibles de vous identifier grâce à ce bouton, même si vous n’avez pas utilisé ce bouton lors de la consultation de notre Site.
7 |
8 |
9 |
10 | Nous vous invitons à consulter la politique vie privée de ces réseaux sociaux afin de prendre connaissance des finalités d’utilisation des informations recueillies grâce à ces boutons de partage en vous rendant sur leurs sites respectifs.
11 |
12 |
--------------------------------------------------------------------------------
/resources/views/lang/fr/policy/doesItWorkWithoutCookies.blade.php:
--------------------------------------------------------------------------------
1 |
2 | Notre site fonctionnera-t-il toujours sans cookies ?
3 |
4 |
5 |
6 | Vous pourrez toujours consulter notre Site mais certaines interactions pourraient ne pas fonctionner normalement.
7 |
8 |
--------------------------------------------------------------------------------
/resources/views/lang/fr/policy/howToParameterCookies.blade.php:
--------------------------------------------------------------------------------
1 |
2 | Comment paramétrer les cookies ?
3 |
4 |
5 |
6 | Vous pouvez facilement supprimer, désactiver ou accepter à tout moment les cookies de notre Site en configurant les paramètres de votre navigateur.
7 |
8 |
9 |
10 | Chaque navigateur (Internet Explorer, Safari, Firefox, Google Chrome, etc.) a son propre mode de configuration de cookies. Pour connaître la procédure à suivre concernant votre navigateur, rendez-vous sur le site :
11 | http://www.allaboutcookies.org/fr/gerer-les-cookies/ .
12 |
13 |
14 |
15 | Si vous utilisez différents ordinateurs, smartphones et/ou tablettes, n’oubliez pas de configurer chaque équipement de manière à ce que chacun d’eux corresponde à vos préférences en termes de cookies.
16 |
17 |
--------------------------------------------------------------------------------
/resources/views/lang/fr/policy/intro.blade.php:
--------------------------------------------------------------------------------
1 |
2 | Politique relative aux cookies
3 |
4 |
5 |
6 | En vigueur depuis le:
7 | Dernière mise à jour:
8 | Version précédente:
9 |
10 |
11 | La présente politique relative aux cookies (ci-après, la « Cookie Policy ») décrit les différents types de cookies que nous utilisons sur notre site « Example website » (ci-après, le « Site ») et la manière dont vous pouvez paramétrer ces cookies.
12 |
13 |
14 | Nous appliquons une politique de confidentialité stricte et nous nous engageons à être transparents quant aux technologies qui sont utilisées sur notre Site.
15 |
16 |
17 | Dans la mesure où les informations recueillies à l’aide des cookies constituent des données personnelles, les dispositions de la charte vie privée s’appliquent et complètent la présente Cookie Policy.
18 |
19 |
--------------------------------------------------------------------------------
/resources/views/lang/fr/policy/otherQuestions.blade.php:
--------------------------------------------------------------------------------
1 |
2 | D’autres questions ?
3 |
4 |
5 |
6 | Pour toute information complémentaire, visitez notre page dédiée à la protection des données ou contactez-nous :
7 |
8 |
9 |
10 |
11 | par email à l’adresse suivante : contact@example.com
12 |
13 |
14 | par courrier à l’adresse postale suivante :
15 |
16 | Example Corp.
17 | Example street 42
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/resources/views/lang/fr/policy/whatIsACookie.blade.php:
--------------------------------------------------------------------------------
1 |
2 | Qu’est-ce qu’un cookie ?
3 |
4 |
5 |
6 | Un « cookie » est un petit fichier texte contenant des informations sauvegardées par un site web sur un ordinateur ou par une application mobile sur le smartphone d’un utilisateur. Les cookies offrent la possibilité de vous identifier et de mémoriser différentes informations aux fins de vous faciliter la navigation sur un site/une application mobile, d’assurer le bon fonctionnement de ceux-ci ou de les rendre plus efficaces, par exemple en mémorisant vos préférences linguistiques.
7 |
8 |
--------------------------------------------------------------------------------
/resources/views/lang/fr/policy/whichCookieDoWeUse.blade.php:
--------------------------------------------------------------------------------
1 |
2 | Quels cookies sont utilisés sur notre site et pourquoi ?
3 |
4 |
5 |
6 | Nous utilisons différents types de cookies pour différentes raisons.
7 |
8 |
9 | @include('croustillon::categoriesTable')
10 |
11 |
12 | details des cookies:
13 |
14 |
15 | @include('croustillon::cookiesTable')
16 |
--------------------------------------------------------------------------------
/resources/views/lang/nl/banner/content.blade.php:
--------------------------------------------------------------------------------
1 |
2 | Wij gebruiken cookies om informatie te verzamelen over de manier waarop gebruikers omgaan met onze website.
3 |
4 |
5 |
6 | We gebruiken deze informatie om rapporten te maken en ons te helpen de website te verbeteren. Als u deze cookies niet toestaat, kunnen we uw bezoek niet opnemen in onze statistieken.
7 |
8 |
--------------------------------------------------------------------------------
/resources/views/lang/nl/cookies/analytics.blade.php:
--------------------------------------------------------------------------------
1 |
2 | Deze cookies worden gebruikt om informatie te verzamelen over uw gebruik van de site om de inhoud van de site te verbeteren, deze beter aan uw behoeften aan te passen en de bruikbaarheid ervan te vergroten.
3 |
4 |
5 |
6 | Deze cookies laten ons bijvoorbeeld de meest bezochte pagina’s van de site zien of helpen bij het identificeren van de moeilijkheden die kunnen optreden tijdens het browsen.
7 |
8 |
--------------------------------------------------------------------------------
/resources/views/lang/nl/cookies/mandatory.blade.php:
--------------------------------------------------------------------------------
1 |
2 | Deze cookies zijn essentieel voor het browsen op onze site of strikt noodzakelijk voor het leveren van een service die specifiek door een gebruiker wordt gevraagd/verwacht.
3 |
4 |
5 |
6 | Het verwijderen van dit soort cookies kan leiden tot navigatieproblemen en wordt daarom sterk afgeraden.
7 |
8 |
--------------------------------------------------------------------------------
/resources/views/lang/nl/cookies/preferences.blade.php:
--------------------------------------------------------------------------------
1 |
2 | Deze cookies verzamelen informatie over uw keuzes en voorkeuren en maken uw navigatie aangenamer en persoonlijker.
3 |
4 |
5 | Deze cookies worden gebruikt om de taal te onthouden die werd gekozen tijdens uw eerste bezoek aan onze website om deze dienovereenkomstig aan te passen.
6 |
7 |
--------------------------------------------------------------------------------
/resources/views/lang/nl/cookies/retargetting.blade.php:
--------------------------------------------------------------------------------
1 |
2 | Deze cookies laten ons bijvoorbeeld de meest bezochte pagina’s van de site zien of helpen bij het identificeren van de moeilijkheden die kunnen optreden tijdens het browsen.
3 |
4 |
--------------------------------------------------------------------------------
/resources/views/lang/nl/cookies/social.blade.php:
--------------------------------------------------------------------------------
1 |
2 | Met deze cookies kunt u de inhoud van de site met andere mensen delen via sociale netwerken. Sommige deelknoppen zijn geïntegreerd via toepassingen van derden die dit soort cookies kunnen verstrekken.
3 |
4 |
5 |
6 | Dit is met name het geval bij de knoppen [« Facebook », « Twitter », « Google + », « LinkedIn » en « Pinterest »]. Sociale netwerken die een dergelijke knop voor delen bieden, identificeren u waarschijnlijk met deze knop, zelfs als u deze knop niet hebt gebruikt bij het bezoeken van onze site.
7 |
8 |
9 |
10 | We nodigen u uit om het privacybeleid van deze sociale netwerken te raadplegen om het doel te achterhalen van het gebruik van de informatie die is verzameld via deze deelknoppen door naar hun respectieve sites te gaan.
11 |
12 |
--------------------------------------------------------------------------------
/resources/views/lang/nl/policy/doesItWorkWithoutCookies.blade.php:
--------------------------------------------------------------------------------
1 |
2 | Zal onze site nog werken zonder cookies ?
3 |
4 |
5 | U kunt onze site nog steeds bekijken, maar sommige interacties werken mogelijk niet normaal.
6 |
7 |
--------------------------------------------------------------------------------
/resources/views/lang/nl/policy/howToParameterCookies.blade.php:
--------------------------------------------------------------------------------
1 |
2 | Hoe moet je de cookies instellen ?
3 |
4 |
5 | U kunt op elk moment eenvoudig de cookies van onze site verwijderen, uitschakelen of accepteren door uw browserinstellingen te configureren.
6 |
7 |
8 | Elke browser (Internet Explorer, Safari, Firefox, Google Chrome, enz.) heeft zijn eigen cookie-configuratiemodus. Voor de procedure die u voor uw browser moet volgen, gaat u naar : http://www.allaboutcookies.org/manage-cookies/ .
9 |
10 |
11 | Als u verschillende computers, smartphones en / of tablets gebruikt, vergeet dan niet elk apparaat zo te configureren dat elk apparaat qua cookies overeenkomt met uw voorkeuren.
12 |
13 |
--------------------------------------------------------------------------------
/resources/views/lang/nl/policy/intro.blade.php:
--------------------------------------------------------------------------------
1 |
2 | Cookiepolicy
3 |
4 |
5 |
6 | Inwerkingtreding sinds:
7 | Laatste update:
8 | Vorige versies:
9 |
10 |
11 | Dit cookiebeleid (hierna: het "Cookiebeleid") beschrijft de verschillende soorten cookies die we gebruiken op onze
12 | - “Example website” (hierna de "Site") en de manier waarop u deze cookies kan instellen.
13 |
14 |
15 | We hanteren een strikt privacybeleid en we zijn vastbesloten om transparant te zijn over de technologieën die op onze site worden gebruikt.
16 |
17 |
18 | Voor zover de met cookies verzamelde informatie persoonlijke gegevens bevat, zijn de bepalingen van het Privacybeleid van toepassing en vullen dit Cookiebeleid aan.
19 |
20 |
--------------------------------------------------------------------------------
/resources/views/lang/nl/policy/otherQuestions.blade.php:
--------------------------------------------------------------------------------
1 |
2 | Andere vragen ?
3 |
4 |
5 |
6 | Indien u nog andere vragen heeft, kan u onze pagina bezoeken over gegevensbescherming of u kan ons altijd bereiken :
7 |
8 |
9 |
10 |
11 | per e-mail : contact@example.com
12 |
13 |
14 | per post op het volgende adres :
15 |
16 | Example Corp.
17 | Example street 42
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/resources/views/lang/nl/policy/whatIsACookie.blade.php:
--------------------------------------------------------------------------------
1 |
2 | Wat is een cookie ?
3 |
4 |
5 | Een "cookie" is een klein tekstbestand met informatie die wordt opgeslagen door een website op een computer of door een mobiele applicatie op de smartphone van een gebruiker. Cookies bieden de mogelijkheid om u te identificeren en verschillende informatie te onthouden om u te helpen bij het navigeren op een site / een mobiele applicatie, om deze goed te laten functioneren of om ze effectiever te maken, bijvoorbeeld door uw taalvoorkeuren.
6 |
7 |
--------------------------------------------------------------------------------
/resources/views/lang/nl/policy/whichCookieDoWeUse.blade.php:
--------------------------------------------------------------------------------
1 |
2 | Welke cookies worden er door onze website gebruikt en waarom ?
3 |
4 |
5 |
6 | Wij gebruiken verschillende soorten cookies om verschillende redenen.
7 |
8 |
9 | @include('croustillon::categoriesTable')
10 |
11 |
12 | Cookiedetails:
13 |
14 |
15 | @include('croustillon::cookiesTable')
16 |
--------------------------------------------------------------------------------
/resources/views/policy.blade.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | @include("croustillon::lang.{$locale}.policy.intro")
5 |
6 |
7 |
8 |
9 |
10 |
11 | @include("croustillon::lang.{$locale}.policy.whatIsACookie")
12 |
13 |
14 |
15 |
16 | @include("croustillon::lang.{$locale}.policy.whichCookieDoWeUse")
17 |
18 |
19 |
20 |
21 | @include("croustillon::lang.{$locale}.policy.howToParametersCookies")
22 |
23 |
24 |
25 |
26 | @include("croustillon::lang.{$locale}.policy.doesItWorkWithoutCookies")
27 |
28 |
29 |
30 |
31 | @include("croustillon::lang.{$locale}.policy.otherQuestions")
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/src/Categories/Analytics.php:
--------------------------------------------------------------------------------
1 | render();
13 | }
14 |
15 | public function name(): string
16 | {
17 | return trans('croustillon::cookies.categories.analytics');
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/Categories/CookieCategory.php:
--------------------------------------------------------------------------------
1 | name;
20 | }
21 |
22 | return trim(preg_replace('/[A-Z]/', ' $0', class_basename($this)));
23 | }
24 |
25 | public function description(): string
26 | {
27 | return $this->description;
28 | }
29 |
30 | public function value(): int
31 | {
32 | return $this->value;
33 | }
34 |
35 | public function mandatory(): bool
36 | {
37 | return $this->mandatory;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/Categories/Mandatory.php:
--------------------------------------------------------------------------------
1 | render();
16 | }
17 |
18 | public function name(): string
19 | {
20 | return trans('croustillon::cookies.categories.mandatory');
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/Categories/Preferences.php:
--------------------------------------------------------------------------------
1 | render();
13 | }
14 |
15 | public function name(): string
16 | {
17 | return trans('croustillon::cookies.categories.preferences');
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/Categories/Retargetting.php:
--------------------------------------------------------------------------------
1 | render();
13 | }
14 |
15 | public function name(): string
16 | {
17 | return trans('croustillon::cookies.categories.retargetting');
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/Categories/Social.php:
--------------------------------------------------------------------------------
1 | render();
13 | }
14 |
15 | public function name(): string
16 | {
17 | return trans('croustillon::cookies.categories.social');
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/Cookies/Cookie.php:
--------------------------------------------------------------------------------
1 | name;
25 | }
26 |
27 | public function duration(): string
28 | {
29 | return $this->duration;
30 | }
31 |
32 | public function category(): string
33 | {
34 | return class_basename($this->category);
35 | }
36 |
37 | public function source(): string
38 | {
39 | return $this->source;
40 | }
41 |
42 | public function purpose(): string
43 | {
44 | return $this->purpose;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/Cookies/CookiePolicy.php:
--------------------------------------------------------------------------------
1 | categories = $this->getCategoriesFromConfig();
22 | }
23 |
24 | /** @throw \Elhebert\Croustillon\Exceptions\CreateCookiePolicyFailed */
25 | public function registerNewPolicy(?string $className = null)
26 | {
27 | if (empty($className)) {
28 | $className = config('croustillon.policy');
29 | }
30 |
31 | $policy = app($className);
32 |
33 | if (!is_a($policy, Policy::class, true)) {
34 | throw CreateCookiePolicyFailed::invalidPolicy($policy);
35 | }
36 |
37 | $policy->configure();
38 |
39 | $this->policy = $policy;
40 | }
41 |
42 | public function categories(): Collection
43 | {
44 | return $this->categories;
45 | }
46 |
47 | public function mandatoryCategories(): Collection
48 | {
49 | return $this->categories()->filter(function ($category) {
50 | return $category->mandatory();
51 | });
52 | }
53 |
54 | public function minimumCookiePolicy(): int
55 | {
56 | return $this->mandatoryCategories()->reduce(function ($carry, $category) {
57 | return $carry += $category->value();
58 | });
59 | }
60 |
61 | public function category(string $category): CookieCategory
62 | {
63 | return $this->categories()[$category];
64 | }
65 |
66 | public function cookies(): Collection
67 | {
68 | return $this->policy->getCookies()->sortBy(function ($cookie) {
69 | return $this->category($cookie->category())->value();
70 | });
71 | }
72 |
73 | public function cookiesByCategory(): Collection
74 | {
75 | return $this->cookies()->groupBy(function ($cookie) {
76 | return $cookie->category();
77 | });
78 | }
79 |
80 | public function hasAcceptedPolicy(?int $policy = null): bool
81 | {
82 | $minimumCookiePolicy = $this->minimumCookiePolicy();
83 |
84 | $policy = $policy ?? $minimumCookiePolicy;
85 |
86 | $neededCookieLevel = decbin($policy);
87 | $acceptedCookies = decbin(Cookie::get(config('croustillon.policy_cookie')) ?? $minimumCookiePolicy);
88 |
89 | $regexp = str_replace('0', '[0-1]', $neededCookieLevel);
90 |
91 | return preg_match("/{$regexp}$/im", $acceptedCookies) === 1;
92 | }
93 |
94 | private function getCategoriesFromConfig(): Collection
95 | {
96 | $classes = config('croustillon.types');
97 |
98 | return collect($classes)
99 | ->map(function ($className) {
100 | return new $className();
101 | })->keyBy(function ($class) {
102 | return class_basename($class);
103 | });
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/src/CroustillonServiceProvider.php:
--------------------------------------------------------------------------------
1 | loadTranslationsFrom(__DIR__ . '/../resources/lang', 'croustillon');
19 | $this->loadViewsFrom(__DIR__ . '/../resources/views', 'croustillon');
20 |
21 | $this->registerPublishing();
22 | $this->registerRoutes();
23 |
24 | $this->registerViewComposer();
25 |
26 | $this->app->bind(Croustillon::class, function () {
27 | $Croustillon = new Croustillon();
28 | $Croustillon->registerNewPolicy();
29 |
30 | return $Croustillon;
31 | });
32 |
33 | $this->app->alias(Croustillon::class, 'croustillon');
34 | }
35 |
36 | /**
37 | * Register any application services.
38 | */
39 | public function register()
40 | {
41 | $this->mergeConfigFrom(__DIR__ . '/../config/croustillon.php', 'croustillon');
42 | }
43 |
44 | private function registerPublishing()
45 | {
46 | $this->publishes([
47 | __DIR__ . '/../resources/views' => resource_path('views/vendor/croustillon'),
48 | ], 'croustillon-views');
49 |
50 | $this->publishes([
51 | __DIR__ . '/../resources/lang' => resource_path('lang/vendor/croustillon'),
52 | ], 'croustillon-translations');
53 |
54 | $this->publishes([
55 | __DIR__ . '/../config/croustillon.php' => config_path('croustillon.php'),
56 | ], 'croustillon-config');
57 | }
58 |
59 | private function registerRoutes()
60 | {
61 | if (config('croustillon.enable_routes')) {
62 | Route::prefix(config('croustillon.path'))
63 | ->namespace('Elhebert\Croustillon\Http\Controllers')
64 | ->middleware('croustillon')
65 | ->group(function () {
66 | $this->loadRoutesFrom(__DIR__ . '/Http/routes.php');
67 | });
68 | }
69 | }
70 |
71 | private function registerViewComposer()
72 | {
73 | View::composer([
74 | 'croustillon::_partials.categories.*',
75 | 'croustillon::banner',
76 | 'croustillon::policy',
77 | ], function ($view) {
78 | $view->with('locale', app()->getLocale());
79 | });
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/src/Exceptions/CreateCookieFailed.php:
--------------------------------------------------------------------------------
1 | setCookie($request);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/Http/Middlewares/AddCookieBanner.php:
--------------------------------------------------------------------------------
1 | shouldAddCookieBannerToResponse()
20 | || Cookie::has(config('croustillon.policy_cookie'))
21 | || !$this->containsBodyTag($response)
22 | ) {
23 | return $response;
24 | }
25 |
26 | return $this->addBannerTo($response);
27 | }
28 |
29 | public function shouldAddCookieBannerToResponse(): bool
30 | {
31 | return $this->addCookieBanner;
32 | }
33 |
34 | protected function addBannerTo(Response $response): Response
35 | {
36 | $content = $response->getContent();
37 | $closingBodyTagPosition = $this->getLastClosingBodyTagPosition($content);
38 | $content = ''
39 | . substr($content, 0, $closingBodyTagPosition)
40 | . view('croustillon::banner')->render()
41 | . substr($content, $closingBodyTagPosition);
42 |
43 | return $response->setContent($content);
44 | }
45 |
46 | protected function containsBodyTag(Response $response): bool
47 | {
48 | return $this->getLastClosingBodyTagPosition($response->getContent()) !== false;
49 | }
50 |
51 | protected function getLastClosingBodyTagPosition(string $content = '')
52 | {
53 | return strripos($content, 'ok