first commit
This commit is contained in:
122
Classes/Domain/Search/ResultSet/Grouping/Group.php
Normal file
122
Classes/Domain/Search/ResultSet/Grouping/Group.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<?php
|
||||
namespace WapplerSystems\Meilisearch\Domain\Search\ResultSet\Grouping;
|
||||
|
||||
/***************************************************************
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2017 Timo Hund <timo.hund@dkd.de>
|
||||
* All rights reserved
|
||||
*
|
||||
* This script is part of the TYPO3 project. The TYPO3 project 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.
|
||||
*
|
||||
* The GNU General Public License can be found at
|
||||
* http://www.gnu.org/copyleft/gpl.html.
|
||||
*
|
||||
* This script 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.
|
||||
*
|
||||
* This copyright notice MUST APPEAR in all copies of the script!
|
||||
***************************************************************/
|
||||
|
||||
/**
|
||||
* A group is identified by a groupName and can contain multiple groupItems (that reference the search results).
|
||||
*
|
||||
* @author Frans Saris <frans@beech.it>
|
||||
* @author Timo Hund <timo.hund@dkd.de>
|
||||
*/
|
||||
class Group
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $groupName = '';
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $resultsPerPage = 10;
|
||||
|
||||
/**
|
||||
* @var GroupItemCollection
|
||||
*/
|
||||
protected $groupItems = null;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $groupConfiguration = [];
|
||||
|
||||
/**
|
||||
* Group constructor.
|
||||
* @param string $groupName
|
||||
* @param int $resultsPerPage
|
||||
*/
|
||||
public function __construct(string $groupName, int $resultsPerPage = 10)
|
||||
{
|
||||
$this->groupName = $groupName;
|
||||
$this->groupItems = new GroupItemCollection();
|
||||
$this->resultsPerPage = $resultsPerPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getGroupName(): string
|
||||
{
|
||||
return $this->groupName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $groupName
|
||||
*/
|
||||
public function setGroupName(string $groupName)
|
||||
{
|
||||
$this->groupName = $groupName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return GroupItemCollection
|
||||
*/
|
||||
public function getGroupItems(): GroupItemCollection
|
||||
{
|
||||
return $this->groupItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param GroupItemCollection $groupItems
|
||||
*/
|
||||
public function setGroupItems(GroupItemCollection $groupItems)
|
||||
{
|
||||
$this->groupItems = $groupItems;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param GroupItem $groupItem
|
||||
*/
|
||||
public function addGroupItem(GroupItem $groupItem)
|
||||
{
|
||||
$this->groupItems[] = $groupItem;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getResultsPerPage(): int
|
||||
{
|
||||
return $this->resultsPerPage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $resultsPerPage
|
||||
*/
|
||||
public function setResultsPerPage(int $resultsPerPage)
|
||||
{
|
||||
$this->resultsPerPage = $resultsPerPage;
|
||||
}
|
||||
}
|
88
Classes/Domain/Search/ResultSet/Grouping/GroupCollection.php
Normal file
88
Classes/Domain/Search/ResultSet/Grouping/GroupCollection.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?php
|
||||
|
||||
namespace WapplerSystems\Meilisearch\Domain\Search\ResultSet\Grouping;
|
||||
|
||||
/***************************************************************
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2017 Timo Hund <timo.hund@dkd.de>
|
||||
* All rights reserved
|
||||
*
|
||||
* This script is part of the TYPO3 project. The TYPO3 project 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.
|
||||
*
|
||||
* The GNU General Public License can be found at
|
||||
* http://www.gnu.org/copyleft/gpl.html.
|
||||
*
|
||||
* This script 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.
|
||||
*
|
||||
* This copyright notice MUST APPEAR in all copies of the script!
|
||||
***************************************************************/
|
||||
|
||||
use WapplerSystems\Meilisearch\System\Data\AbstractCollection;
|
||||
|
||||
/**
|
||||
* The Group contains the Group objects.
|
||||
*/
|
||||
class GroupCollection extends AbstractCollection {
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return Group|null
|
||||
*/
|
||||
public function getByName($name)
|
||||
{
|
||||
foreach ($this->data as $group) {
|
||||
/** @var $group Group */
|
||||
if ($group->getGroupName() === $name) {
|
||||
return $group;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return boolean
|
||||
*/
|
||||
public function getHasWithName($name): bool
|
||||
{
|
||||
foreach ($this->data as $group) {
|
||||
/** @var $group Group */
|
||||
if ($group->getGroupName() === $name) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getGroupNames(): array
|
||||
{
|
||||
$names = [];
|
||||
foreach ($this->data as $group) {
|
||||
/** @var $group Group */
|
||||
$names[] = $group->getGroupName();
|
||||
}
|
||||
|
||||
return $names;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Group $group
|
||||
*/
|
||||
public function add(Group $group)
|
||||
{
|
||||
$this->data[] = $group;
|
||||
}
|
||||
}
|
156
Classes/Domain/Search/ResultSet/Grouping/GroupItem.php
Normal file
156
Classes/Domain/Search/ResultSet/Grouping/GroupItem.php
Normal file
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
namespace WapplerSystems\Meilisearch\Domain\Search\ResultSet\Grouping;
|
||||
|
||||
/***************************************************************
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2017 Timo Hund <timo.schmidt@dkd.de>
|
||||
* All rights reserved
|
||||
*
|
||||
* This script is part of the TYPO3 project. The TYPO3 project 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.
|
||||
*
|
||||
* The GNU General Public License can be found at
|
||||
* http://www.gnu.org/copyleft/gpl.html.
|
||||
*
|
||||
* This script 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.
|
||||
*
|
||||
* This copyright notice MUST APPEAR in all copies of the script!
|
||||
***************************************************************/
|
||||
|
||||
use WapplerSystems\Meilisearch\Domain\Search\ResultSet\Result\SearchResult;
|
||||
use WapplerSystems\Meilisearch\Domain\Search\ResultSet\Result\SearchResultCollection;
|
||||
|
||||
/**
|
||||
* Class GroupItem
|
||||
*
|
||||
* @author Frans Saris <frans@beech.it>
|
||||
* @author Timo Hund <timo.hund@dkd.de>
|
||||
*/
|
||||
class GroupItem
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $groupValue = '';
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $allResultCount = 0;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $start = 0;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
protected $maximumScore = 0;
|
||||
|
||||
/**
|
||||
* @var SearchResultCollection
|
||||
*/
|
||||
protected $searchResults;
|
||||
|
||||
/**
|
||||
* @var Group
|
||||
*/
|
||||
protected $group;
|
||||
|
||||
/**
|
||||
* @param Group $group
|
||||
* @param string $groupValue
|
||||
* @param int $numFound
|
||||
* @param int $start
|
||||
* @param float $maxScore
|
||||
*/
|
||||
public function __construct(Group $group, $groupValue, $numFound, $start, $maxScore)
|
||||
{
|
||||
$this->group = $group;
|
||||
$this->groupValue = $groupValue;
|
||||
$this->allResultCount = $numFound;
|
||||
$this->start = $start;
|
||||
$this->maximumScore = $maxScore;
|
||||
$this->searchResults = new SearchResultCollection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get groupValue
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getGroupValue()
|
||||
{
|
||||
return $this->groupValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get numFound
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getAllResultCount()
|
||||
{
|
||||
return $this->allResultCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get start
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getStart()
|
||||
{
|
||||
return $this->start;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get maxScore
|
||||
*
|
||||
* @return float
|
||||
*/
|
||||
public function getMaximumScore()
|
||||
{
|
||||
return $this->maximumScore;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SearchResultCollection
|
||||
*/
|
||||
public function getSearchResults(): SearchResultCollection
|
||||
{
|
||||
return $this->searchResults;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SearchResultCollection $searchResults
|
||||
*/
|
||||
public function setSearchResults(SearchResultCollection $searchResults)
|
||||
{
|
||||
$this->searchResults = $searchResults;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SearchResult $searchResult
|
||||
*/
|
||||
public function addSearchResult(SearchResult $searchResult)
|
||||
{
|
||||
$this->searchResults[] = $searchResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Group
|
||||
*/
|
||||
public function getGroup(): Group
|
||||
{
|
||||
return $this->group;
|
||||
}
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace WapplerSystems\Meilisearch\Domain\Search\ResultSet\Grouping;
|
||||
|
||||
/***************************************************************
|
||||
* Copyright notice
|
||||
*
|
||||
* (c) 2017 Timo Hund <timo.hund@dkd.de>
|
||||
* All rights reserved
|
||||
*
|
||||
* This script is part of the TYPO3 project. The TYPO3 project 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.
|
||||
*
|
||||
* The GNU General Public License can be found at
|
||||
* http://www.gnu.org/copyleft/gpl.html.
|
||||
*
|
||||
* This script 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.
|
||||
*
|
||||
* This copyright notice MUST APPEAR in all copies of the script!
|
||||
***************************************************************/
|
||||
|
||||
use WapplerSystems\Meilisearch\System\Data\AbstractCollection;
|
||||
|
||||
/**
|
||||
* The GroupItemCollection contains the GroupItem objects.
|
||||
*/
|
||||
class GroupItemCollection extends AbstractCollection {}
|
Reference in New Issue
Block a user