public function registerRepository(ManagedRepositoryInterface $repository) {
		$name = $repository->getName();
		if($this->hasRepository($name)) {
			throw new \LogicException(sprintf('Repository %s is already registered.', $name));
		}

		$event = new ManagedRepositoryEvent($repository);
		$this->eventDispatcher->dispatch(ManagedRepositoryEvent::REGISTER, $event);
		$repository = $event->getRepository();

		$this->repositories[$name] = $repository;
		$this->classMap[$repository->getClassName()] = $name;
		return $repository;
	}