Skip to content

Instantly share code, notes, and snippets.

View jwage's full-sized avatar
💭
I am still here.

Jonathan H. Wage jwage

💭
I am still here.
View GitHub Profile
class DDC1020OrderEventListener
{
public function preUpdate(LifecycleEventArgs $args)
{
$order = $args->getEntity();
$order->tax = 100;
$em = $args->getEntityManager();
$uow = $em->getUnitOfWork();
$uow->recomputeSingleEntityChangeSet(
$em->getClassMetadata(get_class($order)),
public function register()
{
// ...
$user = new User();
$form = new RegisterForm('register', $user, $validator);
$form->bind($request, $user);
if ($form->isValid()) {
$newUser = new NewUser($user);
@jwage
jwage / Doctrine MongoDB ODM Tail Cursor Command Daemon
Created February 6, 2011 00:01
This is a Symfony2 Doctrine MongoDB ODM Tail Cursor console command. It can be ran as a daemon and it will tail a mongodb collection with a tailable cursor and process the documents with a given service as the "processor". You must specify the document, t
<?php
namespace MyCompany\Bundle\MyBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\HttpFoundation\Request;
<?php
// create SoftDeleteManager
$sdm = new SoftDeleteManager($dm);
// Soft delete a few documents
$sdm->delete($user);
$sdm->delete($product);
$sdm->delete($seller);
server {
expires 1M;
listen 80;
root /var/www/vhosts/sociallynotable.com/socially-notable/web;
index index.php;
if ($host ~* ^www.(.*)) {
set $remove_www $1;
rewrite ^(.*)$ http://$remove_www$1 permanent;
}
sfGuardUser:
user_employee1:
username: employee1
password: changeme
Department:
dev:
title: Development
Employee:
Employee:
columns:
id:
type: integer
primary: true
autoincrement: true
sf_guard_user_id:
type: integer
start_date:
type: date
@jwage
jwage / gist:767205
Created January 5, 2011 23:17 — forked from cwage/gist:767203
Employee:
columns:
id:
type: integer
primary: true
autoincrement: true
sf_guard_user_id:
type: integer
name:
type: string(155)
if ($filter !== null) {
if ($filter->current) {
$expr = $qb->expr()->field('special.startDate')->lte($date)
->field('special.endDate')->gte($date);
$qb->addOr($expr);
}
if ($filter->upcoming) {
$expr = $qb->expr()->field('special.startDate')->gt($date);
$qb->addOr($expr);
}
$path = sfConfig::get('sf_upload_dir').'/tracks/';
$fp = fopen($path.$track->getTeaserFile(), 'a+');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.musicalturk.com/teaser.php');
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_BUFFERSIZE, 256);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible;)");
curl_setopt($ch, CURLOPT_POST, true); $post = array(