Skip to content

Instantly share code, notes, and snippets.

@chukShirley
Last active July 14, 2016 14:01
Show Gist options
  • Save chukShirley/9794cdf3f11d28ffb145c31f0bca224c to your computer and use it in GitHub Desktop.
Save chukShirley/9794cdf3f11d28ffb145c31f0bca224c to your computer and use it in GitHub Desktop.
<?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