[Framework] added Kernel::isClassInActiveBundle()
This commit is contained in:
parent
248e501df5
commit
2f84c280d0
@ -229,6 +229,25 @@ abstract class Kernel implements HttpKernelInterface, \Serializable
|
||||
return $this->bundles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a given class name belongs to an active bundle.
|
||||
*
|
||||
* @param string $class A class name
|
||||
*
|
||||
* @return Boolean true if the class belongs to an active bundle, false otherwise
|
||||
*/
|
||||
public function isClassInActiveBundle($class)
|
||||
{
|
||||
foreach ($this->bundles as $bundle) {
|
||||
$bundleClass = get_class($bundle);
|
||||
if (0 === strpos($class, substr($bundleClass, 0, strrpos($bundleClass, '\\')))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->name;
|
||||
|
Reference in New Issue
Block a user