This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This class allows the Controller to be instantiated as a factory by the ServiceManager | |
*/ | |
namespace BabyMonitor\Controller\Factories; | |
use Zend\ServiceManager\FactoryInterface, | |
Zend\ServiceManager\ServiceLocatorInterface, | |
Monitor\Controller\MonitorController; | |
class MonitorControllerFactory implements FactoryInterface | |
{ | |
protected $cache = null; | |
protected $monitorTable = null; | |
public function createService(ServiceLocatorInterface $serviceLocator) | |
{ | |
$sm = $serviceLocator->getServiceLocator(); | |
if ($sm->has('Monitor\Tables\MonitorTable')) { | |
$this->monitorTable = $sm->get('Monitor\Tables\MonitorTable'); | |
} | |
if ($sm->has('Monitor\Cache\Application')) { | |
$this->cache = $sm->get('Monitor\Cache\Application'); | |
} | |
$config = $sm->get('Config'); | |
$appConfig = (array_key_exists('app', $config)) ? $config['app'] : null; | |
$controller = new MonitorController($this->monitorTable, $appConfig, $this->cache); | |
return $controller; | |
} | |
} | |
<?php | |
/** | |
* The Monitor Controller | |
* | |
*/ | |
namespace BabyMonitor\Controller; | |
use Monitor\Model\MonitorModel; | |
use Monitor\Tables\MonitorTable; | |
use Zend\EventManager\EventManagerInterface; | |
use Zend\Mvc\Controller\AbstractActionController; | |
use Zend\Paginator\Adapter\ArrayAdapter; | |
use Zend\Paginator\Adapter\Iterator; | |
use Zend\Paginator\Paginator; | |
use Zend\View\Model\ViewModel; | |
use Zend\Db\ResultSet\ResultSetInterface; | |
class MonitorController extends AbstractActionController | |
{ | |
/** | |
* @var MonitorTable | |
*/ | |
protected $monitorTable; | |
public function __construct(MonitorTable $monitorTable) | |
{ | |
$this->monitorTable = $monitorTable; | |
} | |
} | |
<?php | |
// module.config.php | |
return array( | |
'controllers' => array( | |
'invokables' => array(), | |
'factories' => array( | |
'Monitor\Controller\Monitor' => | |
'MonitorMonitor\Controller\Factories\MonitorControllerFactory', | |
) | |
), | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment