Skip to content

Instantly share code, notes, and snippets.

View masacc's full-sized avatar

Thomas Ramel masacc

  • La Rochelle, France
View GitHub Profile
@masacc
masacc / CombinationsGeneratorProvider.php
Last active September 29, 2020 13:33
Nelmio Alice Fixtures Provider : unique constraint on multiple properties
<?php
// src/Faker/Provider/CombinationsGeneratorProvider.php
namespace App\Faker\Provider;
use Faker\Provider\Base as BaseProvider;
/**
* How to use :
* - generate a list of random list of all combinations with `<generateAllCombinations()>`
@masacc
masacc / OrSearchFilter.php
Last active October 1, 2020 09:05
Yet Another API Platform "Or Search Filter".
<?php
namespace App\Filter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Core\Bridge\Doctrine\Orm\Util\QueryNameGeneratorInterface;
use ApiPlatform\Core\Exception\InvalidArgumentException;
use Doctrine\ORM\QueryBuilder;
use function strlen;
use function strpos;