Skip to content
Snippets Groups Projects
Commit 9e1b7445 authored by David Maus's avatar David Maus
Browse files

Filter component state

parent 6fd14fa2
No related branches found
No related tags found
No related merge requests found
......@@ -93,6 +93,30 @@ class FacetCollection implements Countable, IteratorAggregate, ParameterProvider
return isset($this->facets[$name]);
}
/**
* Set the component state filter.
*
* @param StateFilter\StateFilterInterface $filter
* @return void
*/
public function setComponentStateFilter (StateFilter\StateFilterInterface $filter)
{
$this->filter = $filter;
}
/**
* Return the component state filter.
*
* @return StateFilter\StateFilterInterface
*/
public function getComponentStateFilter ()
{
if (!$this->filter) {
$this->setComponentStateFilter(new StateFilter\DefaultFilter());
}
return $this->filter;
}
/**
* {@inheritDoc}
*/
......@@ -106,6 +130,7 @@ class FacetCollection implements Countable, IteratorAggregate, ParameterProvider
*/
public function setComponentState (ParameterBag $state)
{
$state = $this->getComponentStateFilter()->filter($state);
foreach ($this->facets as $facet) {
$facet->setComponentState($state);
}
......
<?php
/**
* This file is part of HAB Solr.
*
* HAB Solr is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HAB Solr 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 HAB Solr. If not, see <http://www.gnu.org/licenses/>.
*
* @author David Maus <maus@hab.de>
* @copyright (c) 2017 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 or higher
*/
namespace HAB\Solr\Facet\StateFilter;
use Symfony\Component\HttpFoundation\ParameterBag;
/**
* Default implementation.
*
* The default implementation does not filter anything.
*
* @author David Maus <maus@hab.de>
* @copyright (c) 2017 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 or higher
*/
class DefaultStateFilter implements StateFilterInterface
{
/**
* {@inheritDoc}
*/
public function filter (ParameterBag $state)
{
return clone($state);
}
}
\ No newline at end of file
<?php
/**
* This file is part of HAB Solr.
*
* HAB Solr is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* HAB Solr 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 HAB Solr. If not, see <http://www.gnu.org/licenses/>.
*
* @author David Maus <maus@hab.de>
* @copyright (c) 2017 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 or higher
*/
namespace HAB\Solr\Facet\StateFilter;
use Symfony\Component\HttpFoundation\ParameterBag;
/**
* Interface of a component state filter.
*
* @author David Maus <maus@hab.de>
* @copyright (c) 2017 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.txt GNU General Public License v3 or higher
*/
interface StateFilterInterface
{
/**
* Return filtered state.
*
* @param ParameterBag $state
* @return ParameterBag
*/
public function filter (ParameterBag $state);
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment