src/CoreBundle/Contao/Hooks/AbstractContentElementAndModuleCallback.php
protected function buildFilterParamsFor(\DC_Table $dataContainer, $elementName)
    {
        if (!$this->requestStack->getCurrentRequest()->query->get('act')) {
            return;
        }

        $filterId = $this->connection->createQueryBuilder()
            ->select('c.metamodel_filtering')
            ->from(static::$tableName, 'c')
            ->join('c', 'tl_metamodel', 'mm', 'mm.id=c.metamodel')
            ->where('c.id=:id')
            ->setParameter('id', $dataContainer->id)
            ->andWhere('c.type=:type')
            ->setParameter('type', $elementName)
            ->setMaxResults(1)
            ->execute()
            ->fetch(\PDO::FETCH_COLUMN);

        if (!$filterId) {
            unset($GLOBALS['TL_DCA'][static::$tableName]['fields']['metamodel_filterparams']);
            return;
        }

        $collection = $this->filterFactory->createCollection($filterId);
        $dca        = $collection->getParameterDCA();
        foreach ($dca as $fieldName => $subField) {
            $options = [];
            foreach ($subField['options'] as $key => $value) {
                $options[$this->loadCallback($key)] = $value;
            }

            $dca[$fieldName]['options']         = $options;
            $dca[$fieldName]['save_callback'][] = [static::class, 'saveCallback'];
            $dca[$fieldName]['load_callback'][] = [static::class, 'loadCallback'];
        }

        $GLOBALS['TL_DCA'][static::$tableName]['fields']['metamodel_filterparams']['eval']['subfields'] =
            $dca;
    }
protected function buildFilterParamsFor(\DC_Table $dataContainer, $elementName)
    {
        if (!$this->requestStack->getCurrentRequest()->query->get('act')) {
            return;
        }

        $filterId = $this->connection->createQueryBuilder()
            ->select('c.metamodel_filtering')
            ->from(static::$tableName, 'c')
            ->join('c', 'tl_metamodel', 'mm', 'mm.id=c.metamodel')
            ->where('c.id=:id')
            ->setParameter('id', $dataContainer->id)
            ->andWhere('c.type=:type')
            ->setParameter('type', $elementName)
            ->setMaxResults(1)
            ->execute()
            ->fetch(\PDO::FETCH_COLUMN);

        if (!$filterId) {
            unset($GLOBALS['TL_DCA'][static::$tableName]['fields']['metamodel_filterparams']);
            return;
        }

        $collection = $this->filterFactory->createCollection($filterId);
        $dca        = $collection->getParameterDCA();
        foreach ($dca as $fieldName => $subField) {
            $options = [];
            foreach ($subField['options'] as $key => $value) {
                $options[$this->loadCallback($key)] = $value;
            }

            $dca[$fieldName]['options']         = $options;
            $dca[$fieldName]['save_callback'][] = [static::class, 'saveCallback'];
            $dca[$fieldName]['load_callback'][] = [static::class, 'loadCallback'];
        }

        $GLOBALS['TL_DCA'][static::$tableName]['fields']['metamodel_filterparams']['eval']['subfields'] =
            $dca;
    }
Called from subclass.

@param \DC_Table $dataContainer The data container calling this method.
@param string    $elementName   The type name to search for.

@return void

@SuppressWarnings(PHPMD.Superglobals)
@SuppressWarnings(PHPMD.CamelCaseVariableName)