Skip to content

Instantly share code, notes, and snippets.

View havvg's full-sized avatar

Toni Uebernickel havvg

View GitHub Profile
@havvg
havvg / base.json.twig
Created March 19, 2012 16:30
Symfony2 Twig JSON with JSONP
{% set jsonp = app.request.query.get('callback') %}
{% if jsonp %}{{ jsonp }}({% endif %}
{% block data %}{% if is_json|default(false) %}{{ data|raw }}{% else %}{{ data|json_encode|raw }}{% endif %}{% endblock %}
{% if jsonp %});{% endif %}
@havvg
havvg / propel-security-update.patch
Created April 20, 2012 14:37
Symfony2 Propel Security Update
diff --git a/app/config/security.yml b/app/config/security.yml
index 336f4d8..b346131 100644
--- a/app/config/security.yml
+++ b/app/config/security.yml
@@ -1,6 +1,6 @@
security:
encoders:
- Ormigo\Bundle\ReportingBundle\Security\UserProxy:
+ Ormigo\Bundle\ReportingBundle\Model\User:
algorithm: sha512
@havvg
havvg / OrmigoBundle.php
Created May 2, 2012 08:56
Example StreamRegistry registering Gaufrette streams in Symfony2
<?php
namespace Ormigo\Bundle\OrmigoBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Ormigo\Bundle\OrmigoBundle\DependencyInjection\Compiler\RegisterStreamsPass;
/**
<?php
namespace Ormigo\Behat\Context;
class SymfonyPropelAclContext extends BehatContext
{
/**
* @Given /^(?P<user>(user )?)"(?P<securityIdentity>[^"]+)" is (?P<granting>(granted|denied)) access (?P<mask>\d+) for (?P<class>(class )?)"(?P<objectIdentity>[^"]+)"( identified by "(?P<objectIdentifier>[^"]+)")?( on field "(?P<field>[^"]+)")?( with strategy "(?P<strategy>[^"]+)")?$/
*/
public function updateAce($user, $securityIdentity, $granting, $mask, $class, $objectIdentity, $objectIdentifier = null, $field = null, $strategy = 'any')
@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 / AbstractTest.php
Created June 5, 2012 12:58
PHPUnit mock interface extending Countable
<?php
namespace Ormigo\Tests;
abstract class AbstractTest extends \PHPUnit_Framework_TestCase
{
/**
* Apply expectations for a \Countable on a mock object.
*
* @see http://php.net/Countable
@havvg
havvg / schema.xml
Created June 6, 2012 12:53
Propel 1.6: Archivable with Versionable
<?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="entry" phpName="Entry">
<column name="id" type="integer" autoIncrement="true" primaryKey="true" />
<column name="value" type="varchar" size="255" required="true" />
<behavior name="archivable">
<parameter name="archive_on_insert" value="true" />
<parameter name="archive_on_update" value="true" />
<parameter name="archive_on_delete" value="true" />
@havvg
havvg / union-bounds.js
Created June 28, 2012 21:04
Google Maps union multiple polygon within BackboneJS view
var MapView = Backbone.View.extend({
/**
* Combine the boundaries of a list of Polygons into one boundary.
*
* The resulting boundary may for example be used in Map.fitBounds().
*
* @param {google.maps.Polygon[]}
*
* @return {google.maps.LatLngBounds}
*/
@havvg
havvg / MongoDBStorage.php
Created July 7, 2012 12:35
CraueFormFlowBundle MongoDBStorage
<?php
namespace Ormigo\Bundle\OrmigoBundle\Form\Storage;
use Craue\FormFlowBundle\Storage\StorageInterface;
/**
* This storage is implemented against native MongoDB.
*
* The benefit from this is the separated persistent of the form flow data from the session.
@havvg
havvg / AbstractController.php
Created July 9, 2012 20:09
Symfony2 Propel API response
<?php
namespace Sternenbund\Bundle\ApplicationBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller as BaseController;
use PropelObjectCollection;
abstract class AbstractController extends BaseController
{