The Gitlab instance will be restarted on Monday April 28th at 2AM. There will be a short interruption of service.

Skip to content
Snippets Groups Projects
Commit 737d9680 authored by Ere Maijala's avatar Ere Maijala Committed by Demian Katz
Browse files

Make Piwik helper more robust. (#1191)

- Check for current view in Piwik helper before trying to access it.
- Try also the current view for record driver in Piwik helper.
parent 370a6d6a
No related merge requests found
......@@ -4,7 +4,7 @@
*
* PHP version 7
*
* Copyright (C) The National Library of Finland 2014-2016.
* Copyright (C) The National Library of Finland 2014-2018.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
......@@ -257,10 +257,11 @@ class Piwik extends \Zend\View\Helper\AbstractHelper
protected function getSearchResults()
{
$viewModel = $this->getView()->plugin('view_model');
if ('layout/lightbox' === $viewModel->getCurrent()->getTemplate()) {
$current = $viewModel->getCurrent();
if (null === $current || 'layout/lightbox' === $current->getTemplate()) {
return null;
}
$children = $viewModel->getCurrent()->getChildren();
$children = $current->getChildren();
if (isset($children[0])) {
$template = $children[0]->getTemplate();
if (!strstr($template, '/home') && !strstr($template, 'facet-list')) {
......@@ -304,8 +305,16 @@ class Piwik extends \Zend\View\Helper\AbstractHelper
*/
protected function getRecordDriver()
{
$viewModel = $this->getView()->plugin('view_model');
$children = $viewModel->getCurrent()->getChildren();
$view = $this->getView();
$viewModel = $view->plugin('view_model');
$current = $viewModel->getCurrent();
if (null === $current) {
$driver = $view->vars('driver');
if (is_a($driver, 'VuFind\RecordDriver\AbstractBase')) {
return $driver;
}
}
$children = $current->getChildren();
if (isset($children[0])) {
$driver = $children[0]->getVariable('driver');
if (is_a($driver, 'VuFind\RecordDriver\AbstractBase')) {
......
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