Skip to content

Instantly share code, notes, and snippets.

View havvg's full-sized avatar

Toni Uebernickel havvg

View GitHub Profile
@havvg
havvg / content_with_sidebar.html.twig
Created September 21, 2012 09:59
Twig embed with Twitter Bootstrap page layouts
<div class="row-fluid">
{% if content_width is not defined %}
{% set content_width = 8 %}
{% endif %}
<div class="span{{ content_width }}">
{% block content %}{% endblock %}
</div>
{% if sidebar_width is not defined %}
{% set sidebar_width = 4 %}
{% endif %}
@havvg
havvg / AsynchronousEventDispatcher.php
Last active January 20, 2021 07:04
Asynchronous Event Dispatcher
<?php
namespace Ormigo\Component\EventDispatcher;
use Symfony\Component\Console\ConsoleEvents;
use Symfony\Component\Console\Event\ConsoleTerminateEvent;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
@havvg
havvg / FieldWhiteListAwareInterface.php
Created October 12, 2012 15:09
Propel ModelCriteriaSubscriber
<?php
namespace Ormigo\Component\Pager;
interface FieldWhiteListAwareInterface
{
/**
* Returns a list of columns valid for sorting.
*
* @return string[]
@havvg
havvg / DummyType.php
Created October 18, 2012 12:35
Propel ModelType collection
<?php
namespace Form\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
class DummyType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
@havvg
havvg / JasmineHandler.php
Created October 31, 2012 16:57
Symfony2 + Jasmine = JasmineHandler
<?php
namespace Ormigo\Tests;
use Symfony\Component\Templating\EngineInterface;
use Symfony\Component\HttpFoundation\Response;
class JasmineHandler
{
protected $templating;
@havvg
havvg / .gitconfig
Created November 2, 2012 15:44
octopus merge pull requests from upstream
[remote "origin"]
fetch = +refs/pull/*/head:refs/gh-pull/remotes/origin/*
[remote "upstream"]
fetch = +refs/pull/*/head:refs/gh-pull/remotes/upstream/*
@havvg
havvg / CatchmentAreaType.php
Created November 23, 2012 13:19
Dynamic validation_groups based on choice value
<?php
namespace Ormigo\Bundle\OrmigoBundle\Form\CatchmentArea\Type;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
use Ormigo\Bundle\OrmigoBundle\Form\CatchmentArea\DataTransformer\CatchmentAreaModelTransformer;
<?php
$count = 5;
$values = range(20, 50);
var_dump(array_values(array_intersect_key($values, array_flip(array_rand($values, $count)))));
/* Example output
array(5) {
[0]=>
@havvg
havvg / AbstractFunctionalTest.php
Created November 30, 2012 09:52
Symfony2 controller test "304 - Not Modified"
<?php
namespace Ormigo\Tests;
use DateTime;
use DateTimeZone;
use Symfony\Bundle\FrameworkBundle\Client;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\HttpKernelInterface;
@havvg
havvg / DateRange.php
Last active October 24, 2021 10:33
Symfony2: poor man's date_range form type
<?php
namespace Ormigo\Bundle\OrmigoBundle\Form\Model;
use DateTime;
class DateRange
{
/**
* @var DateTime