Skip to content

Instantly share code, notes, and snippets.

View beberlei's full-sized avatar
💯

Benjamin Eberlei beberlei

💯
View GitHub Profile
@beberlei
beberlei / SQLFilter.php
Created July 21, 2011 10:46
First idea for SQL Filtering in Doctrine2
<?php
namespace Doctrine\ORM\Query\Filter;
abstract class SQLFilter
{
final public function __construct(Connection $conn);
final function setParameter($name, $value, $type);
<?php
use Symfony\Component\ClassLoader\UniversalClassLoader;
$loader = new UniversalClassLoader();
$loader->registerNamespaces(array(
'Symfony' => array(__DIR__.'/../vendor/symfony/src', __DIR__.'/../vendor/bundles'),
'Sensio' => __DIR__.'/../vendor/bundles',
'JMS' => __DIR__.'/../vendor/bundles',
));
@beberlei
beberlei / Util.php
Created June 23, 2011 09:25
Controllers as Services revisited
<?php
namespace Whitewashing\BlogBundle\Controller;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
*
*/
@beberlei
beberlei / ActiveEntity.php
Created June 19, 2011 11:11
Doctrine 2.2 Traits Preview
<?php
use Doctrine\ORM\EntityManager,
Doctrine\ORM\Configuration,
Doctrine\ORM\Mapping\ClassMetadata;
/**
* Active Entity trait
*
* Limitations: a class can only ever be assocaited with ONE active entity manager. Multiple entity managers
@beberlei
beberlei / Document.php
Created May 18, 2011 10:46
My Symfony2 File Upload workflow
<?php
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
/**
* @Entity
*/
class Document
{
@beberlei
beberlei / form_definitions.php
Created March 17, 2011 12:30
This Symfony Form Experimental Branch example does not use the DIC.
<?php
class MyFormType extends AbstractFormType
{
public function configure(FormBuilder $builder, array $options)
{
$builder->setDataClass("MyProject\FooEntity");
$builder->add('my.sub_form');
$builder->add('text', 'name', array('max_length' => 127, 'id' => 'foo'));
$builder->add('date', 'created');
@beberlei
beberlei / EventManagerBenchmark.php
Created March 7, 2011 19:32
Performance of bschussek/doctrine-common EventManager changes
<?php
require_once "Doctrine/Common/ClassLoader.php";
use Doctrine\Common\ClassLoader;
use Doctrine\Common\EventArgs;
use Doctrine\Common\EventManager;
$loader = new ClassLoader();
$loader->register();
@beberlei
beberlei / SimpleObjectHydrator.php
Created March 6, 2011 11:33
Hydrator that performs tasks of BasicEntityPersister.php
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
Using a static OptionSupport class that automatically writes options into properties AND fields extend it.
+ Options are set in the very beginning of the constructor
+ Concise
+ Error if option is not supported
+ Everything is a property, no special treatment of options
+ Good performance
+ Static options can be hidden from public access
- Private properties wouldn't work, access not allowed from parent classes.
@beberlei
beberlei / objectfreezer.patch
Created November 21, 2010 14:02
Patch to solve updating issues
diff --git a/Object/Freezer/Storage/CouchDB.php b/Object/Freezer/Storage/CouchDB.php
index f997e74..26abc11 100644
--- a/Object/Freezer/Storage/CouchDB.php
+++ b/Object/Freezer/Storage/CouchDB.php
@@ -72,6 +72,11 @@ class Object_Freezer_Storage_CouchDB extends Object_Freezer_Storage
protected $port;
/**
+ * @var array
+ */