Skip to content

Commit

Permalink
Merge branch 'develop-5'
Browse files Browse the repository at this point in the history
  • Loading branch information
jschultze committed Sep 11, 2020
2 parents 29885be + d402b42 commit e325772
Show file tree
Hide file tree
Showing 12 changed files with 424 additions and 12 deletions.
2 changes: 2 additions & 0 deletions module/FacetPrefix/config/module.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
'allow_override' => true,
'factories' => [
'FacetPrefix\Search\Params\PluginManager' => 'VuFind\ServiceManager\AbstractPluginManagerFactory',
'FacetPrefix\Search\Results\PluginManager' => 'VuFind\ServiceManager\AbstractPluginManagerFactory',
],
'aliases' => [
'VuFind\Search\Params\PluginManager' => 'FacetPrefix\Search\Params\PluginManager',
'VuFind\Search\Results\PluginManager' => 'FacetPrefix\Search\Results\PluginManager',
],
],
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function __invoke(ContainerInterface $container, $requestedName,
) {
// Replace trailing "Params" with "Options" to get the options service:
$optionsService = preg_replace('/Params$/', 'Options', $requestedName);
// Replace leading "FacetPrefix" with "VuFind" to get the VuFind options service:
// Replace leading "SearchKeys" with "VuFind" to get the VuFind options service:
$optionsService = preg_replace('/^FacetPrefix/', 'VuFind', $optionsService);
$optionsObj = $container->get('VuFind\Search\Options\PluginManager')
->get($optionsService);
Expand Down
16 changes: 16 additions & 0 deletions module/FacetPrefix/src/FacetPrefix/Search/Params/PluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,22 @@ class PluginManager extends \VuFind\Search\Params\PluginManager
public function __construct($configOrContainerInstance = null,
array $v3config = []
) {
// These objects are not meant to be shared -- every time we retrieve one,
// we are building a brand new object.
$this->sharedByDefault = false;

$this->addAbstractFactory('VuFind\Search\Params\PluginFactory');
parent::__construct($configOrContainerInstance, $v3config);
}

/**
* Return the name of the base class or interface that plug-ins must conform
* to.
*
* @return string
*/
protected function getExpectedInterface()
{
return 'VuFind\Search\Base\Params';
}
}
67 changes: 67 additions & 0 deletions module/FacetPrefix/src/FacetPrefix/Search/Primo/Params.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php
/**
* Params Extension for FacetPrefix Module
*
* PHP version 5
*
* Copyright (C) Staats- und Universitätsbibliothek 2017.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* @category VuFind2
* @package Search
* @author Hajo Seng <[email protected]>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://github.com/subhh/beluga
*/
namespace FacetPrefix\Search\Primo;

use Libraries\Libraries;
use VuFindSearch\ParamBag;

class Params extends \Libraries\Search\Primo\Params
{

/**
* Constructor
*
* @param \VuFind\Search\Base\Options $options Options to use
* @param \VuFind\Config\PluginManager $configLoader Config loader
*/
public function __construct($options, \VuFind\Config\PluginManager $configLoader,
\VuFind\Search\Memory $searchMemory
) {
parent::__construct($options, $configLoader);
}

/**
* Return current facet configurations
*
* @return array $facetSet
*/
public function getFacetSettings()
{
$facetSet = parent::getFacetSettings();

$facetConfig = $this->configLoader->get('facets');
if (isset($facetConfig->FacetPrefix)) {
foreach ($facetConfig->FacetPrefix as $facet => $prefix) {
$facetSet["f.{$facet}.facet.prefix"] = $prefix;
}
}

return $facetSet;
}
}

103 changes: 103 additions & 0 deletions module/FacetPrefix/src/FacetPrefix/Search/Results/PluginManager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?php
/**
* Search results plugin manager
*
* PHP version 7
*
* Copyright (C) Villanova University 2010.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category VuFind
* @package Search
* @author Demian Katz <[email protected]>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development:plugins:record_drivers Wiki
*/
namespace FacetPrefix\Search\Results;

/**
* Search results plugin manager
*
* @category VuFind
* @package Search
* @author Demian Katz <[email protected]>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development:plugins:record_drivers Wiki
*/
class PluginManager extends \Libraries\Search\Results\PluginManager
{
/**
* Default plugin aliases.
*
* @var array
*/
protected $aliases = [
'browzine' => 'VuFind\Search\BrowZine\Results',
'combined' => 'VuFind\Search\Combined\Results',
'eds' => 'VuFind\Search\EDS\Results',
'eit' => 'VuFind\Search\EIT\Results',
'emptyset' => 'VuFind\Search\EmptySet\Results',
'favorites' => 'VuFind\Search\Favorites\Results',
'libguides' => 'VuFind\Search\LibGuides\Results',
'mixedlist' => 'VuFind\Search\MixedList\Results',
'pazpar2' => 'VuFind\Search\Pazpar2\Results',
'primo' => 'VuFind\Search\Primo\Results',
'search2' => 'VuFind\Search\Search2\Results',
'solr' => 'VuFind\Search\Solr\Results',
'solrauth' => 'VuFind\Search\SolrAuth\Results',
'solrauthor' => 'VuFind\Search\SolrAuthor\Results',
'solrauthorfacets' => 'VuFind\Search\SolrAuthorFacets\Results',
'solrcollection' => 'VuFind\Search\SolrCollection\Results',
'solrreserves' => 'VuFind\Search\SolrReserves\Results',
'solrweb' => 'VuFind\Search\SolrWeb\Results',
'summon' => 'VuFind\Search\Summon\Results',
'tags' => 'VuFind\Search\Tags\Results',
'worldcat' => 'VuFind\Search\WorldCat\Results',
];

/**
* Default plugin factories.
*
* @var array
*/
protected $factories = [
'VuFind\Search\BrowZine\Results' => 'VuFind\Search\Results\ResultsFactory',
'VuFind\Search\Combined\Results' => 'VuFind\Search\Results\ResultsFactory',
'VuFind\Search\EDS\Results' => 'VuFind\Search\Results\ResultsFactory',
'VuFind\Search\EIT\Results' => 'VuFind\Search\Results\ResultsFactory',
'VuFind\Search\EmptySet\Results' => 'VuFind\Search\Results\ResultsFactory',
'VuFind\Search\Favorites\Results' =>
'VuFind\Search\Favorites\ResultsFactory',
'VuFind\Search\LibGuides\Results' => 'VuFind\Search\Results\ResultsFactory',
'VuFind\Search\MixedList\Results' => 'VuFind\Search\Results\ResultsFactory',
'VuFind\Search\Pazpar2\Results' => 'VuFind\Search\Results\ResultsFactory',
'VuFind\Search\Primo\Results' => 'VuFind\Search\Results\ResultsFactory',
'VuFind\Search\Search2\Results' => 'FacetPrefix\Search\Search2\ResultsFactory',
'VuFind\Search\Solr\Results' => 'FacetPrefix\Search\Solr\ResultsFactory',
'VuFind\Search\SolrAuth\Results' => 'VuFind\Search\Results\ResultsFactory',
'VuFind\Search\SolrAuthor\Results' => 'VuFind\Search\Results\ResultsFactory',
'VuFind\Search\SolrAuthorFacets\Results' =>
'VuFind\Search\Results\ResultsFactory',
'VuFind\Search\SolrCollection\Results' =>
'VuFind\Search\Results\ResultsFactory',
'VuFind\Search\SolrReserves\Results' =>
'VuFind\Search\Results\ResultsFactory',
'VuFind\Search\SolrWeb\Results' => 'VuFind\Search\Results\ResultsFactory',
'VuFind\Search\Summon\Results' => 'VuFind\Search\Results\ResultsFactory',
'VuFind\Search\Tags\Results' => 'VuFind\Search\Tags\ResultsFactory',
'VuFind\Search\WorldCat\Results' => 'VuFind\Search\Results\ResultsFactory',
];

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?php
/**
* Generic factory for search results objects.
*
* PHP version 7
*
* Copyright (C) Villanova University 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,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* @category VuFind
* @package Search
* @author Demian Katz <[email protected]>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development Wiki
*/
namespace FacetPrefix\Search\Results;

use Interop\Container\ContainerInterface;
use Zend\ServiceManager\Factory\FactoryInterface;

/**
* Generic factory for search results objects.
*
* @category VuFind
* @package Search
* @author Demian Katz <[email protected]>
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
* @link https://vufind.org/wiki/development Wiki
*/
class ResultsFactory implements FactoryInterface
{
/**
* Create an object
*
* @param ContainerInterface $container Service manager
* @param string $requestedName Service being created
* @param null|array $options Extra options (optional)
*
* @return object
*
* @throws ServiceNotFoundException if unable to resolve the service.
* @throws ServiceNotCreatedException if an exception is raised when
* creating a service.
* @throws ContainerException if any other error occurs
*/
public function __invoke(ContainerInterface $container, $requestedName,
array $options = null
) {
// Replace trailing "Results" with "Params" to get the params service:
$paramsService = preg_replace('/Results$/', 'Params', $requestedName);
$paramsService = preg_replace('/^VuFind/', 'FacetPrefix', $paramsService);
$params = $container->get('FacetPrefix\Search\Params\PluginManager')
->get($paramsService);
$searchService = $container->get('VuFindSearch\Service');
$recordLoader = $container->get('VuFind\Record\Loader');
return new $requestedName(
$params, $searchService, $recordLoader, ...($options ?: [])
);
}
}
15 changes: 10 additions & 5 deletions module/FacetPrefix/src/FacetPrefix/Search/Search2/Params.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@
*/
namespace FacetPrefix\Search\Search2;

use Libraries\Libraries;
use VuFindSearch\ParamBag;
use VuFind\Search\Solr\HierarchicalFacetHelper;
use VuFind\Search\Search2\Params as BaseParams;
use SearchKeys\Search\SearchKeysHelper;

class Params extends BaseParams
class Params extends \Libraries\Search\Search2\Params
{
/**
* Constructor
Expand All @@ -40,9 +41,11 @@ class Params extends BaseParams
* @param \VuFind\Config\PluginManager $configLoader Config loader
*/
public function __construct($options, \VuFind\Config\PluginManager $configLoader,
HierarchicalFacetHelper $facetHelper = null
HierarchicalFacetHelper $facetHelper = null,
SearchKeysHelper $searchKeysHelper,
\VuFind\Search\Memory $searchMemory
) {
parent::__construct($options, $configLoader, $facetHelper);
parent::__construct($options, $configLoader, $facetHelper, $searchKeysHelper, $searchMemory);
}

/**
Expand All @@ -60,11 +63,13 @@ public function getFacetSettings()
$facetSet["f.{$facet}.facet.prefix"] = $prefix;
}
}
if (isset($facetConfig->FacetMatches)) {

if (isset($facetConfig->FacetMatches)) {
foreach ($facetConfig->FacetMatches as $facet => $matches) {
$facetSet["f.{$facet}.facet.matches"] = $matches;
}
}

return $facetSet;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ public function __invoke(ContainerInterface $container, $requestedName,
throw new \Exception('Unexpected options sent to factory.');
}
$facetHelper = $container->get('VuFind\Search\Solr\HierarchicalFacetHelper');
return parent::__invoke($container, $requestedName, [$facetHelper]);
$searchKeysHelper = $container->get('SearchKeys\Search\SearchKeysHelper');
$searchMemory = $container->get('VuFind\Search\Memory');
return parent::__invoke($container, $requestedName, [$facetHelper, $searchKeysHelper, $searchMemory]);
}
}
Loading

0 comments on commit e325772

Please sign in to comment.