Skip to content

Instantly share code, notes, and snippets.

View TomHAnderson's full-sized avatar
🏠
Working from home

Tom H Anderson TomHAnderson

🏠
Working from home
View GitHub Profile
@TomHAnderson
TomHAnderson / gist:11008752
Last active August 29, 2015 14:00
Authentication sub-topics are covered by section header
The Authentication <li><a which toc.phtml looks for is split across lines and
not found by the non-css preg selector.
This section of TOC.md
Authentication and Authorization
--------------------------------
- [Introduction](/auth/intro.md)
- [Authentication](/auth/authentication.md)
// This function cannot return an accurate answer
function isAllyByCrosscheckIdenties($person)
{
// If this person identifies as any of the following
// make assumption they support equal rights for everyone
foreach ($person->getSexualIdentities() as $identity) {
switch ($identity) {
case 'gay':
case 'lesbian':
case 'bisexual':
<?php
// Step 1: create form through annotations
$test = new TestEntity();
$builder = new AnnotationBuilder();
$form = $builder->createForm($test);
$viewModel = new ViewModel();
// Step 2: populate select elements
@TomHAnderson
TomHAnderson / gist:5832767
Created June 21, 2013 17:17
Simple entity w/ getArrayCopy & ExchangeArray with associations
<?php
namespace DbLoadCd\Entity;
use Zend\Form\Annotation as Form;
use Zend\InputFilter\InputFilter;
use Doctrine\ORM\Event\LifecycleEventArgs;
/**
* @Form\Hydrator("Zend\Stdlib\Hydrator\ObjectProperty")
@TomHAnderson
TomHAnderson / gist:5827533
Last active December 18, 2015 18:39
Controller with entity returning associations as part of getArrayCopy(); create, edit
<?php
namespace Application\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Zend\Form\Annotation\AnnotationBuilder;
use DbLoadCd\Entity\Test as TestEntity;
use Application\Service\Security;
@TomHAnderson
TomHAnderson / gist:5825419
Created June 20, 2013 18:41
Controller with relations as part of exchangeArray
if ($form->isValid()) {
$data = $form->getData();
$data['project'] = $project;
$data['owner'] = $em->getRepository('AppleConnect\Entity\User')->find($data['owner']);
$data['operator'] = $em->getRepository('AppleConnect\Entity\User')->find($data['operator']);
$test->exchangeArray($data);
@TomHAnderson
TomHAnderson / gist:5825379
Created June 20, 2013 18:38
Form submission without relations set in exchangeArray
$builder = new AnnotationBuilder();
$form = $builder->createForm($test);
...
$form->get('testResult')->setValueOptions(
$this->doctrineSelectOptions(
'DbLoadCd\Entity\TestResult',
[],
['name' => 'ASC'],
['Application\Service\Security', 'view']
)
public function init(ModuleManager $moduleManager)
{
$this->getEventManager()->getSharedManager()->attach(
array('Zend\Mvc\Application'), // context
array(MvcEvent::EVENT_DISPATCH), // event 'dispatch'
array($this, 'checkSession') // callback
);
}
<?php
namespace Db\Form\InputFilter;
trait Field
{
abstract public function inputFilterInput();
}
@TomHAnderson
TomHAnderson / gist:4081065
Created November 15, 2012 20:30
Parsing a view templete and returning result
public function infiniteScroll($page) {
$view = $this->getServiceLocator()->get('View');
$model = new ViewModel();
$model->setTemplate('scripts/infinite-scroll/main.phtml');
$model->setVariable('page', $page);
$model->setOption('has_parent', true);
return $view->render($model);
}