MetaModels\DcGeneral\Events\Table\FilterSetting\Subscriber::decodeAttributeIdValue PHP Method

decodeAttributeIdValue() public method

Translates an attribute id to a generated alias {@see getAttributeNames()}.
public decodeAttributeIdValue ( ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\DecodePropertyValueForWidgetEvent $event ) : void
$event ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\DecodePropertyValueForWidgetEvent The event.
return void
    public function decodeAttributeIdValue(DecodePropertyValueForWidgetEvent $event)
    {
        if ($event->getEnvironment()->getDataDefinition()->getName() !== 'tl_metamodel_filtersetting' || $event->getProperty() !== 'attr_id') {
            return;
        }
        $model = $event->getModel();
        $metaModel = $this->getMetaModel($model);
        $value = $event->getValue();
        if (!($metaModel && $value)) {
            return;
        }
        $attribute = $metaModel->getAttributeById($value);
        if ($attribute) {
            $event->setValue($metaModel->getTableName() . '_' . $attribute->getColName());
        }
    }