Last active
July 14, 2016 14:01
-
-
Save chukShirley/9794cdf3f11d28ffb145c31f0bca224c to your computer and use it in GitHub Desktop.
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 RPG\Service\Factory; | |
use Zend\ServiceManager\FactoryInterface; | |
use Zend\ServiceManager\ServiceLocatorInterface; | |
use ToolkitApi\Toolkit; | |
/** | |
* Class ToolkitFactory | |
* @package RPG\Service\Factory | |
*/ | |
class ToolkitFactory implements FactoryInterface | |
{ | |
/** | |
* @param ServiceLocatorInterface $serviceLocator | |
* @return mixed | |
*/ | |
public function createService(ServiceLocatorInterface $serviceLocator) | |
{ | |
$dbAdapter = $serviceLocator->get('Zend\Db\Adapter\Adapter'); | |
$dbAdapter->getDriver() | |
->getConnection() | |
->connect(); | |
$dbConn = $dbAdapter->getDriver() | |
->getConnection() | |
->getResource(); | |
// pass database connection into toolkit instantiation | |
$tkConn = new Toolkit($dbConn, DB2_I5_NAMING_ON); // cheating here by hard-coding naming mode | |
$tkConn->setOptions(array( | |
'stateless' => true | |
)); | |
return $tkConn; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment