Skip to content

Instantly share code, notes, and snippets.

View tarlepp's full-sized avatar
💭
örrr

Tarmo Leppänen tarlepp

💭
örrr
  • Pinja
  • Jyväskylä, Finland
View GitHub Profile
<?php
declare(strict_types = 1);
/**
* /src/Security/Provider/SecurityUserFactory.php
*
* @author TLe, Tarmo Leppänen <[email protected]>
*/
namespace App\Security\Provider;
security:
# https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords
password_hashers:
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'
# https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider
providers:
chain_user_provider:
chain:
providers: [security_user_provider, api_key_user_provider]
<?php
declare(strict_types = 1);
namespace App\Tests\Integration;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\Tools\SchemaValidator;
use Doctrine\Persistence\ManagerRegistry;
use PHPUnit\Framework\Attributes\TestDox;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
<?php
namespace App\Command;
use App\Entity\DateDimension;
use App\Repository\DateDimensionRepository;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
<?php
namespace App\Command;
use App\Entity\DateDimension;
use App\Repository\DateDimensionRepository;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
<?php
declare(strict_types = 1);
namespace App\Entity\Traits;
use DateTimeImmutable;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
public function foo()
{
$ids = ($this->createQueryBuilder())
->select('Images.id')
->innerJoin('Slider', 's')
->where('s.id = :yourSliderId')
->setParameter('yourSliderId', 123)
->getQuery()
->getArrayResult();
<?php
namespace App\EventSubscriber;
use App\Entity\User;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\Routing\Router;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
<?php
namespace App\EventSubscriber;
use App\Entity\User;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\Routing\Router;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
<?php
class Foo {
public function __construct($a = 5) {
var_dump($a);
}
}
new Foo($argv[1]);