Skip to content
Snippets Groups Projects
Commit 83cf9857 authored by llaffont's avatar llaffont
Browse files

Le profiling XHProf est paramétrable

parent 63b2ee20
Branches
Tags
No related merge requests found
......@@ -20,7 +20,22 @@
*/
class ZendAfi_Controller_Plugin_XHProfile extends Zend_Controller_Plugin_Abstract {
protected $_enabled = false;
protected
$_enabled = false,
$_root_path = './xhprof',
$_root_url = '/xhprof';
public function setWebappRootPath($path) {
$this->_root_path = $path;
return $this;
}
public function setRootUrl($url) {
$this->_root_url = $url;
return $this;
}
public function preDispatch(Zend_Controller_Request_Abstract $request) {
if (!Class_Users::isCurrentUserSuperAdmin())
......@@ -46,14 +61,13 @@ class ZendAfi_Controller_Plugin_XHProfile extends Zend_Controller_Plugin_Abstrac
return;
$xhprof_data = xhprof_disable();
$XHPROF_ROOT = "/usr/share/webapps/xhprof";
include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_lib.php";
include_once $XHPROF_ROOT . "/xhprof_lib/utils/xhprof_runs.php";
require_once $this->_root_path . "/xhprof_lib/utils/xhprof_lib.php";
require_once $this->_root_path . "/xhprof_lib/utils/xhprof_runs.php";
$xhprof_runs = new XHProfRuns_Default();
$run_id = $xhprof_runs->save_run($xhprof_data, "xhprof_testing");
$this->_response
->setRedirect("http://localhost/xhprof/index.php?run={$run_id}&source=xhprof_testing\n")
->setRedirect('http://localhost'.$this->_root_url."/index.php?run={$run_id}&source=xhprof_testing\n")
->clearBody();
}
}
......
......@@ -109,6 +109,8 @@ function setupConstants() {
defineConstant('MEMCACHED_ENABLE', false);
defineConstant('MEMCACHED_HOST', 'localhost');
defineConstant('MEMCACHED_PORT', '11211');
defineConstant('XHPROF_ROOT_PATH', '/usr/share/webapps/xhprof');
defineConstant('XHPROF_ROOT_URL', '/xhprof');
}
......@@ -277,7 +279,6 @@ function setupFrontController($cfg) {
->registerPlugin(new ZendAfi_Controller_Plugin_InitModule())
->registerPlugin(new ZendAfi_Controller_Plugin_SelectionBib())
->registerPlugin(new ZendAfi_Controller_Plugin_System())
->registerPlugin(new ZendAfi_Controller_Plugin_XHProfile())
->registerPlugin(new ZendAfi_Controller_Plugin_Popup())
->setParam('useDefaultControllerAlways', true);
......@@ -287,6 +288,10 @@ function setupFrontController($cfg) {
if (!Class_Users::isCurrentUserSuperAdmin())
return $front_controller;
$front_controller->registerPlugin((new ZendAfi_Controller_Plugin_XHProfile())
->setWebappRootPath(XHPROF_ROOT_PATH)
->setRootUrl(XHPROF_ROOT_URL));
set_include_path(get_include_path() . PATH_SEPARATOR . ROOT_PATH.'library/ZFDebug/library');
return $front_controller
->registerPlugin(new ZFDebug_Controller_Plugin_Debug(['plugins' =>
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment