Skip to content

Instantly share code, notes, and snippets.

View adamsafr's full-sized avatar
🏠

Adam Sapraliev adamsafr

🏠
View GitHub Profile
@adamsafr
adamsafr / CountryRepository.php
Last active October 28, 2024 05:51
Doctrine: Union with JOIN example
<?php
namespace AppBundle\Repository;
use AppBundle\Entity\Country;
use AppBundle\Entity\CountryTranslation;
use Doctrine\ORM\EntityRepository;
use Doctrine\ORM\Query\ResultSetMapping;
use Doctrine\ORM\QueryBuilder;
@adamsafr
adamsafr / AbstractBySlugAndActiveSearcher.php
Last active March 31, 2023 09:03
Symfony: ParamConverter usage example
<?php
namespace FrontEndBundle\Request\ParamConverter;
use Doctrine\Bundle\DoctrineBundle\Registry;
use Doctrine\Common\Persistence\ObjectRepository;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
abstract class AbstractBySlugAndActiveSearcher
@adamsafr
adamsafr / EntityHiddenType.php
Created September 7, 2017 08:49
[php] Hidden field for Symfony2 entities
<?php
namespace Dpn\ToolsBundle\Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Doctrine\Common\Persistence\ObjectManager;
use Dpn\ToolsBundle\Form\DataTransformer\EntityToIdTransformer;
SELECT DATE_ADD('2016-08-02', INTERVAL help_topic_id DAY) as mydate
FROM mysql.help_topic order by help_topic_id asc limit 14