Skip to content

Instantly share code, notes, and snippets.

View lchrusciel's full-sized avatar
🎯
Focusing

Łukasz Chruściel lchrusciel

🎯
Focusing
View GitHub Profile
<?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;
<service id="App\Promotion\Action\FreeItemPromotionActionCommand">
<tag name="sylius.promotion_action" type="free_item" label="app.form.promotion_action.free_item" form-type="App\Form\Type\Promotion\Action\FreeItemConfigurationType" />
</service>
@lchrusciel
lchrusciel / FreeItemPromotionActionCommand.php
Created May 15, 2024 19:16
Sample configuration of new promotion action
<?php
// src/Promotion/Action/FreeItemPromotionActionCommand.php
declare(strict_types=1);
namespace App\Promotion\Action;
use Sylius\Component\Promotion\Action\PromotionActionCommandInterface;
use Sylius\Component\Promotion\Model\PromotionInterface;
<?php
// src/Controller/BlogController.php
namespace App\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
class BlogController extends AbstractController
@lchrusciel
lchrusciel / TwigRendererEngine.php
Last active March 9, 2024 09:34
Customization required to allow more then one add to cart button in Sylius (SymfonyForm fix version)
<?php
// src/Twig/Form/TwigRendererEngine.php
namespace App\Twig\Form;
use Symfony\Component\Form\AbstractRendererEngine;
use Symfony\Component\Form\FormView;
use Symfony\Component\VarDumper\VarDumper;
use Twig\Environment;
@lchrusciel
lchrusciel / CartItemTypeExtension.php
Last active March 9, 2024 09:21
Customization required to allow more then one add to cart button in Sylius (Sylius CartItemExtension version)
<?php
// src/Form/Extension/CartItemTypeExtension.php
declare(strict_types=1);
namespace App\Form\Extension;
use Sylius\Bundle\OrderBundle\Form\Type\CartItemType;
use Sylius\Bundle\ProductBundle\Form\Type\ProductVariantChoiceType;
@lchrusciel
lchrusciel / Sorter.php
Created March 15, 2022 11:52
DQL injection through sorting parameters security bug fix
<?php
// src/App/Sorting/Sorter.php
declare(strict_types=1);
namespace App\Sorting;
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
use Sylius\Component\Grid\Data\DataSourceInterface;
@lchrusciel
lchrusciel / ResetPasswordHandler.php
Last active March 16, 2022 12:21
Reset password token not set to null after reset password security bug fix
<?php
// src/CommandHandler/Account/ResetPasswordHandler.php
declare(strict_types=1);
namespace App\CommandHandler\Account;
use Sylius\Bundle\ApiBundle\Command\Account\ResetPassword;
use Sylius\Component\Core\Model\ShopUserInterface;
@lchrusciel
lchrusciel / CacheControlSubscriber.php
Last active March 15, 2022 11:23
Exposure of sensitive information by using the back button after logging out security bug fix
<?php
// src/EventListener/CacheControlSubscriber.php
declare(strict_types=1);
namespace App\EventListener;
use App\SectionResolver\ShopCustomerAccountSubSection;
use Sylius\Bundle\AdminBundle\SectionResolver\AdminSection;
@lchrusciel
lchrusciel / XFrameOptionsSubscriber.php
Created March 15, 2022 11:04
Missing HTTP headers to avoid login forms clickjacking security bug fix
<?php
// src/EventListener/XFrameOptionsSubscriber.php
namespace App\EventListener
final class XFrameOptionsSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{