public function getRepository($entityName)
    {
        if ($entityName instanceof Entity) {
            $entityName = $entityName->getType();
        }

        if (!isset($this->repositories[$entityName])) {
            $plural = $this->getCollectionName($entityName);
            $this->repositories[$entityName] = $this->repositoryFactory->createRepository(
                $entityName,
                $plural
            );
        }

        return $this->repositories[$entityName];
    }