Skip to content

Instantly share code, notes, and snippets.

View havvg's full-sized avatar

Toni Uebernickel havvg

View GitHub Profile
@havvg
havvg / Firewall.js
Last active March 1, 2024 11:52
ExtJS 6: JSON Web Token API Login with Promises
Ext.define('App.security.Firewall', {
singleton: true,
requires: [
'App.security.TokenStorage'
],
isLoggedIn: function() {
return null !== App.security.TokenStorage.retrieve();
},
@havvg
havvg / AbstractTest.php
Created June 1, 2012 14:22
PHPUnit mock Interface extending Iterator
<?php
namespace Ormigo\Tests;
abstract class AbstractTest extends \PHPUnit_Framework_TestCase
{
/**
* Apply expectations for an \Iterator on a mock object.
*
* @see http://php.net/Iterator
@havvg
havvg / ajax-form.js
Created August 1, 2012 13:20
jQuery AJAX form submit with Twitter Bootstrap modal
jQuery(function($) {
$('form[data-async]').live('submit', function(event) {
var $form = $(this);
var $target = $($form.attr('data-target'));
$.ajax({
type: $form.attr('method'),
url: $form.attr('action'),
data: $form.serialize(),
@havvg
havvg / symfony.phpunit.xml
Created December 3, 2010 19:36
An example PHPUnit configuration file for symfony projects running on 512MB phpUnderControl server
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
colors="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
stopOnFailure="true">
<filter>
<blacklist>
@havvg
havvg / Builder.php
Created February 8, 2012 15:51
Symfony2 KnpMenu TwitterBootstrap switch user menu
<?php
namespace Ormigo\Bundle\BackofficeBundle\Menu;
use Knp\Menu\FactoryInterface;
use Symfony\Component\DependencyInjection\ContainerAware;
use Ormigo\Bundle\UserBundle\Model\User\UserQuery;
use Symfony\Component\Security\Core\Role\SwitchUserRole;
@havvg
havvg / git-bisect-phpunit.sh
Created December 20, 2011 22:07
git bisect phpunit wrapper
#!/bin/bash
phpunit
EXIT_CODE="$?"
if [ $EXIT_CODE -eq "255" ]; then
# Wrapping the error code to 1, so bisect marks this build as "bad" and continues.
exit 1
fi
@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
@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 / schema.xml
Created August 13, 2012 14:35
Propel 1.6: Sluggable with I18n
<?xml version="1.0" encoding="UTF-8"?>
<database name="default" defaultIdMethod="native" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://xsd.propelorm.org/1.6/database.xsd">
<table name="country">
<column name="id" type="integer" autoIncrement="true" primaryKey="true" />
<column name="iso_code" type="char" size="2" required="true" />
<column name="name" type="varchar" size="255" required="true" primaryString="true" />
<behavior name="i18n">
<parameter name="i18n_columns" value="name, url" />
<parameter name="default_locale" value="de_DE" />
@havvg
havvg / ZendKernel.php
Created December 29, 2016 20:50
StackPHP Example: Symfony + Zend Framework (ZF1)
<?php
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\TerminableInterface;
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
class ZendKernel implements HttpKernelInterface, TerminableInterface