Created
July 17, 2015 21:39
-
-
Save monooso/817318b369a07ebc2d9b to your computer and use it in GitHub Desktop.
Helper method to determine whether a third-party Composer package is loaded by a particular Craft plugin.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Returns a boolean indicating whether the specified class is loaded from | |
| * the directory of the specified plugin. | |
| * | |
| * @param $namespacedClass | |
| * @param $pluginHandle | |
| * | |
| * @return bool | |
| */ | |
| protected function isPackageLoadedByPlugin($namespacedClass, $pluginHandle) | |
| { | |
| $reflector = new \ReflectionClass($namespacedClass); | |
| $pattern = '#' . CRAFT_PLUGINS_PATH . $pluginHandle . '/#'; | |
| return (bool) preg_match($pattern, $reflector->getFileName()); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment