8000 Fix autoconfigure for Coupon condition by lopes-vincent · Pull Request #3103 · thelia/thelia · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix autoconfigure for Coupon condition #3103

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

Merged
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
2 changes: 2 additions & 0 deletions core/lib/Thelia/Condition/ConditionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ public function unserializeConditionCollection(string $serializedConditions)
*/
public function build(string $conditionServiceId, array $operators, array $values)
{
$conditionServiceId = urldecode($conditionServiceId);

if (!$this->container->has($conditionServiceId)) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,16 +139,9 @@ protected function generateInputs()
);
}

/**
* Get ConditionManager Service id.
*
* @return string
*/
public function getServiceId()
{
throw new \Thelia\Exception\NotImplementedException(
'The getServiceId method must be implemented in '.__CLASS__
);
return static::class;
}

/**
Expand Down
5 changes: 4 additions & 1 deletion core/lib/Thelia/Core/Thelia.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,6 @@ protected function loadConfiguration(ContainerBuilder $container): void
FormExtensionInterface::class => 'thelia.forms.extension',
ContainerAwareInterface::class => 'thelia.command',
CouponInterface::class => 'thelia.coupon.addCoupon',
ConditionInterface::class => 'thelia.coupon.addCondition',
ControllerInterface::class => 'controller.service_arguments',
TaxTypeInterface::class => 'thelia.taxType',
];
Expand All @@ -467,6 +466,10 @@ protected function loadConfiguration(ContainerBuilder $container): void
->addTag($tag);
}

$container->registerForAutoconfiguration(ConditionInterface::class)
->setPublic(true)
->addTag('thelia.coupon.addCondition');

$container->registerForAutoconfiguration(LoopInterface::class)
->setPublic(true)
->setShared(false)
Expand Down
2 changes: 1 addition & 1 deletion templates/backOffice/default/coupon/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@
<select name="categoryCondition" id="category-condition" class="form-control">
<option value="" data-description="">{intl l='Please select a condition'}</option>
{foreach from=$availableConditions item=availableCondition}
<option value="{$availableCondition.serviceId}" data-description="{$availableCondition.toolTip}">{$availableCondition.name}</option>
<option value="{$availableCondition.serviceId|escape:'url'}" data-description="{$availableCondition.toolTip}">{$availableCondition.name}</option>
{/foreach}
</select>
<span class="help-block typeToolTip"></span>
Expand Down
0