Skip to content
This repository was archived by the owner on Aug 31, 2023. It is now read-only.

Commit 7875e3b

Browse files
Merge pull request #4 from ben-challis/develop-v2
Initial base point for version 2.0
2 parents a81fdb0 + 254d1ad commit 7875e3b

26 files changed

+738
-621
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
vendor/
2+
composer.lock

.travis.yml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@ cache:
88

99
matrix:
1010
include:
11-
- php: 7.0
12-
env: SYMFONY_VERSION=2.7.*
13-
- php: 7.0
14-
env: SYMFONY_VERSION=3.3.*
15-
- php: 7.0
16-
env: DEPENDENCIES=beta
1711
- php: 7.1
1812
env: SYMFONY_VERSION=2.7.*
1913
- php: 7.1

DependencyInjection/Configuration.php

Lines changed: 0 additions & 28 deletions
This file was deleted.

EventListener/VisitorTrackingSubscriber.php

Lines changed: 0 additions & 200 deletions
This file was deleted.

Manager/DeviceFingerprintManager.php

Lines changed: 0 additions & 26 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Visitor Tracking Bundle
44
=======================
55

6-
A Symfony bundle to track your requests.
6+
A Symfony bundle to track requests.
77

88
## Upgrading from 0.x to 1.x
99

composer.json

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,26 @@
1515
}
1616
],
1717
"require": {
18-
"php": ">=5.6",
19-
"symfony/framework-bundle": "~2.8|~3.0",
18+
"php": ">=7.1",
19+
"symfony/framework-bundle": "^3.3",
2020
"doctrine/doctrine-bundle": "~1.6",
2121
"doctrine/orm": "~2.1",
22-
"stof/doctrine-extensions-bundle": "*"
22+
"stof/doctrine-extensions-bundle": "*",
23+
"symfony/security-bundle": "^3.3"
2324
},
2425
"require-dev": {
2526
"phpunit/phpunit": "^5.6",
2627
"roave/security-advisories": "dev-master",
2728
"jakub-onderka/php-parallel-lint": "^0.9.2"
2829
},
2930
"autoload": {
30-
"psr-0": {
31-
"Alpha\\VisitorTrackingBundle": ""
31+
"psr-4": {
32+
"Alpha\\VisitorTrackingBundle\\": "src/"
3233
}
3334
},
34-
"target-dir": "Alpha/VisitorTrackingBundle"
35+
"autoload-dev": {
36+
"psr-4": {
37+
"Alpha\\VisitorTrackingBundle\\Tests\\": "tests/"
38+
}
39+
}
3540
}
File renamed without changes.
Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Alpha\VisitorTrackingBundle\Controller;
46

57
use Alpha\VisitorTrackingBundle\Entity\Device;
6-
use Alpha\VisitorTrackingBundle\EventListener\VisitorTrackingSubscriber;
8+
use Alpha\VisitorTrackingBundle\Entity\Session;
79
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
810
use Symfony\Component\HttpFoundation\Request;
911
use Symfony\Component\HttpFoundation\Response;
1012

1113
class DeviceController extends Controller
1214
{
13-
public function fingerprintAction(Request $request)
15+
public function fingerprintAction(Request $request): Response
1416
{
1517
$em = $this->getDoctrine()->getManager();
1618

17-
$cookie = $request->cookies->get(VisitorTrackingSubscriber::COOKIE_SESSION, false);
19+
$session = $this->get('alpha.visitor_tracking.storage.session')->getSession();
1820
$device = null;
19-
$session = null;
2021

21-
if ($cookie) {
22-
$device = $em->getRepository('AlphaVisitorTrackingBundle:Device')->findOneBySession($cookie);
23-
$session = $em->getRepository('AlphaVisitorTrackingBundle:Session')->find($cookie);
22+
if ($session instanceof Session) {
23+
if ($session->getDevices()->count() > 0) {
24+
$device = $session->getDevices()->first();
25+
}
2426
}
2527

26-
if (false === $device instanceof Device) {
28+
if (!$device instanceof Device) {
2729
$device = new Device();
2830
$device->setFingerprint($request->getContent());
2931
$device->setSession($session);
@@ -40,4 +42,4 @@ public function fingerprintAction(Request $request)
4042

4143
return new Response('', 204);
4244
}
43-
}
45+
}

0 commit comments

Comments
 (0)