public function read($object, $namespace)
    {
        $className = is_object($object) ? get_class($object) : $object;
        $manager = $this->getManagerForClass($className);
        $factory = $manager->getMetadataFactory();
        $meta = $factory->getMetadataFor($className);

        if ($meta->isMappedSuperclass) {
            return;
        }

        $cacheDriver = $factory->getCacheDriver();
        $cacheId = static::getCacheId($meta->name, $namespace);

        if ($cacheDriver && ($cached = $cacheDriver->fetch($cacheId)) !== false) {
            return $cached;
        }

        $metadata = array();
        // Collect metadata from inherited classes
        if (null !== $meta->reflClass) {
        	$driver = $this->getDriverForManager($manager, $namespace);

            foreach (array_reverse(class_parents($meta->name)) as $parentClass) {
                // read only inherited mapped classes
                if ($factory->hasMetadataFor($parentClass)) {
                    $class = $manager->getClassMetadata($parentClass);
                    $driver->read($class, $metadata);
                }
            }

            $driver->read($meta, $metadata);
        }

        /* Cache the metadata (even if it's empty). Caching empty
         * metadata will prevent re-parsing non-existent annotations
         */
        if ($cacheDriver) {
            $cacheDriver->save($cacheId, $metadata, null);
        }

        return $metadata;
    }
public function read($object, $namespace)
    {
        $className = is_object($object) ? get_class($object) : $object;
        $manager = $this->getManagerForClass($className);
        $factory = $manager->getMetadataFactory();
        $meta = $factory->getMetadataFor($className);

        if ($meta->isMappedSuperclass) {
            return;
        }

        $cacheDriver = $factory->getCacheDriver();
        $cacheId = static::getCacheId($meta->name, $namespace);

        if ($cacheDriver && ($cached = $cacheDriver->fetch($cacheId)) !== false) {
            return $cached;
        }

        $metadata = array();
        // Collect metadata from inherited classes
        if (null !== $meta->reflClass) {
        	$driver = $this->getDriverForManager($manager, $namespace);

            foreach (array_reverse(class_parents($meta->name)) as $parentClass) {
                // read only inherited mapped classes
                if ($factory->hasMetadataFor($parentClass)) {
                    $class = $manager->getClassMetadata($parentClass);
                    $driver->read($class, $metadata);
                }
            }

            $driver->read($meta, $metadata);
        }

        /* Cache the metadata (even if it's empty). Caching empty
         * metadata will prevent re-parsing non-existent annotations
         */
        if ($cacheDriver) {
            $cacheDriver->save($cacheId, $metadata, null);
        }

        return $metadata;
    }
{@inheritDoc}