-
☆ A M B ☆
- 24,524 Posts
Your add-on optionally tries to use a service provided by another add-on. What would be the best way to determine if the second add-on is installed, before using getService()? This check would act as a wrapper, preventing error messages if the second add-on is not installed.
getService() will return null if it fails, though it will put a line in the error log.
I think this might possibly do what you want:
$className = $modx->loadClass($class, $path, false, true)
if (empty ($className)) {
/* Service not available */
}
-
☆ A M B ☆
- 24,524 Posts
What I'm trying to do is to avoid the MODX error messages if the extra isn't installed. Something like PHP's class_exists() function.
That's why I suggested the code above. I'm pretty sure that loadClass() won't throw an error message if it fails.
You might also be able to set the log level for the call -- something like this:
/* Turn off LOG_LEVEL_ERROR messages */
$level = $modx->setLogLevel(modX::LOG_LEVEL_FATAL);
/* getService() call here. */
/* restore previous log level */
$modx->SetLogLevel($level);