Skip to content

Instantly share code, notes, and snippets.

View fitzagard's full-sized avatar

Fitz Agard fitzagard

View GitHub Profile
@fitzagard
fitzagard / validator.php
Last active November 1, 2016 00:57
li3 Validation Example Using Multiple Form Inputs
/**
* Example: Sometimes you need a bit more validation power on form inputs. For instance, a form validation
* may be dependpent on multiple inputs and advanced testing.
*
* The example below shows the power of $options array. That's where all your form inputs along with some other custom
* parts will be stored. The key to getting access to your form POST data is through `values` which lives in $options.
* The extract method pulls out the 'values' array providing access to the POST data.
*
* In this particular example were trying to check if the field input `acronym` is unique among a list of cities in MongoDB.
*
@fitzagard
fitzagard / Model.php
Created October 20, 2013 17:05
Lithium MongoDB Session Extension
<?php
/**
* Lithium: the most rad php framework
*
* @copyright Copyright 2010, Union of RAD (http://union-of-rad.org)
* @license http://opensource.org/licenses/bsd-license.php The BSD License
*/
namespace app\extensions\adapter\session;
<?php
namespace app\models;
class Base extends \lithium\data\Model {
/**
* This method gives direct access to the MongoDB collection object from any
* model that extends the Base Model.
@fitzagard
fitzagard / gist:3057526
Created July 6, 2012 01:44
Curl using Li3
<?php
namespace app\controllers;
use lithium\net\socket\curl;
class FeedsController extends \lithium\action\Controller {
protected $_li3 = array(
'scheme' => 'https',
'host' => 'api.github.com/repos/fitzagard/li3_sublime/commits',
@fitzagard
fitzagard / gist:1419668
Created December 1, 2011 20:38
Li3 Filter Example
class Base extends \lithium\data\Model {
public $validates = array();
public static function __init(array $options = array()){
parent::__init($options);
/**
* Add created date to every document created
*/
static::applyFilter('create', function($self, $params, $chain){