protected function buildMapper($entity, $entityMap)
    {
        // If an EntityMap hasn't been manually registered by the user
        // register it at runtime.
        if (!$this->isRegisteredEntity($entity)) {
            $this->register($entity, $entityMap);
        }

        $entityMap = $this->entityClasses[$entity];

        $factory = new MapperFactory($this->drivers, $this->eventDispatcher, $this);

        $mapper = $factory->make($entity, $entityMap);

        $this->mappers[$entity] = $mapper;

        // At this point we can safely call the boot() method on the entityMap as
        // the mapper is now instantiated & registered within the manager.

        if (!$entityMap->isBooted()) {
            $entityMap->boot();
        }

        // If a cache is defined, use it to store the entityMap
        if ($this->cache !== null && !$this->cache->has($entityMap->getClass()) && !$this->isAnonymous($entityMap)) {
            $this->cache->set($entityMap->getClass(), serialize($entityMap), 1440);
        }

        return $mapper;
    }