Permalink
Browse files

Merge branch 'feature/config-convenience'

  • Loading branch information...
2 parents 5d86f7f + 1d76aa3 commit 17bf372b9fc60f41355919a5b50e9dcd9f0eb154 Jurian Sluiman committed Sep 10, 2012
Showing with 52 additions and 37 deletions.
  1. +46 −0 Module.php
  2. +4 −35 config/module.config.php
  3. +2 −2 config/slmgoogleanalytics.global.php.dist
View
@@ -44,9 +44,14 @@
use Zend\ModuleManager\Feature;
use Zend\Mvc\MvcEvent;
+use SlmGoogleAnalytics\Analytics;
+use SlmGoogleAnalytics\View\Helper;
+
class Module implements
Feature\AutoloaderProviderInterface,
Feature\ConfigProviderInterface,
+ Feature\ViewHelperProviderInterface,
+ Feature\ServiceProviderInterface,
Feature\BootstrapListenerInterface
{
public function getAutoloaderConfig()
@@ -68,6 +73,47 @@ public function getConfig()
return include __DIR__ . '/config/module.config.php';
}
+ public function getViewHelperConfig()
+ {
+ return array(
+ 'factories' => array(
+ 'googleAnalytics' => function($sm) {
+ $tracker = $sm->getServiceLocator()->get('google-analytics');
+ $helper = new Helper\GoogleAnalytics($tracker);
+
+ return $helper;
+ },
+ ),
+ );
+ }
+
+ public function getServiceConfig()
+ {
+ return array(
+ 'aliases' => array(
+ 'google-analytics' => 'SlmGoogleAnalytics\Analytics\Tracker',
+ ),
+ 'factories' => array(
+ 'SlmGoogleAnalytics\Analytics\Tracker' => function($sm) {
+ $config = $sm->get('config');
+ $config = $config['google_analytics'];
+
+ $tracker = new Analytics\Tracker($config['id']);
+
+ if (isset($config['domain_name'])) {
+ $tracker->setDomainName($config['domain_name']);
+ }
+
+ if (isset($config['allow_linker'])) {
+ $tracker->setAllowLinker($config['allow_linker']);
+ }
+
+ return $tracker;
+ },
+ ),
+ );
+ }
+
/**
* When the render event is triggered, we invoke the view helper to
* render the javascript code.
@@ -39,41 +39,10 @@
* @link http://juriansluiman.nl
*/
-use SlmGoogleAnalytics\Analytics;
-use SlmGoogleAnalytics\View\Helper;
-
return array(
- 'view_helpers' => array(
- 'factories' => array(
- 'googleAnalytics' => function($sm) {
- $tracker = $sm->getServiceLocator()->get('google-analytics');
- $helper = new Helper\GoogleAnalytics($tracker);
-
- return $helper;
- },
- ),
- ),
- 'service_manager' => array(
- 'aliases' => array(
- 'google-analytics' => 'SlmGoogleAnalytics\Analytics\Tracker',
- ),
- 'factories' => array(
- 'SlmGoogleAnalytics\Analytics\Tracker' => function($sm) {
- $config = $sm->get('config');
- $config = $config['google_analytics'];
-
- $tracker = new Analytics\Tracker($config['id']);
-
- if (isset($config['domain_name'])) {
- $tracker->setDomainName($config['domain_name']);
- }
-
- if (isset($config['allow_linker'])) {
- $tracker->setAllowLinker($config['allow_linker']);
- }
-
- return $tracker;
- },
- ),
+ 'google_analytics' => array(
+ 'id' => '',
+ 'domain_name' => '',
+ 'allow_linker' => false,
),
);
@@ -10,12 +10,12 @@ $googleAnalytics = array(
* Web property ID (something like UA-xxxxx-x)
*/
'id' => '',
-
+
/**
* Tracking across multiple (sub)domains
* @see https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingSite
*/
- 'domain_name' => false,
+ 'domain_name' => '',
'allow_linking' => false,
);

0 comments on commit 17bf372

Please sign in to comment.