Skip to content

Instantly share code, notes, and snippets.

View lchrusciel's full-sized avatar
🎯
Focusing

Łukasz Chruściel lchrusciel

🎯
Focusing
View GitHub Profile
@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 / 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 / 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 / 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
{
@lchrusciel
lchrusciel / ImageUploader.php
Created March 15, 2022 10:54
SVG sanitizer security bug fix
<?php
// src/Uploader/ImageUploader.php
declare(strict_types=1);
namespace App\Uploader;
use enshrined\svgSanitize\Sanitizer;
use Gaufrette\Filesystem;
@lchrusciel
lchrusciel / Sample ProductBundle class
Created April 27, 2018 14:01
Sample ProductBundle class
// src/AppBundle/Entity/ProductBundle.php
<?php
declare(strict_types=1);
namespace AppBundle\Entity;
use Sylius\Component\Resource\Model\ResourceInterface;
class ProductBundle implements ResourceInterface
@lchrusciel
lchrusciel / specification.tpl
Created July 16, 2015 08:14
Specification template for phpspec. Put this file into .phpspec directory in a root of your project.
<?php
namespace %namespace%;
use PhpSpec\ObjectBehavior;
/**
* @author Łukasz Chruściel <lukasz.chrusciel@lakion.com>
*/
class %name% extends ObjectBehavior
@lchrusciel
lchrusciel / method.tpl
Created July 16, 2015 07:31
Method template for phpspec. Put this file into .phpspec directory in a root of your project.
/**
* @param
*
* @return
*/
public function %name%(%arguments%)
{
// TODO: write logic here
}