Skip to content

Instantly share code, notes, and snippets.

<?php
namespace CommonBundle\Form\Type;
use CommonBundle\Entity\Country;
use Doctrine\Common\Persistence\ManagerRegistry;
use Geocoder\ProviderAggregator;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;
(function($) {
return $.fn.resetInput = function(callback) {
return this.each(function() {
var $el, type;
$el = $(this);
type = this.type;
switch (type) {
case 'select-one':
case 'select-multiple':
$el.find('option').each(function() {
(function($) {
return $.fn.extend({
findLabel: function() {
var matched;
matched = [];
this.each(function() {
var $label, $this, id;
$this = $(this);
id = $this.attr('id');
if (id != null) {
public function pruneEntitiesOlderThan($cutoffTime)
{
return $this->createQueryBuilder('w')
->delete()
->join('w.lot', 'l')
->where('l.sale_date < :cutoff_time')
->setParameter('cutoff_time', strtotime('-'.$cutoffTime.' day'))
->getQuery()
@ABM-Dan
ABM-Dan / EntityManager.php
Created September 12, 2016 22:27
Holy hardcoded system, Batman!
/**
* {@inheritDoc}
*/
public function newHydrator($hydrationMode)
{
switch ($hydrationMode) {
case Query::HYDRATE_OBJECT:
return new Internal\Hydration\ObjectHydrator($this);
<?php
use Silex\Application;
use Demo\Repository\PostRepository;
$app = new Application();
$app['dao.article'] = function() {
// $app['db'] def and $app['dao.user'] defined elsewhere
$articleDAO = new ArticleDAO($app['db']);
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
throw new \RuntimeException('This migration is not reversible');
<?php
namespace CommonBundle\Service;
use Symfony\Component\Templating\EngineInterface;
class SendMail extends \Swift_Message
{
/**
* @var string
<?php
namespace App\Services\Rest\Helper;
use App\Utils\JSON;
use Symfony\Component\HttpFoundation\Request as HttpFoundationRequest;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\HttpException;
<?php
namespace CommonBundle\Twig;
use Symfony\Bridge\Twig\Form\TwigRenderer;
use Symfony\Component\Form\FormView;
class FormSubmitExtension extends \Twig_Extension
{
/**