Skip to content

Commit 78ce548

Browse files
authored
Merge pull request #81 from Troopers/paulandrieux-patch-1
Inject alert only on requests that has a session
2 parents eded39a + 7207a96 commit 78ce548

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ cache:
99
php:
1010
- 7.0
1111

12-
install: composer update
12+
install: COMPOSER_MEMORY_LIMIT=-1 composer update
1313
script: vendor/bin/phpunit -v

EventListener/AlertifyListener.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ protected function injectAlertify(Response $response, Request $request)
7171
$hasMetaRefresh = false !== strripos($content, 'http-equiv="refresh"');
7272
$forceInject = $response->headers->get('X-Inject-Alertify', false);
7373
$isRedirectResponse = $response instanceof RedirectResponse;
74+
$hasPreviousSession = $request->hasPreviousSession();
7475

75-
if ($hasBody && !$hasMetaRefresh && !$isRedirectResponse || $forceInject) {
76+
if ($hasBody && $hasPreviousSession && !$hasMetaRefresh && !$isRedirectResponse || $forceInject) {
7677
if ($response->getStatusCode() === 204) {
7778
throw new IncompatibleStatusCodeException();
7879
}

Tests/DependencyInjection/AlertifyExtensionTest.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,21 @@ public function testContexts()
3838
$container = new ContainerBuilder();
3939
$loader = new TroopersAlertifyExtension();
4040
$loader->load([[
41-
'contexts' => [
42-
'front' => [
43-
'engine' => 'notie',
44-
'options' => [
45-
'animationDelay' => 300,
46-
],
47-
],
48-
'back' => [
49-
'engine' => 'pushjs',
50-
'translationDomain' => 'admin',
41+
'contexts' => [
42+
'front' => [
43+
'engine' => 'notie',
44+
'options' => [
45+
'animationDelay' => 300,
5146
],
5247
],
53-
'default' => [
54-
'engine' => 'notie',
55-
], ]], $container);
48+
'back' => [
49+
'engine' => 'pushjs',
50+
'translationDomain' => 'admin',
51+
],
52+
],
53+
'default' => [
54+
'engine' => 'notie',
55+
], ]], $container);
5656
$this->assertSame([
5757
'contexts' => [
5858
'front' => [

0 commit comments

Comments
 (0)