Skip to content

Instantly share code, notes, and snippets.

@wms
wms / Form.php
Created August 6, 2012 10:32 — forked from toomuchpete/Form.php
Lithium Form Helper for Twitter Bootstrap
<?php
namespace app\extensions\helper;
class Form extends \lithium\template\helper\Form {
/**
* String templates used by this helper.
*
* @var array
<?php
use lithium\analysis\Logger;
use lithium\data\Connections;
Logger::config([
'default' => [
'adapter' => 'File',
'file' => function() { return "combined.log"; },
'format' => "{:timestamp} {:priority}\t{:message}\n"
<?php
Users::all(array(
'with' => 'Email',
'conditions' => array(
'User.deleted' => 0,
'Email.deleted' => 0
)
));
@wms
wms / gist:7749187
Last active December 30, 2015 00:19
public static function find($type, array $options = array())
{
// @todo: determine the Model to use instead of hard-coded 'User'
$options['conditions']['User.deleted'] = 0;
// @todo: add this condition for each 'With' relation instead of hard-coded 'Email'
$options['conditions']['Email.deleted'] = 0;
return parent::find($type, $options);
}
<?php
Groups::all([
'conditions' => [
'users' => '_id_'
// or...
'users' => ['_id']
]
]);
@wms
wms / -
Created May 28, 2014 16:13
diff --git a/data/model/Relationship.php b/data/model/Relationship.php
index 0e9c184..77619a5 100644
--- a/data/model/Relationship.php
+++ b/data/model/Relationship.php
@@ -208,7 +208,7 @@ class Relationship extends \lithium\core\Object {
$conditions = (array) $this->constraints();
foreach ($this->key() as $from => $to) {
- if (!isset($object->{$from})) {
+ if ($object->{$from} === null) {
@wms
wms / -
Created June 1, 2014 21:59
GAME
{
version = 0.23.5
Title = dev (SANDBOX)
Description = No description available.
linkURL =
linkCaption =
Mode = 0
Status = 1
scene = 5
@wms
wms / -
Created June 12, 2014 15:59
<?php
require 'vendor/autoload.php';
use polymer\core\App;
use polymer\data\Binding;
use lithium\core\Libraries;
Libraries::add('lithium');
Libraries::add('polymer', ['path' => '/home/warren/polymer/src/polymer']);
<?php
require 'vendor/autoload.php';
use polymer\core\App;
use polymer\data\Binding;
use lithium\core\Libraries;
Libraries::add('lithium');
Libraries::add('polymer', ['path' => '/home/warren/polymer/src/polymer']);
@wms
wms / gist:b8ce759636cdc0286eec
Created September 2, 2014 09:43
"Let's be pragmatic about this"
It's phrase we hear frequently these days. Some us say it, too. What does it even mean? I'm going to rant for a few minutes on the true meaning of 'pragmatism', and why it is a word that should be used with caution.
DISCLAIMER: Will contain swears and an unorthodox philosophical perspective.