Skip to content

Instantly share code, notes, and snippets.

View havvg's full-sized avatar

Toni Uebernickel havvg

View GitHub Profile
@havvg
havvg / MyModel.php
Created December 8, 2011 12:53
true MySQL ENUM with Propel
<?php
class MyModel extends BaseMyModel
{
public function hydrate($row, $startcol = 0, $rehydrate = false)
{
try {
$this->id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
$this->type = ($row[$startcol + 1] !== null) ? $row[$startcol + 1] : null;
$this->resetModified();
<?php
namespace Foo
{
class Foo
{
public function getRandomValue()
{
return 42; // chosen by fair dice roll
}
@havvg
havvg / .gitconfig
Created December 20, 2011 15:42
git pretty history
[alias]
ph = log --graph --pretty=pretty-history --abbrev-commit --date=relative
[pretty]
pretty-history = format:%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset
@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 / .gitconfig
Created December 21, 2011 16:52
git fast-forward
[alias]
ff = pull --ff-only
@havvg
havvg / DemoController.php
Created January 10, 2012 13:36
Impersonating a User in Symfony2
<?php
namespace Acme\DemoBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Security\Core\Role\SwitchUserRole;
@havvg
havvg / PropelMigration_1326293132.php
Created January 11, 2012 17:13
Symfony2 Propel ACL Migration
<?php
/**
* Data object containing the SQL and PHP code to migrate the database
* up to version 1326293132.
* Generated on 2012-01-11 15:45:32 by havvg
*/
class PropelMigration_1326293132
{
@havvg
havvg / SearchResultRoute.class.php
Created January 31, 2012 22:10
symfony 1.4 custom route using multiple propel models
<?php
/**
* The route for matching search result URLs.
*
* Available parameters within the route:
* * product_category The slug of a product category.
* * vendor The slug of a vendor.
* * search The search string on a products name.
*
@havvg
havvg / services.yml
Created February 7, 2012 21:06
Symfony2 PropelPDO as a Service
services:
your_service_name:
class: PropelPDO
factory_class: Propel
factory_method: getConnection
arguments:
- "connection_name"
@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;