Skip to content

Commit 9b08d5d

Browse files
committed
Initial commit
0 parents  commit 9b08d5d

63 files changed

Lines changed: 5487 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
composer.phar
2+
vendor/
3+
4+
# Commit your application's lock file http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file
5+
# You may choose to ignore a library lock file http://getcomposer.org/doc/02-libraries.md#lock-file
6+
composer.lock

Adwords.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
3+
namespace AntiMattr\GoogleBundle;
4+
5+
use AntiMattr\GoogleBundle\Adwords\Conversion;
6+
use Symfony\Component\DependencyInjection\ContainerInterface;
7+
8+
class Adwords
9+
{
10+
const CONVERSION_KEY = 'google_adwords/conversion';
11+
12+
private $activeConversion;
13+
private $container;
14+
private $conversions;
15+
16+
public function __construct(ContainerInterface $container, array $conversions = array())
17+
{
18+
$this->container = $container;
19+
$this->conversions = $conversions;
20+
}
21+
22+
/**
23+
* @param string $key
24+
*/
25+
public function activateConversionByKey($key)
26+
{
27+
if (array_key_exists($key, $this->conversions)) {
28+
$this->container->get('session')->set(self::CONVERSION_KEY, $key);
29+
}
30+
}
31+
32+
/**
33+
* @return Conversion $conversion
34+
*/
35+
public function getActiveConversion()
36+
{
37+
if ($this->hasActiveConversion()) {
38+
$key = $this->container->get('session')->get(self::CONVERSION_KEY);
39+
$this->container->get('session')->remove(self::CONVERSION_KEY);
40+
$config = $this->conversions[$key];
41+
$this->activeConversion = new Conversion($config['id'], $config['label'], $config['value']);
42+
}
43+
return $this->activeConversion;
44+
}
45+
46+
/**
47+
* @param boolean $hasActiveConversion
48+
*/
49+
public function hasActiveConversion()
50+
{
51+
return $this->container->get('session')->has(self::CONVERSION_KEY);
52+
}
53+
}

Adwords/Conversion.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace AntiMattr\GoogleBundle\Adwords;
4+
5+
class Conversion
6+
{
7+
private $id;
8+
private $label;
9+
private $value;
10+
11+
public function __construct($id, $label, $value)
12+
{
13+
$this->id = $id;
14+
$this->label = $label;
15+
$this->value = $value;
16+
}
17+
18+
public function getId()
19+
{
20+
return $this->id;
21+
}
22+
23+
public function getLabel()
24+
{
25+
return $this->label;
26+
}
27+
28+
public function getValue()
29+
{
30+
return $this->value;
31+
}
32+
}

0 commit comments

Comments
 (0)