Skip to content

Commit

Permalink
remove MethodMetaData and replace with IconRenderer to show icons
Browse files Browse the repository at this point in the history
  • Loading branch information
vegimcarkaxhija committed Aug 22, 2024
1 parent ecea229 commit 278b58c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 40 deletions.
39 changes: 0 additions & 39 deletions Model/MethodMetaData.php

This file was deleted.

32 changes: 32 additions & 0 deletions Plugin/IconRenderer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Buckaroo\HyvaCheckout\Plugin;

use Hyva\Checkout\Model\MethodMetaData\IconRenderer as IconRendererHyva;
use Magento\Framework\View\Asset\Repository;

class IconRenderer
{
protected Repository $assetRepository;

public function __construct(
Repository $assetRepository
) {
$this->assetRepository = $assetRepository;
}

public function aroundRender(
IconRendererHyva $subject,
callable $proceed,
array $icon
): string {
// Check if this is a Buckaroo method and handle it
if (isset($icon['svg']) && strpos($icon['svg'], 'Buckaroo_') !== false) {
$logoLink = $this->assetRepository->getUrl($icon['svg']);
return '<img style="height:30px" src="' . $logoLink . '">';
}

// Otherwise, proceed with the default behavior
return $proceed($icon);
}
}
2 changes: 1 addition & 1 deletion Plugin/MethodList.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Magento\Payment\Model\MethodInterface as PaymentMethodInterface;
use Buckaroo\Magento2\Model\ConfigProvider\Method\ConfigProviderInterface;
use Hyva\Checkout\ViewModel\Checkout\Payment\MethodList as HyvaMethodList;
use Buckaroo\HyvaCheckout\Model\MethodMetaDataFactory;
use Hyva\Checkout\Model\MethodMetaDataFactory;

class MethodList implements \Magento\Framework\View\Element\Block\ArgumentInterface
{
Expand Down
4 changes: 4 additions & 0 deletions etc/di.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@
<type name="Hyva\Checkout\ViewModel\Checkout\Payment\MethodList">
<plugin name="buckaroo-hyva-logo-subtext" type="Buckaroo\HyvaCheckout\Plugin\MethodList" />
</type>

<type name="Hyva\Checkout\Model\MethodMetaData\IconRenderer">
<plugin name="buckaroo_hyva_checkout_icon_renderer" type="Buckaroo\HyvaCheckout\Plugin\IconRenderer" />
</type>
</config>

0 comments on commit 278b58c

Please sign in to comment.