Skip to content

Instantly share code, notes, and snippets.

View Alan01252's full-sized avatar

Alan Hollis Alan01252

View GitHub Profile
@Alan01252
Alan01252 / sample.php
Created June 14, 2012 17:41
Repository code suggestion
<?php
//These classes instead of being in customRepositories are now in /bundles/myBundle/model/
class Staff extends Repository
{
}
class Account extends Repository
{
@Alan01252
Alan01252 / phpbitmask.php
Created June 19, 2012 19:02
PHP Bitmasks
<?php
//Define our bitmask
define("allowEverythingBitmask",1); //In binary 0001
//Our user
class User {
private $permissionBitmask = 1; //In binary 0001
public function setPermissionBitmask($bitmask)
{
$this->permissionBitmask = $bitmask;
@Alan01252
Alan01252 / companyjson.js
Created June 25, 2012 13:59
CompanyJson
{
"name": "Baring Asset Management",
"phone": "0987654321",
"quaterOneRevenue": "1000",
"yearToDateRevenue": "200000"
},
"contact": {
"0": {
"createdAt": ISODate("2012-07-02T14: 42: 02.924Z"),
"updatedAt": ISODate("2012-07-02T14: 42: 02.924Z"),
"key": "directTelephoneNumber",
"value": "01252876850",
"_id": ObjectId("4ff1b33a37b48fac6b0001bb")
}
},
print_r($company);
Entity\Company Object
(
[attributes:protected] => Array
(
[_id] => 4ff2ae675211d54012000142
[comments] => test
[createdAt] => DateTime Object
<script>
var test = {
idAccount:121,
idTier:1,
update:function(req,res){
if(typeof(this.idAccount) != 'undefined') {
var should = require('should'),
symbleApi = require('./lib/symbleApi.js');
var BaseTest = {
_error:null,
_response:null,
_body:null,
_json:null,
<?php
public function getContactByKey($key) {
$collection = null;
if($this->getContact()){
$collection = $this->getContact()->filter(function($element) use($key) {return ($element->getKey() === $key) ? $element : null;});
if($collection->current())
return $collection->current()->getValue();
}
return null;
var account_controller = Object.create(global.Crud,
{
/**
* Overload the create method
*/
'create': function(req,res){
Crud.create(req,res,function(instance) {
if(typeof instance == "object")
socket.send('newActivity', {'instance' : instance, 'req': req, 'res' :res});
});
<?php
public function saveWithEmbededDocuments() {
$this->setContacts($this->makeCollection(self::$contactKeys, 'contacts', 'value'));
$this->setFinancials($this->makeCollection(self::$financialKeys, 'financials', 'floValue'));
if(!$this->save()) {
return false;
}