protected static function classInterfaceExists($class, $type)
{
$functionName = $type . "_exists";
// if the class is already loaded we can skip right here
if ($functionName($class, false)) {
return true;
}
$class = "\\" . ltrim($class, "\\");
// let's test if we have seens this class already before
if (isset(self::$notFoundClassNames[$class])) {
return false;
}
// we need to set a custom error handler here for the time being
// unfortunately suppressNotFoundWarnings() doesn't work all the time, it has something to do with the calls in
// Pimcore\Tool::ClassMapAutoloader(), but don't know what actual conditions causes this problem.
// but to be save we log the errors into the debug.log, so if anything else happens we can see it there
// the normal warning is e.g. Warning: include_once(Path/To/Class.php): failed to open stream: No such file or directory in ...
set_error_handler(function ($errno, $errstr, $errfile, $errline) {
//Logger::debug(implode(" ", [$errno, $errstr, $errfile, $errline]));
});
\Zend_Loader_Autoloader::getInstance()->suppressNotFoundWarnings(true);
$exists = $functionName($class);
\Zend_Loader_Autoloader::getInstance()->suppressNotFoundWarnings(false);
restore_error_handler();
if (!$exists) {
self::$notFoundClassNames[$class] = true;
// value doesn't matter, key lookups are faster ;-)
}
return $exists;
}