Skip to content
Snippets Groups Projects
Commit 2db1dd97 authored by Demian Katz's avatar Demian Katz
Browse files

DevTools improvements

- Added router configuration
- Added home page
- Refactored deminifyAction for readability
parent 93113b80
No related merge requests found
...@@ -7,6 +7,40 @@ $config = [ ...@@ -7,6 +7,40 @@ $config = [
'devtools' => 'VuFindDevTools\Controller\DevtoolsController', 'devtools' => 'VuFindDevTools\Controller\DevtoolsController',
], ],
], ],
'router' => [
'routes' => [
'devtools-deminify' => [
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => [
'route' => '/devtools/deminify',
'defaults' => [
'controller' => 'DevTools',
'action' => 'Deminify',
]
]
],
'devtools-home' => [
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => [
'route' => '/devtools/home',
'defaults' => [
'controller' => 'DevTools',
'action' => 'Home',
]
]
],
'devtools-language' => [
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => [
'route' => '/devtools/language',
'defaults' => [
'controller' => 'DevTools',
'action' => 'Language',
]
]
],
],
],
]; ];
return $config; return $config;
...@@ -42,6 +42,27 @@ use VuFindDevTools\LanguageHelper; ...@@ -42,6 +42,27 @@ use VuFindDevTools\LanguageHelper;
*/ */
class DevtoolsController extends \VuFind\Controller\AbstractBase class DevtoolsController extends \VuFind\Controller\AbstractBase
{ {
/**
* Fetch the query builder for the specified search backend. Return null if
* unavailable.
*
* @param string $id Backend ID
*
* @return object
*/
protected function getQueryBuilder($id)
{
try {
$backend = $this->getServiceLocator()
->get('VuFind\Search\BackendManager')
->get($id);
} catch (\Exception $e) {
return null;
}
return is_callable([$backend, 'getQueryBuilder'])
? $backend->getQueryBuilder() : null;
}
/** /**
* Deminify action * Deminify action
* *
...@@ -66,21 +87,23 @@ class DevtoolsController extends \VuFind\Controller\AbstractBase ...@@ -66,21 +87,23 @@ class DevtoolsController extends \VuFind\Controller\AbstractBase
$view->backendParams = $params->getBackendParameters() $view->backendParams = $params->getBackendParameters()
->getArrayCopy(); ->getArrayCopy();
} }
try { if ($builder = $this->getQueryBuilder($params->getSearchClassId())) {
$backend = $this->getServiceLocator()
->get('VuFind\Search\BackendManager')
->get($params->getSearchClassId());
} catch (\Exception $e) {
$backend = false;
}
if ($backend && is_callable([$backend, 'getQueryBuilder'])) {
$builder = $backend->getQueryBuilder();
$view->queryParams = $builder->build($view->query)->getArrayCopy(); $view->queryParams = $builder->build($view->query)->getArrayCopy();
} }
} }
return $view; return $view;
} }
/**
* Home action
*
* @return \Zend\View\Model\ViewModel
*/
public function homeAction()
{
return $this->createViewModel();
}
/** /**
* Language action * Language action
* *
......
<?
$this->headTitle('Development Tools');
?>
<h2>Development Tools</h2>
<ul>
<li><a href="<?=$this->url('devtools-deminify')?>">Deminifier</a> - Examine minified search data copied from the search database table.</li>
<li><a href="<?=$this->url('devtools-language')?>">Language Details</a> - Summarize status of translations in language files.</li>
</ul>
\ No newline at end of file
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