Skip to content

Instantly share code, notes, and snippets.

<?php
// Inside ZendTest\Form\View\Helper\FormSelectTest
public function getScalarOptionsDataProvider()
{
return array(
array(array('string' => 'value')),
array(array('int' => 1)),
array(array('int-neg' => -1)),
array(array('hex' => 0x1A)),
The following tasks need to be done to finish the i18n component:
------------------------------------------------------------------------------
To finish translator:
- Add Xliff translation loader with plural support if possible, see:
https://wiki.oasis-open.org/xliff/XLIFF2.0/Feature/Plural%20Entries
- Add Tmx translation loader (identify if plural support is available)
- Complete unit tests
------------------------------------------------------------------------------
@cgmartin
cgmartin / gist:3004926
Created June 27, 2012 15:42
Float and NumberFormatter oddity
Old validators with Zend\Locale\Format, passing:
public function deLocaleStringsProvider()
{
return array(
array('1,3', true),
array('1000,3', true),
array('1.000,3', true),
array('1.3', false),
array('1000.3', false),
@cgmartin
cgmartin / pre-commit
Last active October 9, 2015 06:17
ZF2 Git pre-commit hook
#!/usr/bin/env php
<?php
/**
* .git/hooks/pre-commit
*
* This pre-commit hooks will check for PHP errors (lint), and make sure the
* code is PSR-2 compliant.
*
* Dependecy: PHP-CS-Fixer (https://github.com/fabpot/PHP-CS-Fixer)
*/
@cgmartin
cgmartin / gist:3687761
Created September 9, 2012 22:43
MultiCheckbox example
$multicbElement
->setAttributes(array(
'id' => 'my-multicb',
'options' => array(
'Option 1' => 'option1',
'Option 2' => array(
'value' => 'option2',
'labelAttributes' => array(
'class' => 'checkbox inline zf-green'
),
@cgmartin
cgmartin / FileUploadForm.php
Created September 28, 2012 04:51
ZF2 File Upload PR Examples
<?php
namespace Application\Form;
use Zend\Form\Form;
use Zend\Form\Element;
class FileUploadForm extends Form
{
public function __construct($name = null, $options = array())
@cgmartin
cgmartin / gittyup.sh
Last active January 28, 2017 21:58 — forked from EvanDotPro/gittyup.sh
Easily keep master in sync with upstream.
#!/bin/bash
####################################################################################
## ##
## gittyup() - Easily keep master in sync with upstream. ##
## ##
## Author: Evan Coury, http://blog.evan.pro/ ##
## URL: https://gist.github.com/1506822 ##
## Forked: https://gist.github.com/cgmartin/4046453 ##
## ##
## This bash function is a simple shortcut for keeping your local (and public ##
@cgmartin
cgmartin / gist:4156849
Created November 27, 2012 20:37
Create common factories with closures
protected function createTableFactory($tableName) {
return function($sm) use ($tableName) {
$tableGateway = $sm->get(ucfirst($tableName) . 'TableGateway');
$tableClass = ucfirst($tableName) . 'Table';
$table = new $tableClass($tableGateway);
};
}
protected function createTableGatewayFactory($tableName) {
return function($sm) use ($tableName) {
$dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
<?php
$this->navigation()->getPluginManager()->setAllowOverride(true)->setInvokableClass('menu', '\My\Helper');
// In Module.php
public function getViewHelperConfig()
{
return array(
// Change the Navigation View Helper plugins for ALL modules
'initializers' => array(
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/ZendSkeletonApplication for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Application\Controller;