MetaModels\DcGeneral\Events\Table\RenderSetting\Subscriber::modelToLabel PHP Метод

modelToLabel() публичный Метод

Draw the render setting.
public modelToLabel ( ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\ModelToLabelEvent $event ) : void
$event ContaoCommunityAlliance\DcGeneral\Contao\View\Contao2BackendView\Event\ModelToLabelEvent The event.
Результат void
    public function modelToLabel(ModelToLabelEvent $event)
    {
        if ($event->getEnvironment()->getDataDefinition()->getName() !== 'tl_metamodel_rendersetting') {
            return;
        }
        $model = $event->getModel();
        $attribute = $this->getMetaModel($model)->getAttributeById($model->getProperty('attr_id'));
        if ($attribute) {
            $type = $attribute->get('type');
            $image = $GLOBALS['METAMODELS']['attributes'][$type]['image'];
            if (!$image || !file_exists(TL_ROOT . '/' . $image)) {
                $image = 'system/modules/metamodels/assets/images/icons/fields.png';
            }
            $name = $attribute->getName();
            $colName = $attribute->getColName();
        } else {
            $translator = $event->getEnvironment()->getTranslator();
            $image = 'system/modules/metamodels/assets/images/icons/fields.png';
            $name = $translator->translate('error_unknown_id', 'error_unknown_attribute');
            $colName = $translator->translate('error_unknown_column', 'error_unknown_attribute');
            $type = $translator->translate('error_unknown_id', 'tl_metamodel_rendersettings', array($model->getProperty('attr_id')));
        }
        /** @var GenerateHtmlEvent $imageEvent */
        $imageEvent = $event->getEnvironment()->getEventDispatcher()->dispatch(ContaoEvents::IMAGE_GET_HTML, new GenerateHtmlEvent($image));
        $event->setLabel('<div class="field_heading cte_type %s"><strong>%s</strong> <em>[%s]</em></div>
                <div class="field_type block">
                    %s<strong>%s</strong>
                </div>')->setArgs(array($model->getProperty('enabled') ? 'published' : 'unpublished', $colName, $type, $imageEvent->getHtml(), $name));
    }