protected function newRepository(ResourceConfiguration $config)
    {
        if ($this->database instanceof EntityManager) {
            return $this->newDoctrineRepository($this->database, $config->getEntityClass(), $config->getParent());
        } elseif ($this->database instanceof PDO) {
            return $this->newPdoRepository($this->database, $config->getResource(), $config->getParent());
        }

        throw new \Exception("Couldn't determine database connection type.");
    }