This repository has been archived on 2025-02-26. You can view files and clone it, but cannot push or open issues or pull requests.
szurubooru/src/SearchServices/Parsers/SnapshotSearchParser.php
2014-10-18 18:48:29 +02:00

41 lines
1.4 KiB
PHP

<?php
namespace Szurubooru\SearchServices\Parsers;
class SnapshotSearchParser extends AbstractSearchParser
{
protected function createFilter()
{
return new \Szurubooru\SearchServices\Filters\SnapshotFilter;
}
protected function decorateFilterFromToken($filter, $token)
{
if (substr_count($token->getValue(), ',') !== 1)
throw new \BadMethodCallException('Not supported');
if ($token->isNegated())
throw new \BadMethodCallException('Not supported');
list ($type, $primaryKey) = explode(',', $token->getValue());
$requirement = new \Szurubooru\SearchServices\Requirements\Requirement();
$requirement->setType(\Szurubooru\SearchServices\Filters\SnapshotFilter::REQUIREMENT_PRIMARY_KEY);
$requirement->setValue($this->createRequirementValue($primaryKey));
$filter->addRequirement($requirement);
$requirement = new \Szurubooru\SearchServices\Requirements\Requirement();
$requirement->setType(\Szurubooru\SearchServices\Filters\SnapshotFilter::REQUIREMENT_TYPE);
$requirement->setValue($this->createRequirementValue(\Szurubooru\Helpers\EnumHelper::snapshotTypeFromString($type)));
$filter->addRequirement($requirement);
}
protected function decorateFilterFromNamedToken($filter, $namedToken)
{
throw new \BadMethodCallException('Not supported');
}
protected function getOrderColumn($token)
{
throw new \BadMethodCallException('Not supported');
}
}