Skip to content

Instantly share code, notes, and snippets.

@lchrusciel
Last active May 27, 2024 08:48
Show Gist options
  • Save lchrusciel/dbafc8a89c0c1a25352bda43e338325a to your computer and use it in GitHub Desktop.
Save lchrusciel/dbafc8a89c0c1a25352bda43e338325a to your computer and use it in GitHub Desktop.
<?php
// src/Promotion/Action/FreeItemPromotionActionCommand.php
declare(strict_types=1);
namespace App\Promotion\Action;
use Sylius\Bundle\PromotionBundle\Attribute\AsPromotionAction;
use Sylius\Component\Promotion\Action\PromotionActionCommandInterface;
use Sylius\Component\Promotion\Model\PromotionInterface;
use Sylius\Component\Promotion\Model\PromotionSubjectInterface;
use App\Form\Type\Promotion\Action\FreeItemConfigurationType;
#[AsPromotionAction(
type: 'free_item',
label: 'app.form.promotion_action.free_item',
formType: FreeItemConfigurationType::class
)]
final class FreeItemPromotionActionCommand implements PromotionActionCommandInterface
{
public function execute(PromotionSubjectInterface $subject, array $configuration, PromotionInterface $promotion): bool
{
// Promotion logic
}
public function revert(PromotionSubjectInterface $subject, array $configuration, PromotionInterface $promotion): void
{
// Promotion reverting logic
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment