<?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;
}
}