Created
September 23, 2015 20:03
-
-
Save chukShirley/4fbdff014c2200c3565a to your computer and use it in GitHub Desktop.
ZF2 IBM i Toolkit module
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 | |
// Generated by ZF2's ./bin/classmap_generator.php | |
return array( | |
'IbmiToolkit\Module' => __DIR__ . '/Module.php', | |
'IbmiToolkit\Factory\ToolkitFactory' => __DIR__ . '/src/IbmiToolkit/Factory/ToolkitFactory.php', | |
); |
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 | |
return [ | |
'service_manager' => [ | |
'abstract_factories' => [ | |
'Zend\Cache\Service\StorageCacheAbstractServiceFactory', | |
'Zend\Log\LoggerAbstractServiceFactory', | |
], | |
'factories' => [ | |
'IbmiToolkit\IbmiToolkit' => 'IbmiToolkit\Factory\ToolkitFactory' | |
], | |
], | |
]; |
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 | |
namespace IbmiToolkit; | |
use Zend\Mvc\ModuleRouteListener; | |
use Zend\Mvc\MvcEvent; | |
class Module | |
{ | |
public function onBootstrap(MvcEvent $e) | |
{ | |
$eventManager = $e->getApplication()->getEventManager(); | |
$moduleRouteListener = new ModuleRouteListener(); | |
$moduleRouteListener->attach($eventManager); | |
} | |
public function getConfig() | |
{ | |
return include __DIR__ . '/config/module.config.php'; | |
} | |
public function getAutoloaderConfig() | |
{ | |
return array( | |
'Zend\Loader\ClassMapAutoloader' => [ | |
__DIR__ . '/autoload_classmap.php', | |
], | |
'Zend\Loader\StandardAutoloader' => array( | |
'namespaces' => array( | |
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__, | |
), | |
), | |
); | |
} | |
} |
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 | |
namespace IbmiToolkit\Factory; | |
use Zend\ServiceManager\FactoryInterface; | |
use Zend\ServiceManager\ServiceLocatorInterface; | |
/** | |
* Class ToolkitFactory | |
* @package IbmiToolkit\Factory | |
*/ | |
class ToolkitFactory implements FactoryInterface | |
{ | |
/** | |
* @param ServiceLocatorInterface $sm | |
* @return \ToolkitService | |
*/ | |
public function createService(ServiceLocatorInterface $sm) | |
{ | |
$config = $sm->get('Config'); | |
$settings = $config['ibmiToolkit']; | |
$dbAdapter = $sm->get('ibmiToolkit_zend_db_adapter'); | |
$conn = $dbAdapter->getDriver()->getConnection()->getResource(); | |
require('ToolkitService.php'); | |
$tk = \ToolkitService::getInstance($conn,$settings['naming_mode']); | |
$tk->setOptions($settings); | |
return $tk; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment