Created
May 26, 2020 13:14
-
-
Save proudcommerce/602ab33c23a1546588266812ed72ac30 to your computer and use it in GitHub Desktop.
Fix for OXID 6.2 circular reference service problems
This file contains 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
# thx to alfred (https://github.com/alfredbez) for sharing | |
# add to modules/functions.php | |
use Monolog\Logger; | |
use Monolog\Handler\StreamHandler; | |
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory; | |
use Psr\Log\LoggerInterface; | |
use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException; | |
function getLogger() { | |
$loggerServiceName = LoggerInterface::class; | |
try { | |
$container = ContainerFactory::getInstance()->getContainer(); | |
return $container->get($loggerServiceName); | |
} catch (ServiceCircularReferenceException $exception) { | |
if (strpos($exception->getMessage(), $loggerServiceName) !== false) { | |
$logger = new Logger('OXID Logger'); | |
$logger->pushHandler(new StreamHandler(OX_LOG_FILE, Logger::ERROR)); | |
$logger->critical('Not able to load logger from container'); | |
return $logger; | |
} | |
throw $exception; | |
} | |
} |
@proudcommerce & @suabo FYI: There is also an open Pull-Request to fix this directly in the core: OXID-eSales/oxideshop_ce#810
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thx 4 Sharing