Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PT-846: Implement Plugin for Shopware 6.6 #63

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mondu/shopware6-payment",
"description": "Mondu payment for Shopware 6",
"version": "1.1.4",
"version": "2.0.0",
"type": "shopware-platform-plugin",
"license": "proprietary",
"authors": [
Expand All @@ -15,7 +15,7 @@
}
},
"require": {
"shopware/core": "^6.5",
"shopware/core": "^6.6",
"ext-json": "*"
},
"extra": {
Expand Down
15 changes: 8 additions & 7 deletions src/Bootstrap/AbstractBootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@
use Shopware\Core\Framework\Plugin\Context\InstallContext;
use Shopware\Core\Framework\Plugin\Context\UpdateContext;
use Shopware\Core\Framework\Plugin\PluginEntity;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
use Symfony\Component\DependencyInjection\ContainerInterface;

abstract class AbstractBootstrap implements ContainerAwareInterface
abstract class AbstractBootstrap
{
use ContainerAwareTrait;

/**
* @var Context
*/
Expand All @@ -41,8 +38,12 @@ abstract class AbstractBootstrap implements ContainerAwareInterface
*/
protected PluginEntity $plugin;

final public function __construct()
{
/**
* @param ContainerInterface $container
*/
final public function __construct(
protected ContainerInterface $container,
) {
}

abstract public function install(): void;
Expand Down
9 changes: 2 additions & 7 deletions src/Components/Order/Controller/CreditNoteController.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Shopware\Core\Framework\Routing\Annotation\RouteScope;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepository;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;

/**
* @Route(defaults={"_routeScope"={"api"}})
*/
#[Route(defaults: ['_routeScope' => ['api']])]
class CreditNoteController extends AbstractController
{
public function __construct(
Expand All @@ -28,9 +25,7 @@ public function __construct(
private readonly EntityRepository $documentRepository
) {}

/**
* @Route(name="mondu-payment.credit_note.cancel", path="/api/mondu/orders/{orderId}/credit_notes/{creditNoteId}/cancel", defaults={"csrf_protected"=false}, methods={"POST"})
*/
#[Route(path: '/api/mondu/orders/{orderId}/credit_notes/{creditNoteId}/cancel', name: 'mondu-payment.credit_note.cancel', methods: ['POST'])]
public function cancel(Request $request, string $orderId, string $creditNoteId, Context $context): Response
{
try {
Expand Down
5 changes: 1 addition & 4 deletions src/Components/Order/Controller/DocumentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use Symfony\Component\Routing\Annotation\Route;

#[Route(defaults: ['_routeScope' => ['storefront']])]

class DocumentController extends AbstractController
{
/**
Expand All @@ -26,9 +25,7 @@ public function __construct(
private readonly DocumentGenerator $documentGenerator
) {}

/**
* @Route(name="mondu-payment.payment.document", path="/mondu/document/{documentId}/{deepLinkCode}/{token}")
*/
#[Route(path: '/mondu/document/{documentId}/{deepLinkCode}/{token}', name: 'mondu-payment.payment.document')]
public function downloadDocument(Request $request, string $documentId, string $deepLinkCode, Context $context): Response
{
$documentUrlHelper = $this->container->get(DocumentUrlHelper::class);
Expand Down
8 changes: 2 additions & 6 deletions src/Components/Order/Controller/InvoiceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
use Mondu\MonduPayment\Util\CriteriaHelper;

/**
* @Route(defaults={"_routeScope"={"api"}})
*/
#[Route(defaults: ['_routeScope' => ['api']])]
class InvoiceController extends AbstractController
{
public function __construct(
Expand All @@ -27,9 +25,7 @@ public function __construct(
private readonly EntityRepository $orderDataRepository
) {}

/**
* @Route(name="mondu-payment.invoice.cancel", path="/api/mondu/orders/{orderId}/{invoiceId}/cancel", defaults={"csrf_protected"=false}, methods={"POST"})
*/
#[Route(path: '/api/mondu/orders/{orderId}/{invoiceId}/cancel', name: 'mondu-payment.invoice.cancel', methods: ['POST'])]
public function cancel(Request $request, string $orderId, string $invoiceId, Context $context): Response
{
try {
Expand Down
14 changes: 7 additions & 7 deletions src/Components/Order/DependencyInjection/controllers.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
xsi:schemaLocation="https://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd">
<services>

<defaults autowire="true" >
Expand All @@ -18,18 +18,18 @@
<argument key="$monduClient" type="service" id="mondu.mondu_api" />
<argument key="$invoiceDataRepository" type="service" id="mondu_invoice_data.repository"/>
<argument key="$orderDataRepository" type="service" id="mondu_order_data.repository"/>
<call method="setContainer">
<argument id="service_container" type="service"/>
</call>
<call method="setContainer">
<argument id="service_container" type="service"/>
</call>
</service>

<service id="Mondu\MonduPayment\Components\Order\Controller\CreditNoteController">
<argument key="$monduClient" type="service" id="mondu.mondu_api" />
<argument key="$invoiceDataRepository" type="service" id="mondu_invoice_data.repository"/>
<argument key="$orderDataRepository" type="service" id="mondu_order_data.repository"/>
<call method="setContainer">
<argument id="service_container" type="service"/>
</call>
<call method="setContainer">
<argument id="service_container" type="service"/>
</call>
</service>

</services>
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Order/Model/OrderDataEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class OrderDataEntity extends Entity
/**
* @var OrderEntity
*/
protected OrderEntity $order;
protected $order;

/**
* @var string
Expand Down
8 changes: 2 additions & 6 deletions src/Components/PluginConfig/Controller/ConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,14 @@
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

/**
* @Route(defaults={"_routeScope"={"api"}})
*/
#[Route(defaults: ['_routeScope' => ['api']])]
class ConfigController extends AbstractController
{
public function __construct(
private readonly MonduClient $monduClient
) {}

/**
* @Route(name="mondu-payment.config.test", path="/api/mondu/config/test", defaults={"csrf_protected"=false}, methods={"POST"})
*/
#[Route(path: '/api/mondu/config/test', name: 'mondu-payment.config.test', methods: ['POST'])]
public function test(Request $request, Context $context): Response
{
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
xsi:schemaLocation="https://symfony.com/schema/dic/services https://symfony.com/schema/dic/services/services-1.0.xsd">
<services>

<defaults autowire="true" >
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
xsi:schemaLocation="https://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<defaults autowire="true"/>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
xsi:schemaLocation="https://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<defaults autowire="true" />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
xsi:schemaLocation="https://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>

<defaults autowire="true">
Expand Down
8 changes: 2 additions & 6 deletions src/Components/Webhooks/Controller/WebhooksController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;

/**
* @Route(defaults={"_routeScope"={"storefront"}})
*/
#[Route(defaults: ['_routeScope' => ['storefront']])]
class WebhooksController extends StorefrontController
{
private ConfigService $configService;
Expand All @@ -29,9 +27,7 @@ public function __construct(
$this->webhookService = $webhookService;
}

/**
* @Route("/mondu/webhooks", name="mondu-payment.webhooks", defaults={"csrf_protected"=false}, methods={"POST"})
*/
#[Route(path: '/mondu/webhooks', name: 'mondu-payment.webhooks', methods: ['POST'])]
public function process(Request $request, Context $context): Response
{
$content = $request->getContent();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
xsi:schemaLocation="https://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>

<defaults autowire="true" >
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Webhooks/DependencyInjection/services.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
xsi:schemaLocation="https://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<defaults autowire="true"/>

Expand Down
6 changes: 3 additions & 3 deletions src/Mond1SW6.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Shopware\Core\Framework\Plugin\Context\UninstallContext;
use Shopware\Core\Framework\Plugin\Context\UpdateContext;
use Shopware\Core\Framework\Plugin\Context\ActivateContext;
use Symfony\Component\DependencyInjection\ContainerInterface;

class Mond1SW6 extends Plugin
{
Expand Down Expand Up @@ -76,8 +77,8 @@ public function uninstall(UninstallContext $uninstallContext): void
protected function getBootstrapClasses(InstallContext $installContext): array
{
$bootstrapper = [
new PaymentMethods(),
new Database()
new PaymentMethods($this->container),
new Database($this->container)
];

$pluginRepository = $this->container->get('plugin.repository');
Expand All @@ -91,7 +92,6 @@ protected function getBootstrapClasses(InstallContext $installContext): array
foreach ($bootstrapper as $bootstrap) {
$bootstrap->setContext($installContext->getContext());
$bootstrap->setInstallContext($installContext);
$bootstrap->setContainer($this->container);
$bootstrap->injectServices();
$bootstrap->setPlugin($plugin);
}
Expand Down
23 changes: 23 additions & 0 deletions src/Pos/Run/LoggerFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace Mondu\MonduPayment\Pos\Run;

use Monolog\Logger;
use Monolog\Processor\PsrLogMessageProcessor;
use Shopware\Core\Framework\Log\Package;
use Swag\PayPal\Pos\Run\LogHandler;

#[Package('checkout')]
class LoggerFactory
{
public function createLogger(): Logger
{
$logger = new Logger('mondu_mondupayment_pos');
$logger->pushHandler(new LogHandler());
$logger->pushProcessor(new PsrLogMessageProcessor());

return $logger;
}
}
4 changes: 2 additions & 2 deletions src/Resources/config/routes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<routes xmlns="http://symfony.com/schema/routing"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/routing
http://symfony.com/schema/routing/routing-1.0.xsd">
https://symfony.com/schema/routing/routing-1.0.xsd">

<import resource="../../Components/**/Controller/*" type="annotation" />
<import resource="../../Components/**/Controller/*" type="attribute" />
</routes>
6 changes: 4 additions & 2 deletions src/Resources/config/services.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
xsi:schemaLocation="https://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">

<imports>
<import resource="../../Components/*/DependencyInjection/services.xml"/>
Expand Down Expand Up @@ -104,8 +104,10 @@
<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="Shopware\Core\Framework\Log\LoggerFactory" method="createRotating"/>
<factory service="Mondu\MonduPayment\Pos\Run\LoggerFactory" method="createLogger"/>
<argument type="string">mondu_payment</argument>
</service>

Expand Down
Loading