Skip to content

Commit

Permalink
Merge pull request #396 from perftools/config-access
Browse files Browse the repository at this point in the history
  • Loading branch information
glensc authored Dec 22, 2020
2 parents a04df57 + 27785bf commit e43abad
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
5 changes: 5 additions & 0 deletions src/AbstractController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,9 @@ public function render()
$body = $this->app->view->fetch($this->_template);
$this->app->response->write($body);
}

protected function config(string $key)
{
return $this->app->config($key);
}
}
2 changes: 1 addition & 1 deletion src/Controller/CustomController.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function query(Request $request, Response $response)
return $response->body($json);
}

$perPage = $this->app->config('page.limit');
$perPage = $this->config('page.limit');

$res = $this->searcher->query($query, $perPage, $retrieve);

Expand Down
20 changes: 10 additions & 10 deletions src/Controller/RunController.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function index(Request $request, Response $response)
'sort' => $sort,
'page' => (int)$request->get('page', SearcherInterface::DEFAULT_PAGE),
'direction' => $request->get('direction'),
'perPage' => (int)$this->app->config('page.limit'),
'perPage' => (int)$this->config('page.limit'),
'conditions' => $search,
'projection' => true,
]));
Expand All @@ -76,7 +76,7 @@ public function index(Request $request, Response $response)
'paging' => $paging,
'base_url' => 'home',
'runs' => $result['results'],
'date_format' => $this->app->config('date.format'),
'date_format' => $this->config('date.format'),
'search' => $search,
'has_search' => strlen(implode('', $search)) > 0,
'title' => $title,
Expand All @@ -94,7 +94,7 @@ public function view(Request $request, Response $response)
// https://github.com/perftools/xhgui/issues/261
$response->headers->set('Cache-Control', 'public, max-age=60, must-revalidate');

$detailCount = $this->app->config('detail.count');
$detailCount = $this->config('detail.count');
$result = $this->searcher->get($request->get('id'));

$result->calculateSelf();
Expand Down Expand Up @@ -127,7 +127,7 @@ public function view(Request $request, Response $response)
'wall_time' => $timeChart,
'memory' => $memoryChart,
'watches' => $watchedFunctions,
'date_format' => $this->app->config('date.format'),
'date_format' => $this->config('date.format'),
]);
}

Expand All @@ -141,7 +141,7 @@ protected function getFilters()
if (strlen($filterString) > 1 && $filterString !== 'true') {
$filters = array_map('trim', explode(',', $filterString));
} else {
$filters = $this->app->config('run.view.filter.names');
$filters = $this->config('run.view.filter.names');
}

return $filters;
Expand Down Expand Up @@ -204,7 +204,7 @@ public function url(Request $request)
'sort' => $request->get('sort'),
'direction' => $request->get('direction'),
'page' => $request->get('page'),
'perPage' => $this->app->config('page.limit'),
'perPage' => $this->config('page.limit'),
];

$search = [];
Expand Down Expand Up @@ -246,7 +246,7 @@ public function url(Request $request)
'runs' => $runs['results'],
'url' => $request->get('url'),
'chart_data' => $chartData,
'date_format' => $this->app->config('date.format'),
'date_format' => $this->config('date.format'),
'search' => array_merge($search, ['url' => $request->get('url')]),
]);
}
Expand All @@ -265,7 +265,7 @@ public function compare(Request $request)
'direction' => $request->get('direction'),
'sort' => $request->get('sort'),
'page' => $request->get('page'),
'perPage' => $this->app->config('page.limit'),
'perPage' => $this->config('page.limit'),
];
$candidates = $this->searcher->getForUrl(
$baseRun->getMeta('simple_url'),
Expand Down Expand Up @@ -295,7 +295,7 @@ public function compare(Request $request)
'head_run' => $headRun,
'candidates' => $candidates,
'url_params' => $request->get(),
'date_format' => $this->app->config('date.format'),
'date_format' => $this->config('date.format'),
'comparison' => $comparison,
'paging' => $paging,
'search' => [
Expand Down Expand Up @@ -354,7 +354,7 @@ public function callgraph(Request $request)
$this->_template = 'runs/callgraph.twig';
$this->set([
'profile' => $profile,
'date_format' => $this->app->config('date.format'),
'date_format' => $this->config('date.format'),
]);
}

Expand Down

0 comments on commit e43abad

Please sign in to comment.