Get rid of ServiceContainerTrait. Use dependency injection where possible.

This commit is contained in:
David Molineus
2015-02-02 08:44:17 +01:00
parent 64b0aa5389
commit f703b27a6b
6 changed files with 95 additions and 58 deletions

View File

@@ -13,11 +13,11 @@ namespace Netzmacht\Contao\Leaflet\Mapper\Vector;
use Netzmacht\Contao\Leaflet\Definition\Style;
use Netzmacht\Contao\Leaflet\Filter\Filter;
use Netzmacht\Contao\Leaflet\Frontend\ValueFilter;
use Netzmacht\Contao\Leaflet\Mapper\AbstractTypeMapper;
use Netzmacht\Contao\Leaflet\Mapper\DefinitionMapper;
use Netzmacht\Contao\Leaflet\Model\PopupModel;
use Netzmacht\Contao\Leaflet\Model\StyleModel;
use Netzmacht\Contao\Leaflet\ServiceContainerTrait;
use Netzmacht\LeafletPHP\Definition;
use Netzmacht\LeafletPHP\Definition\HasPopup;
use Netzmacht\LeafletPHP\Definition\UI\Popup;
@@ -30,8 +30,6 @@ use Netzmacht\LeafletPHP\Definition\Vector\Path;
*/
class AbstractVectorMapper extends AbstractTypeMapper
{
use ServiceContainerTrait;
/**
* Class of the model being build.
*
@@ -39,6 +37,25 @@ class AbstractVectorMapper extends AbstractTypeMapper
*/
protected static $modelClass = 'Netzmacht\Contao\Leaflet\Model\VectorModel';
/**
* Frontend filter.
*
* @var ValueFilter
*/
protected $valueFilter;
/**
* Construct.
*
* @param ValueFilter $valueFilter Frontend filter.
*/
public function __construct(ValueFilter $valueFilter)
{
parent::__construct();
$this->valueFilter = $valueFilter;
}
/**
* {@inheritdoc}
*/
@@ -84,10 +101,7 @@ class AbstractVectorMapper extends AbstractTypeMapper
) {
if ($definition instanceof HasPopup && $model->addPopup) {
$popup = null;
$content = $this
->getServiceContainer()
->getFrontendValueFilter()
->filter($model->popupContent);
$content = $this->valueFilter->filter($model->popupContent);
if ($model->popup) {
$popupModel = PopupModel::findActiveByPK($model->popup);