Passed
Push — master ( a86818...d6b808 )
by Michele
02:00
created
config/config.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -4,31 +4,31 @@
 block discarded – undo
4 4
 $COOKIE_LIFETIME_UM = 'months';
5 5
 
6 6
 return [
7
-	/*
7
+    /*
8 8
 	 * Use this setting to enable the cookie consent dialog.
9 9
 	 */
10
-	'enabled' => env('COOKIE_CONSENT_ENABLED', true),
10
+    'enabled' => env('COOKIE_CONSENT_ENABLED', true),
11 11
 
12
-	/*
12
+    /*
13 13
 	 * The name of the cookie in which we store if the user
14 14
 	 * has agreed to accept the conditions.
15 15
 	 */
16
-	'cookie_name' => env('COOKIE_CONSENT_NAME', 'laravel_cookie_consent'),
16
+    'cookie_name' => env('COOKIE_CONSENT_NAME', 'laravel_cookie_consent'),
17 17
 
18
-	/*
18
+    /*
19 19
 	 * Set the cookie duration in days.
20 20
 	 */
21
-	'cookie_lifetime' => $COOKIE_LIFETIME, // Six months
21
+    'cookie_lifetime' => $COOKIE_LIFETIME, // Six months
22 22
 
23 23
     /*
24 24
      * 4 types of cookie
25 25
      */
26
-	'cookie_types' => [
27
-		'necessary' => env('COOKIE_CONSENT_NAME', 'laravel_cookie_consent').'_necessary',
28
-		'statistics' => env('COOKIE_CONSENT_NAME', 'laravel_cookie_consent').'_statistics',
26
+    'cookie_types' => [
27
+        'necessary' => env('COOKIE_CONSENT_NAME', 'laravel_cookie_consent').'_necessary',
28
+        'statistics' => env('COOKIE_CONSENT_NAME', 'laravel_cookie_consent').'_statistics',
29 29
         'marketing' => env('COOKIE_CONSENT_NAME', 'laravel_cookie_consent').'_marketing',
30
-		'functional' => env('COOKIE_CONSENT_NAME', 'laravel_cookie_consent').'_functional',
31
-	],
30
+        'functional' => env('COOKIE_CONSENT_NAME', 'laravel_cookie_consent').'_functional',
31
+    ],
32 32
 
33 33
     /*
34 34
      * All cookies by type
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
                     'um' => 'minutes'
43 43
                 ],
44 44
                 'provider' => env('APP_NAME'),
45
-                'domain' => str_replace(['http://', 'https://'], '', env('APP_URL')),
45
+                'domain' => str_replace([ 'http://', 'https://' ], '', env('APP_URL')),
46 46
             ],
47 47
             'laravel_session' => [
48 48
                 'duration' => [
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
                     'um' => 'minutes'
51 51
                 ],
52 52
                 'provider' => env('APP_NAME'),
53
-                'domain' => str_replace(['http://', 'https://'], '', env('APP_URL')),
53
+                'domain' => str_replace([ 'http://', 'https://' ], '', env('APP_URL')),
54 54
             ],
55 55
             // Laravel Cookie Consent
56 56
             env('COOKIE_CONSENT_NAME', 'laravel_cookie_consent') => [
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
                     'um' => $COOKIE_LIFETIME_UM
60 60
                 ],
61 61
                 'provider' => env('APP_NAME'),
62
-                'domain' => str_replace(['http://', 'https://'], '', env('APP_URL')),
62
+                'domain' => str_replace([ 'http://', 'https://' ], '', env('APP_URL')),
63 63
             ],
64 64
             env('COOKIE_CONSENT_NAME', 'laravel_cookie_consent').'_statistics' => [
65 65
                 'duration' => [
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
                     'um' => $COOKIE_LIFETIME_UM
68 68
                 ],
69 69
                 'provider' => env('APP_NAME'),
70
-                'domain' => str_replace(['http://', 'https://'], '', env('APP_URL')),
70
+                'domain' => str_replace([ 'http://', 'https://' ], '', env('APP_URL')),
71 71
             ],
72 72
             env('COOKIE_CONSENT_NAME', 'laravel_cookie_consent').'_marketing' => [
73 73
                 'duration' => [
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
                     'um' => $COOKIE_LIFETIME_UM
76 76
                 ],
77 77
                 'provider' => env('APP_NAME'),
78
-                'domain' => str_replace(['http://', 'https://'], '', env('APP_URL')),
78
+                'domain' => str_replace([ 'http://', 'https://' ], '', env('APP_URL')),
79 79
             ],
80 80
             env('COOKIE_CONSENT_NAME', 'laravel_cookie_consent').'_functions' => [
81 81
                 'duration' => [
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
                     'um' => $COOKIE_LIFETIME_UM
84 84
                 ],
85 85
                 'provider' => env('APP_NAME'),
86
-                'domain' => str_replace(['http://', 'https://'], '', env('APP_URL')),
86
+                'domain' => str_replace([ 'http://', 'https://' ], '', env('APP_URL')),
87 87
             ],
88 88
             // Google reCAPTCHA
89 89
             '_GRECAPTCHA' => [
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
                     'um' => 'years'
104 104
                 ],
105 105
                 'provider' => 'Google Analytics',
106
-                'domain' => str_replace(['http://', 'https://'], '', str_replace('www', '', env('APP_URL'))),
106
+                'domain' => str_replace([ 'http://', 'https://' ], '', str_replace('www', '', env('APP_URL'))),
107 107
             ],
108 108
             '_gid' => [
109 109
                 'duration' => [
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
                     'um' => 'day'
112 112
                 ],
113 113
                 'provider' => 'Google Analytics',
114
-                'domain' => str_replace(['http://', 'https://'], '', str_replace('www', '', env('APP_URL'))),
114
+                'domain' => str_replace([ 'http://', 'https://' ], '', str_replace('www', '', env('APP_URL'))),
115 115
             ],
116 116
             '_ga_*' => [
117 117
                 'duration' => [
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
                     'um' => 'years'
120 120
                 ],
121 121
                 'provider' => 'Google Analytics',
122
-                'domain' => str_replace(['http://', 'https://'], '', str_replace('www', '', env('APP_URL'))),
122
+                'domain' => str_replace([ 'http://', 'https://' ], '', str_replace('www', '', env('APP_URL'))),
123 123
             ],
124 124
             '_gat_*' => [
125 125
                 'duration' => [
@@ -127,10 +127,10 @@  discard block
 block discarded – undo
127 127
                     'um' => 'minute'
128 128
                 ],
129 129
                 'provider' => 'Google Analytics',
130
-                'domain' => str_replace(['http://', 'https://'], '', str_replace('www', '', env('APP_URL'))),
130
+                'domain' => str_replace([ 'http://', 'https://' ], '', str_replace('www', '', env('APP_URL'))),
131 131
             ],
132 132
         ],
133
-        'marketing' => [],
134
-        'functional' => [],
133
+        'marketing' => [ ],
134
+        'functional' => [ ],
135 135
     ]
136 136
 ];
Please login to merge, or discard this patch.
resources/views/_banner.blade.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -110,7 +110,7 @@
 block discarded – undo
110 110
         data-session-secure="{{ config('session.secure') }}"
111 111
         data-button-label-accept-selected="{{ trans('laravel-cookie-consent::translations.button_accept_selected') }}"
112 112
         data-button-label-accept-all="{{ trans('laravel-cookie-consent::translations.button_accept') }}"
113
-        data-cookie-types='<?php echo json_encode($config['cookie_types']) ?>'
113
+        data-cookie-types='<?php echo json_encode($config[ 'cookie_types' ]) ?>'
114 114
         data-cookie-selected='<?php echo json_encode($cookieTypesAccepted) ?>'
115 115
     ></script>
116 116
 @endif
Please login to merge, or discard this patch.
resources/lang/it/translations.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -2,33 +2,33 @@
 block discarded – undo
2 2
 
3 3
 return [
4 4
 
5
-	'title' => 'Utilizziamo cookie',
5
+    'title' => 'Utilizziamo cookie',
6 6
     'title_description' => 'Tutti i cookie che utilizziamo',
7
-	'description' => '<p>Utilizziamo cookie per personalizzare i contenuti, avere statistiche e migliorare la tua esperienza nel nostro sito web.</p>',
7
+    'description' => '<p>Utilizziamo cookie per personalizzare i contenuti, avere statistiche e migliorare la tua esperienza nel nostro sito web.</p>',
8 8
     'description_policy' => '<p>Per maggiori informazioni ti consigliamo di leggere la nostra <a href=":cookie_policy_link" target="_blank">Cookie Policy</a>.</p>',
9
-	'button_accept' => 'Consenti tutti',
9
+    'button_accept' => 'Consenti tutti',
10 10
     'button_accept_necessary' => 'Rifiuta tutti',
11
-	'button_accept_selected' => 'Consenti selezionati',
11
+    'button_accept_selected' => 'Consenti selezionati',
12 12
     'button_save_changes' => 'Salva modifiche',
13
-	'button_more_info' => 'Maggiori informazioni',
14
-	'no_cookies_used' => 'Nessun cookie utilizzato per questa categoria',
13
+    'button_more_info' => 'Maggiori informazioni',
14
+    'no_cookies_used' => 'Nessun cookie utilizzato per questa categoria',
15 15
 
16
-	'necessary' => [
17
-		'title' => 'Strettamente necessari',
18
-		'description' => '<p>Questi cookie sono necessari per il funzionamento del sito Web e non possono essere disattivati nei nostri sistemi.</p><p>È possibile impostare il browser in modo che blocchi questi cookie o ne avvisi l\'utilizzo, ma alcune parti del sito non funzioneranno. Questi cookie non memorizzano alcuna informazione personale identificativa.</p>',
19
-	],
20
-	'statistics' => [
21
-		'title' => 'Statistici',
22
-		'description' => '<p>Questi cookie ci consentono di contare le visite e le sorgenti di traffico in modo da poter misurare e migliorare le prestazioni del nostro sito. Ci aiutano a sapere quali sono le pagine più e meno popolari e vedere come i visitatori si muovono nel sito.</p><p>Tutte le informazioni raccolte da questi cookie sono aggregate e quindi anonime. Se non autorizzi questi cookie, non sapremo quando avrai visitato il nostro sito e non saremo in grado di monitorarne le prestazioni.</p>',
23
-	],
24
-	'functional' => [
25
-		'title' => 'Funzionali e di terze parti',
26
-		'description' => '<p>Questi cookie consentono al sito Web di fornire funzionalità e personalizzazione avanzate. Possono essere impostati da noi o da fornitori di terze parti, i cui servizi sono stati aggiunti alle nostre pagine.</p><p>Se non si consente questi cookie, alcuni o tutti questi servizi potrebbero non funzionare correttamente.</p>',
27
-	],
28
-	'marketing' => [
29
-		'title' => 'Marketing e targeting',
30
-		'description' => '<p>Questi cookie possono essere impostati tramite il nostro sito dai nostri partner pubblicitari. Possono essere utilizzati da tali società per creare un profilo dei tuoi interessi e mostrarti annunci pertinenti su altri siti.</p><p>Non memorizzano direttamente informazioni personali, ma si basano sull\'identificazione univoca del browser e del dispositivo Internet. Se non si consente questi cookie, si verificherà una pubblicità meno mirata.</p>',
31
-	],
16
+    'necessary' => [
17
+        'title' => 'Strettamente necessari',
18
+        'description' => '<p>Questi cookie sono necessari per il funzionamento del sito Web e non possono essere disattivati nei nostri sistemi.</p><p>È possibile impostare il browser in modo che blocchi questi cookie o ne avvisi l\'utilizzo, ma alcune parti del sito non funzioneranno. Questi cookie non memorizzano alcuna informazione personale identificativa.</p>',
19
+    ],
20
+    'statistics' => [
21
+        'title' => 'Statistici',
22
+        'description' => '<p>Questi cookie ci consentono di contare le visite e le sorgenti di traffico in modo da poter misurare e migliorare le prestazioni del nostro sito. Ci aiutano a sapere quali sono le pagine più e meno popolari e vedere come i visitatori si muovono nel sito.</p><p>Tutte le informazioni raccolte da questi cookie sono aggregate e quindi anonime. Se non autorizzi questi cookie, non sapremo quando avrai visitato il nostro sito e non saremo in grado di monitorarne le prestazioni.</p>',
23
+    ],
24
+    'functional' => [
25
+        'title' => 'Funzionali e di terze parti',
26
+        'description' => '<p>Questi cookie consentono al sito Web di fornire funzionalità e personalizzazione avanzate. Possono essere impostati da noi o da fornitori di terze parti, i cui servizi sono stati aggiunti alle nostre pagine.</p><p>Se non si consente questi cookie, alcuni o tutti questi servizi potrebbero non funzionare correttamente.</p>',
27
+    ],
28
+    'marketing' => [
29
+        'title' => 'Marketing e targeting',
30
+        'description' => '<p>Questi cookie possono essere impostati tramite il nostro sito dai nostri partner pubblicitari. Possono essere utilizzati da tali società per creare un profilo dei tuoi interessi e mostrarti annunci pertinenti su altri siti.</p><p>Non memorizzano direttamente informazioni personali, ma si basano sull\'identificazione univoca del browser e del dispositivo Internet. Se non si consente questi cookie, si verificherà una pubblicità meno mirata.</p>',
31
+    ],
32 32
 
33 33
     // Cookies descriptions
34 34
     'cookies' => [
Please login to merge, or discard this patch.
resources/lang/en/translations.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -2,33 +2,33 @@
 block discarded – undo
2 2
 
3 3
 return [
4 4
 
5
-	'title' => 'We use cookies',
5
+    'title' => 'We use cookies',
6 6
     'title_description' => 'All cookies we use',
7
-	'description' => '<p>We use cookies to personalize content, to get statistics and to improve your experience on our website.</p>',
7
+    'description' => '<p>We use cookies to personalize content, to get statistics and to improve your experience on our website.</p>',
8 8
     'description_policy' => '<p>For more information please read our <a href=":cookie_policy_link" target="_blank">Cookie Policy</a>.</p>',
9
-	'button_accept' => 'Accept all',
9
+    'button_accept' => 'Accept all',
10 10
     'button_accept_necessary' => 'Reject all',
11
-	'button_accept_selected' => 'Accept selected',
11
+    'button_accept_selected' => 'Accept selected',
12 12
     'button_save_changes' => 'Save changes',
13
-	'button_more_info' => 'More information',
14
-	'no_cookies_used' => 'No cookies used for this type',
13
+    'button_more_info' => 'More information',
14
+    'no_cookies_used' => 'No cookies used for this type',
15 15
 
16
-	'necessary' => [
17
-		'title' => 'Strictly necessary',
18
-		'description' => '<p>These cookies are necessary for the website to function and cannot be switched off in our systems.</p><p>You can set your browser to block or alert you about these cookies, but some parts of the site will not then work. These cookies do not store any personally identifiable information.</p>',
19
-	],
20
-	'statistics' => [
21
-		'title' => 'Statistics',
22
-		'description' => '<p>These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us to know which pages are the most and least popular and see how visitors move around the site.</p><p>All information these cookies collect is aggregated and therefore anonymous. If you do not allow these cookies we will not know when you have visited our site, and will not be able to monitor its performance.</p>',
23
-	],
24
-	'functional' => [
25
-		'title' => 'Functional and third party',
26
-		'description' => '<p>These cookies enable the website to provide enhanced functionality and personalisation. They may be set by us or by third party providers whose services we have added to our pages.</p><p>If you do not allow these cookies then some or all of these services may not function properly.</p>',
27
-	],
28
-	'marketing' => [
29
-		'title' => 'Marketing and targeting',
30
-		'description' => '<p>These cookies may be set through our site by our advertising partners. They may be used by those companies to build a profile of your interests and show you relevant adverts on other sites.</p><p>They do not store directly personal information, but are based on uniquely identifying your browser and internet device. If you do not allow these cookies, you will experience less targeted advertising.</p>',
31
-	],
16
+    'necessary' => [
17
+        'title' => 'Strictly necessary',
18
+        'description' => '<p>These cookies are necessary for the website to function and cannot be switched off in our systems.</p><p>You can set your browser to block or alert you about these cookies, but some parts of the site will not then work. These cookies do not store any personally identifiable information.</p>',
19
+    ],
20
+    'statistics' => [
21
+        'title' => 'Statistics',
22
+        'description' => '<p>These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us to know which pages are the most and least popular and see how visitors move around the site.</p><p>All information these cookies collect is aggregated and therefore anonymous. If you do not allow these cookies we will not know when you have visited our site, and will not be able to monitor its performance.</p>',
23
+    ],
24
+    'functional' => [
25
+        'title' => 'Functional and third party',
26
+        'description' => '<p>These cookies enable the website to provide enhanced functionality and personalisation. They may be set by us or by third party providers whose services we have added to our pages.</p><p>If you do not allow these cookies then some or all of these services may not function properly.</p>',
27
+    ],
28
+    'marketing' => [
29
+        'title' => 'Marketing and targeting',
30
+        'description' => '<p>These cookies may be set through our site by our advertising partners. They may be used by those companies to build a profile of your interests and show you relevant adverts on other sites.</p><p>They do not store directly personal information, but are based on uniquely identifying your browser and internet device. If you do not allow these cookies, you will experience less targeted advertising.</p>',
31
+    ],
32 32
 
33 33
     // Cookies descriptions
34 34
     'cookies' => [
Please login to merge, or discard this patch.
src/LaravelCookieConsentServiceProvider.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -17,11 +17,11 @@
 block discarded – undo
17 17
         $this->loadTranslationsFrom(__DIR__.'/../resources/lang', 'laravel-cookie-consent');
18 18
         $this->loadViewsFrom(__DIR__.'/../resources/views', 'laravel-cookie-consent');
19 19
 
20
-        $this->publishes([__DIR__.'/../config/config.php' => config_path('laravel-cookie-consent.php')], 'config');
21
-        $this->publishes([__DIR__.'/../resources/lang' => resource_path('lang/vendor/laravel-cookie-consent')], 'lang');
22
-        $this->publishes([__DIR__.'/../resources/js' => public_path('vendor/laravel-cookie-consent')], 'public');
23
-        $this->publishes([__DIR__.'/../resources/css' => public_path('vendor/laravel-cookie-consent')], 'public');
24
-        $this->publishes([__DIR__.'/../resources/views' => resource_path('views/vendor/laravel-cookie-consent')], 'views');
20
+        $this->publishes([ __DIR__.'/../config/config.php' => config_path('laravel-cookie-consent.php') ], 'config');
21
+        $this->publishes([ __DIR__.'/../resources/lang' => resource_path('lang/vendor/laravel-cookie-consent') ], 'lang');
22
+        $this->publishes([ __DIR__.'/../resources/js' => public_path('vendor/laravel-cookie-consent') ], 'public');
23
+        $this->publishes([ __DIR__.'/../resources/css' => public_path('vendor/laravel-cookie-consent') ], 'public');
24
+        $this->publishes([ __DIR__.'/../resources/views' => resource_path('views/vendor/laravel-cookie-consent') ], 'views');
25 25
     }
26 26
 
27 27
     /**
Please login to merge, or discard this patch.
src/Http/Middleware/LaravelCookieConsent.php 3 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,9 @@
 block discarded – undo
40 40
     {
41 41
         $cookieTypesConsent = [];
42 42
         foreach(config('laravel-cookie-consent.cookie_types') as $type => $cookie_name) {
43
-            if(array_key_exists($cookie_name, $request->cookie())) $cookieTypesConsent[] = $cookie_name;
43
+            if(array_key_exists($cookie_name, $request->cookie())) {
44
+                $cookieTypesConsent[] = $cookie_name;
45
+            }
44 46
         }
45 47
         return $cookieTypesConsent;
46 48
     }
Please login to merge, or discard this patch.
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -8,27 +8,27 @@  discard block
 block discarded – undo
8 8
 
9 9
 class LaravelCookieConsent
10 10
 {
11
-	/**
12
-	 * Handle an incoming request.
13
-	 * @param $request
14
-	 * @param Closure $next
15
-	 *
16
-	 * @return LaravelCookieConsent|mixed
17
-	 * @throws Throwable
18
-	 */
19
-	public function handle($request, Closure $next)
20
-	{
21
-		$alreadyAccepted = array_key_exists(config('laravel-cookie-consent.cookie_name'), $request->cookie());
11
+    /**
12
+     * Handle an incoming request.
13
+     * @param $request
14
+     * @param Closure $next
15
+     *
16
+     * @return LaravelCookieConsent|mixed
17
+     * @throws Throwable
18
+     */
19
+    public function handle($request, Closure $next)
20
+    {
21
+        $alreadyAccepted = array_key_exists(config('laravel-cookie-consent.cookie_name'), $request->cookie());
22 22
         $cookieTypesAccepted = $this->getCookieTypesConsent($request);
23
-		$response = $next($request);
24
-		if (! $response instanceof Response) {
25
-			return $response;
26
-		}
27
-		if (! $this->containsBodyTag($response)) {
28
-			return $response;
29
-		}
30
-		return $this->addCookieConsentScriptToResponse($response, $alreadyAccepted, $cookieTypesAccepted);
31
-	}
23
+        $response = $next($request);
24
+        if (! $response instanceof Response) {
25
+            return $response;
26
+        }
27
+        if (! $this->containsBodyTag($response)) {
28
+            return $response;
29
+        }
30
+        return $this->addCookieConsentScriptToResponse($response, $alreadyAccepted, $cookieTypesAccepted);
31
+    }
32 32
 
33 33
     /**
34 34
      * Get the cookie preference for the user
@@ -45,16 +45,16 @@  discard block
 block discarded – undo
45 45
         return $cookieTypesConsent;
46 46
     }
47 47
 
48
-	/**
49
-	 * Check if the application contains body tag
50
-	 * @param Response $response
51
-	 *
52
-	 * @return bool
53
-	 */
54
-	protected function containsBodyTag(Response $response): bool
48
+    /**
49
+     * Check if the application contains body tag
50
+     * @param Response $response
51
+     *
52
+     * @return bool
53
+     */
54
+    protected function containsBodyTag(Response $response): bool
55 55
     {
56
-		return $this->getLastClosingBodyTagPosition($response->getContent()) != false;
57
-	}
56
+        return $this->getLastClosingBodyTagPosition($response->getContent()) != false;
57
+    }
58 58
 
59 59
     /**
60 60
      * Add cookie consent container to the response
@@ -66,27 +66,27 @@  discard block
 block discarded – undo
66 66
      * @return Response
67 67
      * @throws Throwable
68 68
      */
69
-	protected function addCookieConsentScriptToResponse(Response $response, $alreadyAccepted, $cookieTypesAccepted): Response
69
+    protected function addCookieConsentScriptToResponse(Response $response, $alreadyAccepted, $cookieTypesAccepted): Response
70 70
     {
71
-		$content = $response->getContent();
72
-		//if(!$alreadyAccepted) {
73
-			$closingBodyTagPosition = $this->getLastClosingBodyTagPosition($content);
74
-			$content = ''
75
-			           .substr($content, 0, $closingBodyTagPosition)
76
-			           .view('laravel-cookie-consent::_banner', ['alreadyAccepted' => $alreadyAccepted, 'cookieTypesAccepted' => $cookieTypesAccepted])->render()
77
-			           .substr($content, $closingBodyTagPosition);
78
-		//}
79
-		return $response->setContent($content);
80
-	}
71
+        $content = $response->getContent();
72
+        //if(!$alreadyAccepted) {
73
+            $closingBodyTagPosition = $this->getLastClosingBodyTagPosition($content);
74
+            $content = ''
75
+                        .substr($content, 0, $closingBodyTagPosition)
76
+                        .view('laravel-cookie-consent::_banner', ['alreadyAccepted' => $alreadyAccepted, 'cookieTypesAccepted' => $cookieTypesAccepted])->render()
77
+                        .substr($content, $closingBodyTagPosition);
78
+        //}
79
+        return $response->setContent($content);
80
+    }
81 81
 
82
-	/**
83
-	 * Get last closing body tag position
84
-	 * @param string $content
85
-	 *
86
-	 * @return int
87
-	 */
88
-	protected function getLastClosingBodyTagPosition(string $content = ''): int|false
82
+    /**
83
+     * Get last closing body tag position
84
+     * @param string $content
85
+     *
86
+     * @return int
87
+     */
88
+    protected function getLastClosingBodyTagPosition(string $content = ''): int|false
89 89
     {
90
-		return strripos($content, '</body>');
91
-	}
90
+        return strripos($content, '</body>');
91
+    }
92 92
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -21,10 +21,10 @@  discard block
 block discarded – undo
21 21
 		$alreadyAccepted = array_key_exists(config('laravel-cookie-consent.cookie_name'), $request->cookie());
22 22
         $cookieTypesAccepted = $this->getCookieTypesConsent($request);
23 23
 		$response = $next($request);
24
-		if (! $response instanceof Response) {
24
+		if (!$response instanceof Response) {
25 25
 			return $response;
26 26
 		}
27
-		if (! $this->containsBodyTag($response)) {
27
+		if (!$this->containsBodyTag($response)) {
28 28
 			return $response;
29 29
 		}
30 30
 		return $this->addCookieConsentScriptToResponse($response, $alreadyAccepted, $cookieTypesAccepted);
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
      */
39 39
     public function getCookieTypesConsent($request): array
40 40
     {
41
-        $cookieTypesConsent = [];
42
-        foreach(config('laravel-cookie-consent.cookie_types') as $type => $cookie_name) {
43
-            if(array_key_exists($cookie_name, $request->cookie())) $cookieTypesConsent[] = $cookie_name;
41
+        $cookieTypesConsent = [ ];
42
+        foreach (config('laravel-cookie-consent.cookie_types') as $type => $cookie_name) {
43
+            if (array_key_exists($cookie_name, $request->cookie())) $cookieTypesConsent[ ] = $cookie_name;
44 44
         }
45 45
         return $cookieTypesConsent;
46 46
     }
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 			$closingBodyTagPosition = $this->getLastClosingBodyTagPosition($content);
74 74
 			$content = ''
75 75
 			           .substr($content, 0, $closingBodyTagPosition)
76
-			           .view('laravel-cookie-consent::_banner', ['alreadyAccepted' => $alreadyAccepted, 'cookieTypesAccepted' => $cookieTypesAccepted])->render()
76
+			           .view('laravel-cookie-consent::_banner', [ 'alreadyAccepted' => $alreadyAccepted, 'cookieTypesAccepted' => $cookieTypesAccepted ])->render()
77 77
 			           .substr($content, $closingBodyTagPosition);
78 78
 		//}
79 79
 		return $response->setContent($content);
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 	 *
86 86
 	 * @return int
87 87
 	 */
88
-	protected function getLastClosingBodyTagPosition(string $content = ''): int|false
88
+	protected function getLastClosingBodyTagPosition(string $content = ''): int | false
89 89
     {
90 90
 		return strripos($content, '</body>');
91 91
 	}
Please login to merge, or discard this patch.