MetaModels\FrontendIntegration\FrontendFilter::generateElement PHP Method

generateElement() protected method

Render a module or content element.
protected generateElement ( string $table, string $content, string $replace, integer $elementId ) : string
$table string The name of the table.
$content string The html content in which to replace.
$replace string The string within the html to be replaced.
$elementId integer The id of the module/ce-element to be inserted for the replace string.
return string
    protected function generateElement($table, $content, $replace, $elementId)
    {
        $sql = sprintf('SELECT * FROM %s WHERE id=? AND type="metamodels_frontendclearall"', $table);
        /** @var IMetaModelsServiceContainer $serviceContainer */
        $serviceContainer = $GLOBALS['container']['metamodels-service-container'];
        $objDbResult = $serviceContainer->getDatabase()->prepare($sql)->execute($elementId);
        // Check if we have a ce element.
        if ($objDbResult->numRows == 0) {
            return str_replace($replace, '', $content);
        }
        // Get instance and call generate function.
        if ($table == 'tl_module') {
            $objElement = new ModuleFilterClearAll($objDbResult);
        } elseif ($table == 'tl_content') {
            $objElement = new ContentElementFilterClearAll($objDbResult);
        } else {
            return str_replace($replace, '', $content);
        }
        return str_replace($replace, $objElement->generateReal(), $content);
    }