Skip to content

Commit

Permalink
Merge pull request #43 from asimlqt/master
Browse files Browse the repository at this point in the history
Reverted select tag processor back to previous implementation
  • Loading branch information
asimlqt authored Dec 18, 2017
2 parents 5271afb + d2f2a68 commit 28fe7fe
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
use Pimcore\Model\Document\Tag\Multiselect;
use Pimcore\Model\Document\Tag\Select;
use Pimcore\Model\Document\Tag\Input;
use Byng\Pimcore\Elasticsearch\Filter\FilterInterface;
use Pimcore\Model\Object\AbstractObject;

/**
* Select Element Processor
Expand All @@ -25,6 +27,11 @@
*/
final class SelectElementProcessor
{
/**
* @var FilterInterface
*/
protected $filter;

/**
* @var InputElementProcessor
*/
Expand All @@ -34,10 +41,12 @@ final class SelectElementProcessor
/**
* Constructor
*
* @param FilterInterface $filter
* @param InputElementProcessor $fallbackProcessor
*/
public function __construct(InputElementProcessor $fallbackProcessor)
public function __construct(FilterInterface $filter, InputElementProcessor $fallbackProcessor)
{
$this->filter = $filter;
$this->fallbackProcessor = $fallbackProcessor;
}

Expand All @@ -57,9 +66,22 @@ public function processElement(
) {
$elementData = trim($select->getData());

if (
is_numeric(($elementData = trim($elementData)))
&& ($object = AbstractObject::getById($elementData)) instanceof AbstractObject
) {
$rawElementData = $object->getKey();

$body[$key] = [
$elementData,
$this->filter->filter($rawElementData)
];

return ($body[$key . '-collated'] = $rawElementData);
}

$input = new Input();
$input->text = $elementData;

return $body[$key] = $this->fallbackProcessor->processElement($input);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function build(FilterInterface $filter = null)
return new PageProcessor(
$elementProcessor,
new DateElementProcessor(),
new SelectElementProcessor($inputProcessor),
new SelectElementProcessor($filter, $inputProcessor),
$inputProcessor
);
}
Expand Down

0 comments on commit 28fe7fe

Please sign in to comment.