Skip to content

Instantly share code, notes, and snippets.

@frodosghost
frodosghost / ManyToEntityTransformer
Created April 12, 2014 21:58
Data Transformer: Many to Many for Entity Field
<?php
namespace Acme\DemoBundle\Form\DataTransformer;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\PersistentCollection;
use Doctrine\Common\Collections\ArrayCollection;
use Symfony\Component\Form\DataTransformerInterface;
use Symfony\Component\Form\Exception\TransformationFailedException;
@frodosghost
frodosghost / keybase.md
Created February 3, 2020 00:10
Keybase

Keybase proof

I hereby claim:

  • I am frodosghost on github.
  • I am frodosghost (https://keybase.io/frodosghost) on keybase.
  • I have a public key ASCjXhben2bdA5Zk-N27SCbBCDm127WRyO2gkmryZ-K9dAo

To claim this, I am signing this object:

@frodosghost
frodosghost / CorsListener.php
Created April 14, 2016 02:35
CORS Listener and Handling with Symfony2
<?php
namespace AppBundle\EventListener;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
@frodosghost
frodosghost / bubblesort.php
Created May 30, 2018 03:51
Sorting Algorithms using PHP
<?php
/**
* BubbleSort in PHP
*
* @param array $data
* @return array
*/
function bubblesort ($data) {
$length = count($data);
@frodosghost
frodosghost / LegacySessionStorage.php
Last active April 28, 2016 12:11 — forked from tcz/LegacySessionStorage.php
Bridging the gap between standard $_SESSION and HttpFoundation Session with Silex.
<?php
namespace Session\Storage;
use Symfony\Component\HttpFoundation\Session\Storage\PhpBridgeSessionStorage;
/**
* Session storage that avoids using _sf2_attributes subkey in the $_SESSION
* superglobal but instead it uses the root variable.
*
@frodosghost
frodosghost / ScriptHandler.php
Last active March 24, 2016 16:12
Dependency Inception: Composer, Installing NPM, Installing Bower
<?php
namespace AppBundle\Composer;
use Composer\Script\Event;
use Symfony\Component\Process\Process;
/**
* Script for Running NPM as part of Composer Update
*
@frodosghost
frodosghost / ScriptHandler.php
Last active March 24, 2016 16:08
Dependency Inception: Installing Bower dependencies with Composer
<?php
namespace AppBundle\Composer;
use Composer\Script\Event;
use Symfony\Component\Process\Process;
/**
* Script for Running NPM as part of Composer Update
*
@frodosghost
frodosghost / app.js
Created February 19, 2016 19:50
AngularJS and Twig Templates
var antelopeApp = angular.module('antelopeApp', [
'ngRoute',
'antelopeControllers'
]).config(function($interpolateProvider){
$interpolateProvider.startSymbol('{[{').endSymbol('}]}');
});
@frodosghost
frodosghost / CommentType.php
Last active December 11, 2015 20:19
Base form code for saving multiple classes of data with Symfony2. This is for Jerome.
<?php
namespace Your\Product\Bundle\Form\CommentType;
use Your\Product\Bundle\Form\UserType;
class CommentType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
@frodosghost
frodosghost / EditFormSubscriberTest.php
Created May 9, 2012 11:25
Unit Testing Symfony2 Forms
<?php
namespace Manhattan\Bundle\GalleryBundle\Tests\Form;
use Symfony\Component\Form\FormFactory;
use Symfony\Component\Form\Extension\Core\CoreExtension;
use Manhattan\Bundle\GalleryBundle\Form\EventListener\EditFormSubscriber;
class EditFormSubscriberTest extends \PHPUnit_Framework_TestCase