Skip to content

Commit e325772

Browse files
committed
Merge branch 'develop-5'
2 parents 29885be + d402b42 commit e325772

File tree

12 files changed

+424
-12
lines changed

12 files changed

+424
-12
lines changed

module/FacetPrefix/config/module.config.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
'allow_override' => true,
77
'factories' => [
88
'FacetPrefix\Search\Params\PluginManager' => 'VuFind\ServiceManager\AbstractPluginManagerFactory',
9+
'FacetPrefix\Search\Results\PluginManager' => 'VuFind\ServiceManager\AbstractPluginManagerFactory',
910
],
1011
'aliases' => [
1112
'VuFind\Search\Params\PluginManager' => 'FacetPrefix\Search\Params\PluginManager',
13+
'VuFind\Search\Results\PluginManager' => 'FacetPrefix\Search\Results\PluginManager',
1214
],
1315
],
1416
];

module/FacetPrefix/src/FacetPrefix/Search/Params/ParamsFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function __invoke(ContainerInterface $container, $requestedName,
6060
) {
6161
// Replace trailing "Params" with "Options" to get the options service:
6262
$optionsService = preg_replace('/Params$/', 'Options', $requestedName);
63-
// Replace leading "FacetPrefix" with "VuFind" to get the VuFind options service:
63+
// Replace leading "SearchKeys" with "VuFind" to get the VuFind options service:
6464
$optionsService = preg_replace('/^FacetPrefix/', 'VuFind', $optionsService);
6565
$optionsObj = $container->get('VuFind\Search\Options\PluginManager')
6666
->get($optionsService);

module/FacetPrefix/src/FacetPrefix/Search/Params/PluginManager.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,22 @@ class PluginManager extends \VuFind\Search\Params\PluginManager
112112
public function __construct($configOrContainerInstance = null,
113113
array $v3config = []
114114
) {
115+
// These objects are not meant to be shared -- every time we retrieve one,
116+
// we are building a brand new object.
117+
$this->sharedByDefault = false;
118+
119+
$this->addAbstractFactory('VuFind\Search\Params\PluginFactory');
115120
parent::__construct($configOrContainerInstance, $v3config);
116121
}
122+
123+
/**
124+
* Return the name of the base class or interface that plug-ins must conform
125+
* to.
126+
*
127+
* @return string
128+
*/
129+
protected function getExpectedInterface()
130+
{
131+
return 'VuFind\Search\Base\Params';
132+
}
117133
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
/**
3+
* Params Extension for FacetPrefix Module
4+
*
5+
* PHP version 5
6+
*
7+
* Copyright (C) Staats- und Universitätsbibliothek 2017.
8+
*
9+
* This program is free software; you can redistribute it and/or modify
10+
* it under the terms of the GNU General Public License version 2,
11+
* as published by the Free Software Foundation.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program; if not, write to the Free Software
20+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21+
*
22+
* @category VuFind2
23+
* @package Search
24+
* @author Hajo Seng <hajo.seng@sub.uni-hamburg.de>
25+
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
26+
* @link https://github.com/subhh/beluga
27+
*/
28+
namespace FacetPrefix\Search\Primo;
29+
30+
use Libraries\Libraries;
31+
use VuFindSearch\ParamBag;
32+
33+
class Params extends \Libraries\Search\Primo\Params
34+
{
35+
36+
/**
37+
* Constructor
38+
*
39+
* @param \VuFind\Search\Base\Options $options Options to use
40+
* @param \VuFind\Config\PluginManager $configLoader Config loader
41+
*/
42+
public function __construct($options, \VuFind\Config\PluginManager $configLoader,
43+
\VuFind\Search\Memory $searchMemory
44+
) {
45+
parent::__construct($options, $configLoader);
46+
}
47+
48+
/**
49+
* Return current facet configurations
50+
*
51+
* @return array $facetSet
52+
*/
53+
public function getFacetSettings()
54+
{
55+
$facetSet = parent::getFacetSettings();
56+
57+
$facetConfig = $this->configLoader->get('facets');
58+
if (isset($facetConfig->FacetPrefix)) {
59+
foreach ($facetConfig->FacetPrefix as $facet => $prefix) {
60+
$facetSet["f.{$facet}.facet.prefix"] = $prefix;
61+
}
62+
}
63+
64+
return $facetSet;
65+
}
66+
}
67+
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
<?php
2+
/**
3+
* Search results plugin manager
4+
*
5+
* PHP version 7
6+
*
7+
* Copyright (C) Villanova University 2010.
8+
*
9+
* This program is free software; you can redistribute it and/or modify
10+
* it under the terms of the GNU General Public License version 2,
11+
* as published by the Free Software Foundation.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program; if not, write to the Free Software
20+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21+
*
22+
* @category VuFind
23+
* @package Search
24+
* @author Demian Katz <demian.katz@villanova.edu>
25+
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
26+
* @link https://vufind.org/wiki/development:plugins:record_drivers Wiki
27+
*/
28+
namespace FacetPrefix\Search\Results;
29+
30+
/**
31+
* Search results plugin manager
32+
*
33+
* @category VuFind
34+
* @package Search
35+
* @author Demian Katz <demian.katz@villanova.edu>
36+
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
37+
* @link https://vufind.org/wiki/development:plugins:record_drivers Wiki
38+
*/
39+
class PluginManager extends \Libraries\Search\Results\PluginManager
40+
{
41+
/**
42+
* Default plugin aliases.
43+
*
44+
* @var array
45+
*/
46+
protected $aliases = [
47+
'browzine' => 'VuFind\Search\BrowZine\Results',
48+
'combined' => 'VuFind\Search\Combined\Results',
49+
'eds' => 'VuFind\Search\EDS\Results',
50+
'eit' => 'VuFind\Search\EIT\Results',
51+
'emptyset' => 'VuFind\Search\EmptySet\Results',
52+
'favorites' => 'VuFind\Search\Favorites\Results',
53+
'libguides' => 'VuFind\Search\LibGuides\Results',
54+
'mixedlist' => 'VuFind\Search\MixedList\Results',
55+
'pazpar2' => 'VuFind\Search\Pazpar2\Results',
56+
'primo' => 'VuFind\Search\Primo\Results',
57+
'search2' => 'VuFind\Search\Search2\Results',
58+
'solr' => 'VuFind\Search\Solr\Results',
59+
'solrauth' => 'VuFind\Search\SolrAuth\Results',
60+
'solrauthor' => 'VuFind\Search\SolrAuthor\Results',
61+
'solrauthorfacets' => 'VuFind\Search\SolrAuthorFacets\Results',
62+
'solrcollection' => 'VuFind\Search\SolrCollection\Results',
63+
'solrreserves' => 'VuFind\Search\SolrReserves\Results',
64+
'solrweb' => 'VuFind\Search\SolrWeb\Results',
65+
'summon' => 'VuFind\Search\Summon\Results',
66+
'tags' => 'VuFind\Search\Tags\Results',
67+
'worldcat' => 'VuFind\Search\WorldCat\Results',
68+
];
69+
70+
/**
71+
* Default plugin factories.
72+
*
73+
* @var array
74+
*/
75+
protected $factories = [
76+
'VuFind\Search\BrowZine\Results' => 'VuFind\Search\Results\ResultsFactory',
77+
'VuFind\Search\Combined\Results' => 'VuFind\Search\Results\ResultsFactory',
78+
'VuFind\Search\EDS\Results' => 'VuFind\Search\Results\ResultsFactory',
79+
'VuFind\Search\EIT\Results' => 'VuFind\Search\Results\ResultsFactory',
80+
'VuFind\Search\EmptySet\Results' => 'VuFind\Search\Results\ResultsFactory',
81+
'VuFind\Search\Favorites\Results' =>
82+
'VuFind\Search\Favorites\ResultsFactory',
83+
'VuFind\Search\LibGuides\Results' => 'VuFind\Search\Results\ResultsFactory',
84+
'VuFind\Search\MixedList\Results' => 'VuFind\Search\Results\ResultsFactory',
85+
'VuFind\Search\Pazpar2\Results' => 'VuFind\Search\Results\ResultsFactory',
86+
'VuFind\Search\Primo\Results' => 'VuFind\Search\Results\ResultsFactory',
87+
'VuFind\Search\Search2\Results' => 'FacetPrefix\Search\Search2\ResultsFactory',
88+
'VuFind\Search\Solr\Results' => 'FacetPrefix\Search\Solr\ResultsFactory',
89+
'VuFind\Search\SolrAuth\Results' => 'VuFind\Search\Results\ResultsFactory',
90+
'VuFind\Search\SolrAuthor\Results' => 'VuFind\Search\Results\ResultsFactory',
91+
'VuFind\Search\SolrAuthorFacets\Results' =>
92+
'VuFind\Search\Results\ResultsFactory',
93+
'VuFind\Search\SolrCollection\Results' =>
94+
'VuFind\Search\Results\ResultsFactory',
95+
'VuFind\Search\SolrReserves\Results' =>
96+
'VuFind\Search\Results\ResultsFactory',
97+
'VuFind\Search\SolrWeb\Results' => 'VuFind\Search\Results\ResultsFactory',
98+
'VuFind\Search\Summon\Results' => 'VuFind\Search\Results\ResultsFactory',
99+
'VuFind\Search\Tags\Results' => 'VuFind\Search\Tags\ResultsFactory',
100+
'VuFind\Search\WorldCat\Results' => 'VuFind\Search\Results\ResultsFactory',
101+
];
102+
103+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
/**
3+
* Generic factory for search results objects.
4+
*
5+
* PHP version 7
6+
*
7+
* Copyright (C) Villanova University 2018.
8+
*
9+
* This program is free software; you can redistribute it and/or modify
10+
* it under the terms of the GNU General Public License version 2,
11+
* as published by the Free Software Foundation.
12+
*
13+
* This program is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with this program; if not, write to the Free Software
20+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21+
*
22+
* @category VuFind
23+
* @package Search
24+
* @author Demian Katz <demian.katz@villanova.edu>
25+
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
26+
* @link https://vufind.org/wiki/development Wiki
27+
*/
28+
namespace FacetPrefix\Search\Results;
29+
30+
use Interop\Container\ContainerInterface;
31+
use Zend\ServiceManager\Factory\FactoryInterface;
32+
33+
/**
34+
* Generic factory for search results objects.
35+
*
36+
* @category VuFind
37+
* @package Search
38+
* @author Demian Katz <demian.katz@villanova.edu>
39+
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
40+
* @link https://vufind.org/wiki/development Wiki
41+
*/
42+
class ResultsFactory implements FactoryInterface
43+
{
44+
/**
45+
* Create an object
46+
*
47+
* @param ContainerInterface $container Service manager
48+
* @param string $requestedName Service being created
49+
* @param null|array $options Extra options (optional)
50+
*
51+
* @return object
52+
*
53+
* @throws ServiceNotFoundException if unable to resolve the service.
54+
* @throws ServiceNotCreatedException if an exception is raised when
55+
* creating a service.
56+
* @throws ContainerException if any other error occurs
57+
*/
58+
public function __invoke(ContainerInterface $container, $requestedName,
59+
array $options = null
60+
) {
61+
// Replace trailing "Results" with "Params" to get the params service:
62+
$paramsService = preg_replace('/Results$/', 'Params', $requestedName);
63+
$paramsService = preg_replace('/^VuFind/', 'FacetPrefix', $paramsService);
64+
$params = $container->get('FacetPrefix\Search\Params\PluginManager')
65+
->get($paramsService);
66+
$searchService = $container->get('VuFindSearch\Service');
67+
$recordLoader = $container->get('VuFind\Record\Loader');
68+
return new $requestedName(
69+
$params, $searchService, $recordLoader, ...($options ?: [])
70+
);
71+
}
72+
}

module/FacetPrefix/src/FacetPrefix/Search/Search2/Params.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,12 @@
2727
*/
2828
namespace FacetPrefix\Search\Search2;
2929

30+
use Libraries\Libraries;
3031
use VuFindSearch\ParamBag;
3132
use VuFind\Search\Solr\HierarchicalFacetHelper;
32-
use VuFind\Search\Search2\Params as BaseParams;
33+
use SearchKeys\Search\SearchKeysHelper;
3334

34-
class Params extends BaseParams
35+
class Params extends \Libraries\Search\Search2\Params
3536
{
3637
/**
3738
* Constructor
@@ -40,9 +41,11 @@ class Params extends BaseParams
4041
* @param \VuFind\Config\PluginManager $configLoader Config loader
4142
*/
4243
public function __construct($options, \VuFind\Config\PluginManager $configLoader,
43-
HierarchicalFacetHelper $facetHelper = null
44+
HierarchicalFacetHelper $facetHelper = null,
45+
SearchKeysHelper $searchKeysHelper,
46+
\VuFind\Search\Memory $searchMemory
4447
) {
45-
parent::__construct($options, $configLoader, $facetHelper);
48+
parent::__construct($options, $configLoader, $facetHelper, $searchKeysHelper, $searchMemory);
4649
}
4750

4851
/**
@@ -60,11 +63,13 @@ public function getFacetSettings()
6063
$facetSet["f.{$facet}.facet.prefix"] = $prefix;
6164
}
6265
}
63-
if (isset($facetConfig->FacetMatches)) {
66+
67+
if (isset($facetConfig->FacetMatches)) {
6468
foreach ($facetConfig->FacetMatches as $facet => $matches) {
6569
$facetSet["f.{$facet}.facet.matches"] = $matches;
6670
}
6771
}
72+
6873
return $facetSet;
6974
}
7075
}

module/FacetPrefix/src/FacetPrefix/Search/Search2/ParamsFactory.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ public function __invoke(ContainerInterface $container, $requestedName,
6161
throw new \Exception('Unexpected options sent to factory.');
6262
}
6363
$facetHelper = $container->get('VuFind\Search\Solr\HierarchicalFacetHelper');
64-
return parent::__invoke($container, $requestedName, [$facetHelper]);
64+
$searchKeysHelper = $container->get('SearchKeys\Search\SearchKeysHelper');
65+
$searchMemory = $container->get('VuFind\Search\Memory');
66+
return parent::__invoke($container, $requestedName, [$facetHelper, $searchKeysHelper, $searchMemory]);
6567
}
6668
}

0 commit comments

Comments
 (0)