Skip to content

Instantly share code, notes, and snippets.

@asgrim
Created October 26, 2012 08:38
Show Gist options
  • Save asgrim/3957662 to your computer and use it in GitHub Desktop.
Save asgrim/3957662 to your computer and use it in GitHub Desktop.
every page
<?php
namespace EveryPage\Controller\Plugin;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\ServiceManager\ServiceLocatorAwareInterface;
use Zend\Mvc\Controller\Plugin\AbstractPlugin;
class EveryPage extends AbstractPlugin implements ServiceLocatorAwareInterface
{
protected $serviceLocator;
public function setServiceLocator(ServiceLocatorInterface $serviceLocator)
{
$this->serviceLocator = $serviceLocator;
return $this;
}
/**
* (non-PHPdoc)
* @see Zend\ServiceManager.ServiceLocatorAwareInterface::getServiceLocator()
* @return ServiceLocatorInterface
*/
public function getServiceLocator()
{
return $this->serviceLocator;
}
public function __invoke()
{
$sometext = "If you see this, EveryPage ran!";
//$this->getServiceLocator()->get('view')->sometext = $sometext;
#if ($this->getServiceLocator()->has('viewhelpermanager'))
{
var_dump($this->getServiceLocator()->get('viewhelpermanager'));
}
var_dump($this->getServiceLocator());
// @todo How can I put stuff in the view from here?
// @todo If I access the controller (using $this->getController()) it's not the right instance
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment