protected function generateElement($table, $content, $replace, $elementId)
    {
        $sql = sprintf('SELECT * FROM %s WHERE id=? AND type="metamodels_frontendclearall"', $table);

        $statement = $this->connection->prepare($sql);
        $statement->bindValue(1, $elementId);
        $statement->execute();

        $objDbResult = $statement->fetch(\PDO::FETCH_OBJ);

        // Check if we have a existing module or ce element.
        if ($objDbResult === false) {
            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);
    }