code: private function getConnection()
      {
          if ($this->connection) {
              return $this->connection;
          }
  
          $reflection = new \ReflectionProperty(\Contao\Database::class, 'resConnection');
          $reflection->setAccessible(true);
  
          return $this->connection = $reflection->getValue($this->getDatabase());
      }
docs: Obtain the doctrine connection.
  
  @return Connection
  
  @throws \ReflectionException Throws could not connect to database.