src/CoreBundle/EventListener/DcGeneral/Table/MetaModel/ModelToLabelListener.php
public function handle(ModelToLabelEvent $event)
    {
        if (!$this->wantToHandle($event)) {
            return;
        }

        $model     = $event->getModel();
        $tableName = $model->getProperty('tableName');

        if (!($model && !empty($tableName) && $this->connection->getSchemaManager()->tablesExist([$tableName]))) {
            return;
        }

        // Keep the previous label.
        $label = vsprintf($event->getLabel(), $event->getArgs());
        $image = ((bool) $model->getProperty('translated')) ? 'locale.png' : 'locale_1.png';
        $count = $this->connection->createQueryBuilder()
            ->select('COUNT(*) AS itemCount')
            ->from($tableName)
            ->execute()
            ->fetchColumn();

        switch ($count) {
            case 0:
                $transId = 'tl_metamodel.itemFormatCount.0';
                break;
            case 1:
                $transId = 'tl_metamodel.itemFormatCount.1';
                break;
            default:
                $transId = 'tl_metamodel.itemFormatCount.2:';
        }

        $event
            ->setLabel('
    <span class="name">
      <img src="bundles/metamodelscore/images/icons/%1$s" /> %2$s
      <span style="color:#b3b3b3; padding-left:3px">(%3$s)</span>
      <span style="color:#b3b3b3; padding-left:3px">[%4$s]</span>
    </span>')
            ->setArgs([
                $image,
                $label,
                $tableName,
                $this->translator->trans($transId, [$count], 'contao_tl_metamodel')
            ]);
    }
public function handle(ModelToLabelEvent $event)
    {
        if (!$this->wantToHandle($event)) {
            return;
        }

        $model     = $event->getModel();
        $tableName = $model->getProperty('tableName');

        if (!($model && !empty($tableName) && $this->connection->getSchemaManager()->tablesExist([$tableName]))) {
            return;
        }

        // Keep the previous label.
        $label = vsprintf($event->getLabel(), $event->getArgs());
        $image = ((bool) $model->getProperty('translated')) ? 'locale.png' : 'locale_1.png';
        $count = $this->connection->createQueryBuilder()
            ->select('COUNT(*) AS itemCount')
            ->from($tableName)
            ->execute()
            ->fetchColumn();

        switch ($count) {
            case 0:
                $transId = 'tl_metamodel.itemFormatCount.0';
                break;
            case 1:
                $transId = 'tl_metamodel.itemFormatCount.1';
                break;
            default:
                $transId = 'tl_metamodel.itemFormatCount.2:';
        }

        $event
            ->setLabel('
    <span class="name">
      <img src="bundles/metamodelscore/images/icons/%1$s" /> %2$s
      <span style="color:#b3b3b3; padding-left:3px">(%3$s)</span>
      <span style="color:#b3b3b3; padding-left:3px">[%4$s]</span>
    </span>')
            ->setArgs([
                $image,
                $label,
                $tableName,
                $this->translator->trans($transId, [$count], 'contao_tl_metamodel')
            ]);
    }
Render the html for the input screen condition.

@param ModelToLabelEvent $event The event.

@return void