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
public function init(ModuleManager $moduleManager)
{
$this->getEventManager()->getSharedManager()->attach(
array('Zend\Mvc\Application'), // context
array(MvcEvent::EVENT_DISPATCH), // event 'dispatch'
array($this, 'checkSession') // callback
);
}
@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']
)
@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: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: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")
<?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
// 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':
@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)
class Module implements ApigilityProviderInterface
{
public function onBootstrap(MvcEvent $e)
{
$eventManager = $e->getApplication()->getEventManager();
$sharedEventManager = $eventManager->getSharedManager();
print_r($sharedEventManger);die('post shared event manager');

Download Composer

Run this in your terminal to get the latest Composer version:

curl -sS https://getcomposer.org/installer | php 

Or if you don't have curl:

php -r "readfile('https://getcomposer.org/installer');" | php