src/Filter/Rules/SimpleQuery.php
private function sanitizeConnection($connection)
    {
        if ($connection instanceof Connection) {
            return $connection;
        }

        // BC layer - we used to accept a Contao database instance here.
        if ($connection instanceof Database) {
            // @codingStandardsIgnoreStart
            @trigger_error(
                '"' . __METHOD__ . '" now accepts doctrine instances - ' .
                'passing Contao database instances is deprecated.',
                E_USER_DEPRECATED
            );
            // @codingStandardsIgnoreEnd
            $reflection = new \ReflectionProperty(Database::class, 'resConnection');
            $reflection->setAccessible(true);
            return $reflection->getValue($connection);
        }
        if (null === $connection) {
            // @codingStandardsIgnoreStart
            @trigger_error(
                'You should pass a doctrine database connection to "' . __METHOD__ . '".',
                E_USER_DEPRECATED
            );
            // @codingStandardsIgnoreEnd
            $connection = System::getContainer()->get('database_connection');
        }

        if (!($connection instanceof Connection)) {
            throw new \RuntimeException('Could not obtain doctrine connection.');
        }

        return $connection;
    }
private function sanitizeConnection($connection)
    {
        if ($connection instanceof Connection) {
            return $connection;
        }

        // BC layer - we used to accept a Contao database instance here.
        if ($connection instanceof Database) {
            // @codingStandardsIgnoreStart
            @trigger_error(
                '"' . __METHOD__ . '" now accepts doctrine instances - ' .
                'passing Contao database instances is deprecated.',
                E_USER_DEPRECATED
            );
            // @codingStandardsIgnoreEnd
            $reflection = new \ReflectionProperty(Database::class, 'resConnection');
            $reflection->setAccessible(true);
            return $reflection->getValue($connection);
        }
        if (null === $connection) {
            // @codingStandardsIgnoreStart
            @trigger_error(
                'You should pass a doctrine database connection to "' . __METHOD__ . '".',
                E_USER_DEPRECATED
            );
            // @codingStandardsIgnoreEnd
            $connection = System::getContainer()->get('database_connection');
        }

        if (!($connection instanceof Connection)) {
            throw new \RuntimeException('Could not obtain doctrine connection.');
        }

        return $connection;
    }
Sanitize the connection value

@param Connection|\Contao\Database $connection The connection value.

@return Connection

@throws \RuntimeException Throws could not obtain doctrine connection.

@deprecated To be removed in 3.0 - you should ALWAYS pass the proper connection.