public function getMetadataFor($className)
    {
        if (isset($this->loadedMetadata[$className])) {
            return $this->loadedMetadata[$className];
        }

        $realClassName = ClassUtils::getRealClass($className);

        if (isset($this->loadedMetadata[$realClassName])) {
            // We do not have the alias name in the map, include it
            $this->loadedMetadata[$className] = $this->loadedMetadata[$realClassName];

            return $this->loadedMetadata[$realClassName];
        }

        if ($this->cacheDriver) {
            if (($cached = $this->cacheDriver->fetch($realClassName . $this->cacheSalt)) !== false) {
                $this->loadedMetadata[$realClassName] = $cached;
            } else {
                $this->cacheDriver->save(
                    $realClassName . $this->cacheSalt, $this->loadMetadata($realClassName), null
                );
            }
        } else {
            $this->loadMetadata($realClassName);
        }

        if ($className != $realClassName) {
            // We do not have the alias name in the map, include it
            $this->loadedMetadata[$className] = $this->loadedMetadata[$realClassName];
        }

        return $this->loadedMetadata[$className];
    }