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

Commit

Permalink
Merge pull request #4 from ben-challis/develop-v2
Browse files Browse the repository at this point in the history
Initial base point for version 2.0
  • Loading branch information
martin-georgiev authored Apr 12, 2018
2 parents a81fdb0 + 254d1ad commit 7875e3b
Show file tree
Hide file tree
Showing 26 changed files with 738 additions and 621 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
vendor/
composer.lock
6 changes: 0 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ cache:

matrix:
include:
- php: 7.0
env: SYMFONY_VERSION=2.7.*
- php: 7.0
env: SYMFONY_VERSION=3.3.*
- php: 7.0
env: DEPENDENCIES=beta
- php: 7.1
env: SYMFONY_VERSION=2.7.*
- php: 7.1
Expand Down
28 changes: 0 additions & 28 deletions DependencyInjection/Configuration.php

This file was deleted.

200 changes: 0 additions & 200 deletions EventListener/VisitorTrackingSubscriber.php

This file was deleted.

26 changes: 0 additions & 26 deletions Manager/DeviceFingerprintManager.php

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Visitor Tracking Bundle
=======================

A Symfony bundle to track your requests.
A Symfony bundle to track requests.

## Upgrading from 0.x to 1.x

Expand Down
17 changes: 11 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,26 @@
}
],
"require": {
"php": ">=5.6",
"symfony/framework-bundle": "~2.8|~3.0",
"php": ">=7.1",
"symfony/framework-bundle": "^3.3",
"doctrine/doctrine-bundle": "~1.6",
"doctrine/orm": "~2.1",
"stof/doctrine-extensions-bundle": "*"
"stof/doctrine-extensions-bundle": "*",
"symfony/security-bundle": "^3.3"
},
"require-dev": {
"phpunit/phpunit": "^5.6",
"roave/security-advisories": "dev-master",
"jakub-onderka/php-parallel-lint": "^0.9.2"
},
"autoload": {
"psr-0": {
"Alpha\\VisitorTrackingBundle": ""
"psr-4": {
"Alpha\\VisitorTrackingBundle\\": "src/"
}
},
"target-dir": "Alpha/VisitorTrackingBundle"
"autoload-dev": {
"psr-4": {
"Alpha\\VisitorTrackingBundle\\Tests\\": "tests/"
}
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
<?php

declare(strict_types=1);

namespace Alpha\VisitorTrackingBundle\Controller;

use Alpha\VisitorTrackingBundle\Entity\Device;
use Alpha\VisitorTrackingBundle\EventListener\VisitorTrackingSubscriber;
use Alpha\VisitorTrackingBundle\Entity\Session;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;

class DeviceController extends Controller
{
public function fingerprintAction(Request $request)
public function fingerprintAction(Request $request): Response
{
$em = $this->getDoctrine()->getManager();

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

if ($cookie) {
$device = $em->getRepository('AlphaVisitorTrackingBundle:Device')->findOneBySession($cookie);
$session = $em->getRepository('AlphaVisitorTrackingBundle:Session')->find($cookie);
if ($session instanceof Session) {
if ($session->getDevices()->count() > 0) {
$device = $session->getDevices()->first();
}
}

if (false === $device instanceof Device) {
if (!$device instanceof Device) {
$device = new Device();
$device->setFingerprint($request->getContent());
$device->setSession($session);
Expand All @@ -40,4 +42,4 @@ public function fingerprintAction(Request $request)

return new Response('', 204);
}
}
}
Loading

0 comments on commit 7875e3b

Please sign in to comment.