MetaModels\DcGeneral\Events\Table\InputScreenCondition\Subscriber::handleModelToLabel PHP Method

handleModelToLabel() public method

Render the html for the input screen condition.
public handleModelToLabel ( ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\ModelToLabelEvent $event ) : void
$event ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\ModelToLabelEvent The event.
return void
    public function handleModelToLabel(ModelToLabelEvent $event)
    {
        if ($event->getEnvironment()->getDataDefinition()->getName() !== 'tl_metamodel_dcasetting_condition') {
            return;
        }
        $environment = $event->getEnvironment();
        $translator = $environment->getTranslator();
        $model = $event->getModel();
        $metaModels = $this->getMetaModel($environment);
        $attribute = $metaModels->getAttributeById($model->getProperty('attr_id'));
        $type = $model->getProperty('type');
        $parameterValue = is_array($model->getProperty('value')) ? implode(', ', $model->getProperty('value')) : $model->getProperty('value');
        $name = $translator->translate('conditionnames.' . $type, 'tl_metamodel_dcasetting_condition');
        $image = $GLOBALS['METAMODELS']['attributes'][$type]['image'];
        if (!$image || !file_exists(TL_ROOT . '/' . $image)) {
            $image = 'system/modules/metamodels/assets/images/icons/filter_default.png';
        }
        /** @var GenerateHtmlEvent $imageEvent */
        $imageEvent = $event->getEnvironment()->getEventDispatcher()->dispatch(ContaoEvents::IMAGE_GET_HTML, new GenerateHtmlEvent($image));
        $event->setLabel($this->getLabelText($translator, $type))->setArgs(array($imageEvent->getHtml(), $name, $attribute ? $attribute->getName() : '', $parameterValue));
    }