Skip to content

Instantly share code, notes, and snippets.

View kriswallsmith's full-sized avatar

Kris Wallsmith kriswallsmith

  • Portland, Oregon USA
  • 22:48 (UTC -08:00)
View GitHub Profile
<?php
class BaseDoctrineForm extends sfFormDoctrine
{
public function __construct($object = null, $options = array(), $CSRFSecret = null)
{
parent::__construct($object, $options, $CSRFSecret);
// tell the widget schema which fields are required
$this->widgetSchema->addOption('required_fields', $this->getRequiredFields());
<?php
class BaseDoctrineForm extends sfFormDoctrine
{
public function __construct($object = null, $options = array(), $CSRFSecret = null)
{
parent::__construct($object, $options, $CSRFSecret);
// tell the widget schema which fields are required
$this->widgetSchema->addOption(
<?php
class BaseDoctrineForm extends sfFormDoctrine
{
// ...
protected function getRequiredFields(sfValidatorSchema $validatorSchema = null,
$format = null)
{
if (is_null($validatorSchema))
<?php
class RequiredLabelsFormatterTable extends sfWidgetFormSchemaFormatterTable
{
protected
$requiredLabelClass = 'required';
public function generateLabel($name, $attributes = array())
{
// loop up to find the "required_fields" option
<?php
class BaseDoctrineForm extends sfFormDoctrine
{
public function __construct($object = null, $options = array(), $CSRFSecret = null)
{
// ...
$this->widgetSchema->addFormFormatter('table',
new RequiredLabelsFormatterTable($this->widgetSchema)
#!/usr/bin/env php
<?php
$username = $argv[1];
$password = $argv[2];
// copied from http://fabien.potencier.org/article/20/tweeting-from-php
$context = stream_context_create(array(
'http' => array(
'method' => 'POST',
<?php
// Doctrine/DataDict/Mysql.php
if ($length <= 1) {
return 'TINYINT';
} elseif ($length == 2) {
return 'SMALLINT';
} elseif ($length == 3) {
return 'MEDIUMINT';
} elseif ($length == 4) {
<?php
// config/ProjectConfiguration.class.php
class ProjectConfiguration extends sfProjectConfiguration
{
protected
$masterConnection = null,
$slaveConnection = null;
public function initializeConnections()
<?php
class ConnectionListener extends Doctrine_Connection
implements Doctrine_EventListener_Interface
{
protected
$master = null,
$slave = null;
public function __construct(PDO $master, PDO $slave)
<?php
// config/ProjectConfiguration.class.php
class ProjectConfiguration extends sfProjectConfiguration
{
// ...
public function configureDoctrineConnection(Doctrine_Connection $conn)
{
$listener = new ConnectionListener(