Skip to content

Instantly share code, notes, and snippets.

View weierophinney's full-sized avatar
⏯️

Matthew Weier O'Phinney weierophinney

⏯️
View GitHub Profile

EventManager

 - attach() should allow attaching a ListenerAggregate
 - detach() should allow detaching a ListenerAggregate
 - non-static implementation of StaticEventCollection
    - Determine how this could be injected into every class composing an
      EventManager? and/or those classes that ask for an EventManager?
 - update classes composing an EventManager such that they will set identifers
   when retrieved -- i.e. a setIdentifiers() call prior to returning the
   instance.

@weierophinney
weierophinney / ViewLayerIdeas.php
Created February 9, 2012 18:09
Brainstorming for ZF2 view layer
<?php
// The default strategy would add a listener to Application::dispatch() at high
// priority. This would inject a ViewModel instance with the layout template set
// as the template, no capture_to value, and a false terminal flag.
// The default strategy would also listen to Dispatchable::dispatch() at low
// priority; a returned ViewModel instance would be injected into the MvcEvent
// as the ViewModel. At this time, we'd also check for a template on the
// ViewModel, and if none found, auto-determine it and inject it based on the
<?php
namespace FooModule;
use Zend\EventManager\StaticEventManager;
class Module
{
public function init()
{
<div class="code_500">
<h2>Application Error</h2>
<p>
An error occurred processing this page; please try again later.
</p>
<?php
if (!$this->display_exceptions) {
echo "<p>Display exceptions is disabled</p>\n";
<div class="code_500">
<h2>Application Error</h2>
<p>
An error occurred processing this page; please try again later.
</p>
<?php
if (!$this->display_exceptions) {
echo "<p>Display exceptions is disabled</p>\n";
public function getWhereParts()
{
return array(
array(
$this->getSpecification(),
array($this->identifier, $this->minValue, $this->maxValue),
array(),
),
);
}
<?php
namespace Frontend;
use Zend\EventManager\StaticEventManager;
class Module
{
public function init()
{
$events = StaticEventManager::getInstance();
@weierophinney
weierophinney / EventManager.php
Created March 9, 2012 21:51
EventManager injection
<?php
namespace Zend\EventManager;
/**
* EventManager can compose static connections.
*
* What I'd like to see: classes that accept an EM always get a new instance,
* but each EM instance each receives the *same* instance of a
* StaticEventCollection.
*
<?php
function getEventManager()
{
$em = new EventManager();
$em->setStaticConnections($this->getGlobalEventManager());
return $em;
}
function getGlobalEventManager()
{