Skip to content

Commit

Permalink
hotifx for logger
Browse files Browse the repository at this point in the history
  • Loading branch information
tikohov20 committed Apr 24, 2024
1 parent 856e467 commit ed43e3c
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<argument key="$monduClient" type="service" id="mondu.mondu_api"/>
<argument key="$orderDataRepository" type="service" id="mondu_order_data.repository"/>
<argument key="$invoiceDataRepository" type="service" id="mondu_invoice_data.repository"/>
<argument key="$logger" type="service" id="mondu.logger"/>
<argument key="$logger" type="service" id="monolog.logger.mondu"/>
<argument key="$currencyRepository" id="currency.repository" type="service" />
</service>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function transition(Transition $transition, Context $context): StateMachi
if (!$this->configService->skipOrderStateValidation()) {

if ($transitionName == 'reopen' && !$this->canCancelOrder($order)) {
throw new MonduException('Order was canceled.');
// throw new MonduException('Order was canceled.');
}

if ($transitionName == 'ship' || $transitionName == 'ship_partially') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ public function __construct(
private readonly DocumentUrlHelper $documentUrlHelper,
private readonly LoggerInterface $logger,
private readonly EntityRepository $currencyRepository
) {}
) {

}

public static function getSubscribedEvents(): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Webhooks/DependencyInjection/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<defaults autowire="true"/>

<service id="mondu.webhook_service" class="Mondu\MonduPayment\Components\Webhooks\Service\WebhookService">
<argument key="$logger" type="service" id="mondu.logger"/>
<argument key="$logger" type="service" id="monolog.logger.mondu"/>
<argument key="$monduClient" type="service" id="mondu.mondu_api"/>
<argument key="$orderDataRepository" type="service" id="mondu_order_data.repository"/>
<argument key="$configService" type="service" id="mondu.mondu_config"/>
Expand Down
27 changes: 27 additions & 0 deletions src/Mond1SW6.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@
use Shopware\Core\Framework\Plugin\Context\ActivateContext;
use Symfony\Component\DependencyInjection\ContainerInterface;

use Symfony\Component\Config\FileLocator;
use Symfony\Component\Config\Loader\DelegatingLoader;
use Symfony\Component\Config\Loader\LoaderResolver;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\DirectoryLoader;
use Symfony\Component\DependencyInjection\Loader\GlobFileLoader;
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;


class Mond1SW6 extends Plugin
{
public function install(InstallContext $installContext): void
Expand Down Expand Up @@ -45,6 +54,24 @@ public function activate(ActivateContext $activateContext): void
}
}

public function build(ContainerBuilder $container): void
{
parent::build($container);

$locator = new FileLocator('Resources/config');

$resolver = new LoaderResolver([
new YamlFileLoader($container, $locator),
new GlobFileLoader($container, $locator),
new DirectoryLoader($container, $locator),
]);

$configLoader = new DelegatingLoader($resolver);

$confDir = \rtrim($this->getPath(), '/') . '/Resources/config';
$configLoader->load($confDir . '/{packages}/*.yaml', 'glob');
}

public function update(UpdateContext $updateContext): void
{
parent::update($updateContext);
Expand Down
23 changes: 0 additions & 23 deletions src/Pos/Run/LoggerFactory.php

This file was deleted.

9 changes: 9 additions & 0 deletions src/Resources/config/packages/monolog.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
monolog:
channels: ['mondu']

handlers:
monduLogHandler:
type: rotating_file
path: "%kernel.logs_dir%/mondu_%kernel.environment%.log"
level: error
channels: [ "mondu" ]
13 changes: 3 additions & 10 deletions src/Resources/config/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

<service id="mondu.mondu_api" class="Mondu\MonduPayment\Components\MonduApi\Service\MonduClient" public="true">
<argument type="service" id="mondu.mondu_config"/>
<argument key="$logger" type="service" id="mondu.logger"/>
<argument key="$logger" type="service" id="monolog.logger.mondu"/>
</service>

<service id="Mondu\MonduPayment\Components\MonduApi\Service\MonduOperationService">
Expand Down Expand Up @@ -85,7 +85,7 @@
<argument key="$orderDataRepository" type="service" id="mondu_order_data.repository"/>
<argument key="$invoiceDataRepository" type="service" id="mondu_invoice_data.repository"/>
<argument key="$monduClient" type="service" id="mondu.mondu_api"/>
<argument key="$logger" type="service" id="mondu.logger"/>
<argument key="$logger" type="service" id="monolog.logger.mondu"/>
<argument key="$productRepository" type="service" id="product.repository"/>
<argument key="$currencyRepository" type="service" id="currency.repository"/>
</service>
Expand All @@ -96,21 +96,14 @@
<argument key="$orderDataRepository" type="service" id="mondu_order_data.repository"/>
<argument key="$invoiceDataRepository" type="service" id="mondu_invoice_data.repository"/>
<argument key="$monduClient" type="service" id="mondu.mondu_api"/>
<argument key="$logger" type="service" id="mondu.logger"/>
<argument key="$logger" type="service" id="monolog.logger.mondu"/>
</service>

<service id="Mondu\MonduPayment\Bootstrap\MediaProvider" public="true">
<argument type="service" key="$mediaService" id="Shopware\Core\Content\Media\MediaService"/>
<argument type="service" key="$mediaRepository" id="media.repository"/>
</service>

<service id="Mondu\MonduPayment\Pos\Run\LoggerFactory"/>

<service id="mondu.logger" class="Monolog\Logger">
<factory service="Mondu\MonduPayment\Pos\Run\LoggerFactory" method="createLogger"/>
<argument type="string">mondu_payment</argument>
</service>

<service id="Mondu\MonduPayment\Command\ConfigApiTokenCommand">
<argument type="service" id="Shopware\Core\System\SystemConfig\SystemConfigService"/>
<tag name="console.command"/>
Expand Down

0 comments on commit ed43e3c

Please sign in to comment.