Skip to content

Instantly share code, notes, and snippets.

View MichaelGooden's full-sized avatar

Michael Gooden MichaelGooden

  • Port Elizabeth, South Africa
View GitHub Profile
@MichaelGooden
MichaelGooden / jqm-patch.md
Created June 2, 2012 13:24 — forked from eddiemonge/jqm-patch.md
jQuery Mobile Bug Patching

Tips for jQuery Mobile Bug Patching

Requirements:

PHP Web Server

Some common ones:

//Module.php
<?php
namespace VendorName\LibraryName;
class Module
{
public function getAutoloaderConfig()
{
return array(
<?php
// Hostname route
'front-ent' => array(
'type' => 'Hostname',
'options' => array(
'route' => ':subdomain.' . BASE_DOMAIN,
'constrains' => [
'subdomain' => '[a-zA-Z0-9\-]+',
],
'defaults' => array(
<?php
'logger1' => function ($sm) {
$logger = new Zend\Log\Logger();
$writer = new Zend\Log\Writer\Stream(APP_PATH . '/data/logs/app.log');
$formatter = new Zend\Log\Formatter\Simple(
'%timestamp% %priorityName% (%priority%): %message%',
'd.m.Y H:i:s');
$writer->setFormatter($formatter);
$logger->addWriter($writer);
<?php
'factories' => array(
'My\Service\BankAccount' => function($serviceManager) {
$bankAccountService = new My\Service\BankAccount($serviceManager->get('Doctrine\ORM\EntityManager')->getRepository('My\Entity\BankAccount'));
return $bankAccountService;
},
),
<?php
/* existing stuffs */
class Module
{
/* more existing stuffs */
public function getServiceConfig()
{
return array(
@MichaelGooden
MichaelGooden / gist:6304297
Created August 22, 2013 07:53
Simple ZF2 CLI scripts.
<?php
/**
* This makes our life easier when dealing with paths. Everything is relative
* to the application root now.
*/
chdir(dirname(__DIR__));
// Setup autoloading
require 'init_autoloader.php';
<?php
/**
*
*/
public function myTestWithNumber()
{
// Mock Service:
$mockService = $this->getMockBuilder('myService')
->disableOriginalConstructor()
@MichaelGooden
MichaelGooden / route-layouts.php
Last active December 22, 2015 03:39
Set layout from route param.
<?php
public function onBootstrap(MvcEvent $e)
{
$em = $e->getApplication()->getEventManager();
$em->attach('dispatch', array($this, 'chooseLayout'));
}
public function chooseLayout(MvcEvent $e)
{
$matches = $e->getRouteMatch();
@MichaelGooden
MichaelGooden / gist:6520254
Last active December 22, 2015 19:29 — forked from Goram/gist:6520240
<?php
$form = new Form();
$form->setAttribute('method', 'post');
$fieldset1 = new Fieldset('user');
$fieldset1->setOptions(array(
'use_as_base_fieldset' => true
));