Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support manual beacon implementation #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions newrelic/NewRelicPlugin.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,10 @@ public function init()
}
}

public function addTwigExtension()
{
Craft::import('plugins.newrelic.twigextensions.NewRelicTwigExtension');
return new NewRelicTwigExtension();
}

}
67 changes: 67 additions & 0 deletions newrelic/twigextensions/NewRelicTwigExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

namespace Craft;

use Twig_Extension;

class NewRelicTwigExtension extends \Twig_Extension
{

/**
* Returns the name of the extension.
*
* @return string The extension name
*/
public function getName()
{
return 'newrelic';
}

/**
* Returns a list of functions to add to the existing list.
*
* @return array An array of functions
*/
public function getFunctions()
{
return array(
new \Twig_SimpleFunction(
'newrelic_get_browser_timing_header',
array($this, 'newrelic_get_browser_timing_header'),
array('is_safe' => array('html'))
),
new \Twig_SimpleFunction(
'newrelic_get_browser_timing_footer',
array($this, 'newrelic_get_browser_timing_footer'),
array('is_safe' => array('html'))
),
);
}

/**
* Get New Relic timing header
*
* @return string
*/
public function newrelic_get_browser_timing_header() {
if (extension_loaded('newrelic')) {
return newrelic_get_browser_timing_header();
} else {
return null;
}
}

/**
* Get New Relic timing footer
*
* @return string
*/
public function newrelic_get_browser_timing_footer() {
if (extension_loaded('newrelic')) {
return newrelic_get_browser_timing_footer();
} else {
return null;
}
}

}