src/IlluminateRegistry.php
public function getManagerForClass($class)
    {
        // Check for namespace alias
        if (strpos($class, ':') !== false) {
            list($namespaceAlias, $simpleClassName) = explode(':', $class, 2);
            $class                                  = $this->getAliasNamespace($namespaceAlias) . '\\' . $simpleClassName;
        }

        $proxyClass = new ReflectionClass($class);
        if ($proxyClass->implementsInterface(Proxy::class)) {
            $class = $proxyClass->getParentClass()->getName();
        }

        $managerNames = $this->getManagerNames();

        if (count($managerNames) === 1) {
            return $this->getManager(reset($managerNames));
        }

        foreach ($managerNames as $name) {
            $manager = $this->getManager($name);

            if (!$manager->getMetadataFactory()->isTransient($class)) {
                foreach ($manager->getMetadataFactory()->getAllMetadata() as $metadata) {
                    if ($metadata->getName() === $class) {
                        return $manager;
                    }
                }
            }
        }
    }
public function getManagerForClass($class)
    {
        // Check for namespace alias
        if (strpos($class, ':') !== false) {
            list($namespaceAlias, $simpleClassName) = explode(':', $class, 2);
            $class                                  = $this->getAliasNamespace($namespaceAlias) . '\\' . $simpleClassName;
        }

        $proxyClass = new ReflectionClass($class);
        if ($proxyClass->implementsInterface(Proxy::class)) {
            $class = $proxyClass->getParentClass()->getName();
        }

        $managerNames = $this->getManagerNames();

        if (count($managerNames) === 1) {
            return $this->getManager(reset($managerNames));
        }

        foreach ($managerNames as $name) {
            $manager = $this->getManager($name);

            if (!$manager->getMetadataFactory()->isTransient($class)) {
                foreach ($manager->getMetadataFactory()->getAllMetadata() as $metadata) {
                    if ($metadata->getName() === $class) {
                        return $manager;
                    }
                }
            }
        }
    }
public function getManagerForClass ( $ class ) { // Check for namespace alias if ( strpos ( $ class , ':' ) !== false ) { list ( $ namespaceAlias , $ simpleClassName ) = explode ( ':' , $ class , 2 ) ; $ class = $ this -> getAliasNamespace ( $ namespaceAlias ) . '\\' . $ simpleClassName ; } $ proxyClass = new ReflectionClass ( $ class ) ; if ( $ proxyClass -> implementsInterface ( Proxy :: class ) ) { $ class = $ proxyClass -> getParentClass ( ) -> getName ( ) ; } $ managerNames = $ this -> getManagerNames ( ) ; if ( count ( $ managerNames ) === 1 ) { return $ this -> getManager ( reset ( $ managerNames ) ) ; } foreach ( $ managerNames as $ name ) { $ manager = $ this -> getManager ( $ name ) ; if ( ! $ manager -> getMetadataFactory ( ) -> isTransient ( $ class ) ) { foreach ( $ manager -> getMetadataFactory ( ) -> getAllMetadata ( ) as $ metadata ) { if ( $ metadata -> getName ( ) === $ class ) { return $ manager ; } } } } }
Gets the object manager associated with a given class.

@param string $class A persistent object class name.

@return \Doctrine\Common\Persistence\ObjectManager|null
Gets the object manager associated with a given class .