Esempio n. 1
0
 /**
  * Create Mapper with name
  * 
  * {@inheritDoc}
  * @see \Zend\ServiceManager\Factory\FactoryInterface::__invoke()
  */
 public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
 {
     $prefix = current(explode('_', $requestedName));
     $namespace = $this->getConfig($container)['namespace'][$prefix];
     $name_table = substr($requestedName, strlen($prefix) + 8);
     $adapter = $container->get($this->getConfig($container)['adapter']);
     $resultSetPrototype = new ResultSet();
     $resultSetPrototype->bufferArrayObjectPrototype();
     $resultSetPrototype->setArrayObjectPrototype($container->get($prefix . '_model_' . $name_table));
     $tableGateway = new TableGateway($name_table, $adapter, null, $resultSetPrototype, new Sql($adapter, $name_table));
     $class = $namespace['mapper'] . '\\' . $this->toCamelCase($name_table);
     $obj = new $class($tableGateway);
     $obj->setContainer($container);
     return $obj;
 }
Esempio n. 2
0
 public function testCurrentWihtOnceCallExchangeArray()
 {
     $m_model = $this->getMockBuilder('Dal\\Model\\AbstractModel')->disableOriginalConstructor()->setMethods(array('exchangeArray'))->getMock();
     $m_model->expects($this->once())->method('exchangeArray')->will($this->returnSelf());
     $arr = new \ArrayObject(array(array('toto'), array('tata')));
     $resultset = new ResultSet();
     $resultset->bufferArrayObjectPrototype();
     $resultset->setArrayObjectPrototype($m_model);
     $resultset->initialize($arr);
     $out = $resultset->current();
     $out = $resultset->current();
     $out = $resultset->current();
 }