Skip to content

Commit

Permalink
[TASK] Adaptions after split of ProductPlugin
Browse files Browse the repository at this point in the history
After the migration of switchableControllerActions
in EXT:cart_products the pluginName can differ which
needs to be considered.
This makes the approach more generic.
  • Loading branch information
rintisch committed Oct 10, 2024
1 parent 3e848a5 commit 3a4d0f2
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 34 deletions.
15 changes: 14 additions & 1 deletion Classes/Domain/Model/Cart/DetailPageLink.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public function __construct(
protected int $pageUid,
protected string $extensionName = '',
protected string $pluginName = '',
protected string $controller = ''
protected string $controller = '',
protected string $action = '',
) {}

public function getPageUid(): int
Expand All @@ -39,4 +40,16 @@ public function getController(): string
{
return $this->controller;
}
public function getAction(): string
{
return $this->action;
}

public function isActionLink(): bool
{
if ($this->pageUid && $this->extensionName && $this->pluginName && $this->controller && $this->action) {
return true;
}
return false;
}
}
5 changes: 3 additions & 2 deletions Classes/Domain/Model/Cart/DetailPageLinkFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ public function getDetailPageLink(
int $detailPageUid,
string $extensionName = '',
string $pluginName = '',
string $controller = ''
string $controller = '',
string $action = '',
): ?DetailPageLink {
if ($detailPageUid > 0) {
return new DetailPageLink($detailPageUid, $extensionName, $pluginName, $controller);
return new DetailPageLink($detailPageUid, $extensionName, $pluginName, $controller, $action);
}
return null;
}
Expand Down
3 changes: 2 additions & 1 deletion Classes/Domain/Model/Cart/DetailPageLinkFactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public function getDetailPageLink(
int $detailPageUid,
string $extensionName = '',
string $pluginName = '',
string $controller = ''
string $controller = '',
string $action = ''
): ?DetailPageLink;
}
65 changes: 35 additions & 30 deletions Resources/Private/Partials/Cart/ProductForm/ProductList.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,41 @@
xmlns:cart="http://typo3.org/ns/Extcode/Cart/ViewHelpers"
data-namespace-typo3-fluid="true">

<f:section name="detailLink">
<f:if condition="{product.detailPageLink}">
<f:then>
<f:if condition="{product.detailPageLink.actionLink}">
<f:link.action
pageUid="{product.detailPageLink.pageUid}"
extensionName="{product.detailPageLink.extensionName}"
pluginName="{product.detailPageLink.pluginName}"
controller="{product.detailPageLink.controller}"
action="{product.detailPageLink.action}"
arguments="{product: product.productId}">
{linkedTitle}
</f:link.action>
</f:if>
<f:if condition="!{product.detailPageLink.actionLink} && {product.detailPageLink.pageUid}">
<f:link.page pageUid="{product.detailPageLink.pageUid}">
{linkedTitle}
</f:link.page>
</f:if>

</f:then>
<f:else>
{linkedTitle}
</f:else>
</f:if>
</f:section>

<f:section name="withoutVariant">
<tr class="{f:if(condition: product.quantityInRange, then: '', else: 'danger')}">
<td colspan="2" class="col-md-6">
<div class="product-name">
<f:if condition="{product.detailPageLink}">
<f:then>
<f:link.action
pageUid="{product.detailPageLink.pageUid}"
extensionName="{product.detailPageLink.extensionName}"
pluginName="{product.detailPageLink.pluginName}"
controller="{product.detailPageLink.controller}"
arguments="{product: product.productId}">
{product.title} {f:if(condition:'{product.feVariant.value}',then:'- {product.feVariant.value}')}
</f:link.action>
</f:then>
<f:else>
{product.title} {f:if(condition:'{product.feVariant.value}',then:'- {product.feVariant.value}')}
</f:else>
</f:if>
<f:variable name="linkedTitle">
{product.title} {f:if(condition:'{product.feVariant.value}',then:'- {product.feVariant.value}')}
</f:variable>
<f:render section="detailLink" arguments="{product: product, linkedTitle: linkedTitle}"/>
</div>
<p>
<f:translate key="tx_cart_domain_model_order_product.sku.short"/>
Expand Down Expand Up @@ -74,21 +90,10 @@
<td class="col-md-1">&nbsp;</td>
<td class="col-md-5">
<div class="product-name">
<f:if condition="{product.detailPageParameter.pageUid} && {product.detailPageParameter.extensionName}">
<f:then>
<f:link.action
pageUid="{product.detailPageLink.pageUid}"
extensionName="{product.detailPageLink.extensionName}"
pluginName="{product.detailPageLink.pluginName}"
controller="{product.detailPageLink.controller}"
arguments="{product: product.productId}">
{variant.title}
</f:link.action>
</f:then>
<f:else>
{variant.title}
</f:else>
</f:if>
<f:variable name="linkedTitle">
{variant.title}
</f:variable>
<f:render section="detailLink" arguments="{product: product, linkedTitle: linkedTitle}"/>
</div>
<p>
<f:translate key="tx_cart_domain_model_order_product.sku.short"/>
Expand Down

0 comments on commit 3a4d0f2

Please sign in to comment.