Sensio\Bundle\FrameworkExtraBundle\EventListener\TemplateListener::getBundleForClass PHP Method

getBundleForClass() protected method

Returns the Bundle instance in which the given class name is located.
protected getBundleForClass ( string $class )
$class string A fully qualified controller class name
    protected function getBundleForClass($class)
    {
        $namespace = strtr(dirname(strtr($class, '\\', '/')), '/', '\\');
        foreach ($this->container->get('kernel')->getBundles() as $bundle) {
            if (0 === strpos($namespace, $bundle->getNamespace())) {
                return $bundle;
            }
        }

        throw new \InvalidArgumentException(sprintf('The "%s" class does not belong to a registered bundle.', $class));
    }