Skip to content

Instantly share code, notes, and snippets.

View baldurrensch's full-sized avatar

Baldur Rensch baldurrensch

  • Sourceability LLC
  • Irvine, CA
View GitHub Profile
@baldurrensch
baldurrensch / services.xml
Created November 2, 2012 21:55
AbstractAuthenticationListener
<service id="rest.security.authentication.listener" class="Acme\TestBundle\Security\Firewall\RestListener" public="false">
<argument type="service" id="security.context"/>
<argument type="service" id="security.authentication.manager" />
<argument type="service" id="doctrine"/>
<argument type="service" id="event_dispatcher" />
<argument type="service" id="security.authentication.success_handler" />
</service>
@baldurrensch
baldurrensch / LoadProductData.php
Created November 2, 2012 20:21
Sample Fixture
<?php
namespace Acme\DemoBundle\DataFixtures\ORM;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Acme\DemoBundle\Entity\Product;
/**
diff --git a/.puppet/modules/hautelook/manifests/init.pp b/.puppet/modules/hautelook/manifests/init.pp
index 19b88fd..46fadb1 100644
--- a/.puppet/modules/hautelook/manifests/init.pp
+++ b/.puppet/modules/hautelook/manifests/init.pp
@@ -69,6 +69,21 @@ class hautelook {
require => Package["memcached"]
}
+ package { "mysql-server":
+ ensure => installed,
@baldurrensch
baldurrensch / Controller.php
Created October 26, 2012 20:28
Problem getting relations working with HateoasBundle
<?php
// This is just copy pasted in here.
class Controller {
public function getMemberAction($memberId)
{
$country = $this->getDoctrine()->getRepository('HautelookApiBundle:Countries')->find('US');
$serializedCountry = $this->get('serializer')->serialize($country, 'json');
<?php
// ...
class SessionStorageChain implements \SessionHandlerInterface
{
private $readStorageChain;
private $writeStorageChain;
private $container;
@baldurrensch
baldurrensch / KernelAwareTest.php
Created September 17, 2012 16:32 — forked from jakzal/KernelAwareTest.php
KernelAwareTest
<?php
require_once dirname(__DIR__).'/../../../../app/AppKernel.php';
/**
* Test case class helpful with Entity tests requiring the database interaction.
* For regular entity tests it's better to extend standard \PHPUnit_Framework_TestCase instead.
*/
abstract class KernelAwareTest extends \PHPUnit_Framework_TestCase
{
@baldurrensch
baldurrensch / feistel.php
Created September 12, 2012 22:58
Feistel Hash
<?php
/**
* This function computes a hash of an integer. This can be used to not expose values to a customer, such as
* not giving them the id value for passing them to URLs. This algorithm is a bidirectional encryption (Feistel cipher) that maps
* the integer space onto itself.
*
* @link http://wiki.postgresql.org/wiki/Pseudo_encrypt Algorithm used
* @link http://en.wikipedia.org/wiki/Feistel_cipher Wikipedia page about Feistel ciphers
* @param int $value
@baldurrensch
baldurrensch / gist:3669417
Created September 7, 2012 20:38
Simple field example
<?php
// Of course you also need your Doctrine Annotations
class Example
{
protected $firstName;
protected $lastName;
protected $username;
public function setFirstName($firstName)
public function set(array $params)
{
foreach ($params as $key => $value) {
$this->$key = $value;
}
}
{% block choice_widget %}
{% spaceless %}
<div class="control-group">
{% for child in form %}
{{ form_label(child) }}
{{ form_widget(child) }}</label>
{% endfor %}
</div>