<?php
namespace Modules\Orders\Galileo\Collector\Model;

class ConvertInputToFilters extends \ModulesAbstract\ImportedOrdersFileManager\Model\ConvertInputToFilters
{
	/**
	 * (non-PHPdoc)
	 * @see \ModulesAbstract\ImportedOrdersFileManager\Model\ConvertInputToFilters::convertInputFilterToObjectFilter()
	 */
	protected function convertInputFilterToObjectFilter($filterType, $filterMode, $input, $minCount, $maxCount, $negate)
	{
		// file parser
		if ($filterType == 'fileParser') {
			$filterFileParser = new \Modules\Orders\Galileo\Collector\Model\Filters\FileParser();
			$filterFileParser->setFilterMode($filterMode);
			$filterFileParser->setInput($input);
			$filterFileParser->setCountLimit($minCount, $maxCount);
			$filterFileParser->negateFilter($negate);
			$this->filters[] = $filterFileParser;
		}

		// structure parser
		if ($filterType == 'structureParser') {
			$filterStructureParser = new \Modules\Orders\Galileo\Collector\Model\Filters\StructureParser();
			$filterStructureParser->setFilterMode($filterMode);
			$filterStructureParser->setInput($input);
			$filterStructureParser->setCountLimit($minCount, $maxCount);
			$filterStructureParser->negateFilter($negate);
			$this->filters[] = $filterStructureParser;
		}

		if ($filterType == 'content') {
			$filterContent = new \Modules\Orders\Galileo\Collector\Model\Filters\Content();
			$filterContent->setFilterMode($filterMode);
			$input = sprintf("/(?P<extract>%s)/m", $input);
			$filterContent->setInput($input);
			$filterContent->setCountLimit($minCount, $maxCount);
			$filterContent->negateFilter($negate);
			$this->filters[] = $filterContent;

			$filterType = NULL;
		}

		parent::convertInputFilterToObjectFilter($filterType, $filterMode, $input, $minCount, $maxCount, $negate);
	}

	protected function populateFilterHelper($filterType)
	{
		parent::populateFilterHelper($filterType);

		// TODO exemple filtre
		if ($filterType == 'content') {
		}
	}
}
