public function getRepositoryForEntity(string $entityName, string $connectionName = null): AbstractRepository
    {
        /** @var AbstractRepository $repository */
        $repository = $this->loadFactorableInstance($entityName);

        if (is_string($connectionName)) {
            $entityManager = $this->getContainer()->get('doctrine')->getManager($connectionName);
            $repository->setEntityManager($entityManager);
        }

        $this->onFactorableLoaded($repository);

        return $repository;
    }