Skip to content

Instantly share code, notes, and snippets.

View jmather's full-sized avatar

Jacob Mather jmather

View GitHub Profile
<?php
require_once dirname(__FILE__).'/../../../../../test/phpunit/bootstrap/unit.php';
class unit_majaxMediaFilenameBuilderTest extends sfPHPUnitBaseTestCase
{
protected $builder = null;
protected function setUp()
{
@jmather
jmather / sample.yml
Created March 19, 2011 14:01
How to do a double-ref
User:
columns:
name: { type: string(255), notnull: true }
Post:
columns:
content: { type: clob }
author_id: { type: integer }
editor_id: { type: integer }
relations:
@jmather
jmather / converter.php
Created March 30, 2011 14:34
Convert KJB to array
<?php
function processFile($file)
{
$file = file_get_contents($file);
$book = array();
list($junk, $cont) = explode('<hr>', $file, 2);
protected $event = null;
public function onSecurityInteractiveLogin(InteractiveLoginEvent $event)
{
$this->event = $event;
$username = $this->getUsername();
$session = $this->getSession();
$this->setFlash($session, $username);
}
protected function getUsername()
<?php
namespace Knowhow\UserBundle\Listeners;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
class LoginListener implements EventSubscriberInterface
{
<?php
class SomeForm
{
// ... snip ...
public function saveEmbeddedForms($con = null, $forms = null)
{
<?php
/**
* Photo filter form.
*
* @package cms
* @subpackage filter
* @author JMather
* @version SVN: $Id: sfDoctrineFormFilterTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
*/
$script = "
<script type=\"text/javascript\">
(function() {
var id = '$id';
var augment_id = id+'_messages';
var url = '$splitter_url';
var callUpdateTimeout = null;
var updateFunction = function() {
@jmather
jmather / SiteListBuilder.php
Created August 14, 2011 06:43
How to link a many-to-many properly in Symfony2 with Sonata Admin Bundle
<?php
namespace Majax\PortalBundle\Builder;
use Symfony\Bundle\DoctrineBundle\Registry;
class SiteListBuilder {
/** @var \Symfony\Bundle\DoctrineBundle\Registry */
private $orm;
public function __construct($orm)
public function isEmpty()
{
$method = new \ReflectionMethod(
$this->_objectOrClassName,
$this->_methodName
);
list(,$path,) = explode(PHP_EOL, (string)$method);
preg_match('/(@@ )(.*\.php)( )(\d+)(\D*)(\d+)/', $path, $matches);
list ($path, $start, $end) = array(
$matches[2], $matches[4], $matches[6]