/** * Create service * * @param ServiceLocatorInterface $serviceLocator * @return mixed */ public function createService(ServiceLocatorInterface $serviceLocator) { $config = $this->getConfig($serviceLocator); if (isset($config['service_locator'])) { $objectServiceLocator = $serviceLocator->get($config['service_locator']); } else { $objectServiceLocator = $serviceLocator->has('Matryoshka\\Model\\Object\\ObjectManager') ? $serviceLocator->get('Matryoshka\\Model\\Object\\ObjectManager') : $serviceLocator; } $strategy = new ServiceLocatorStrategy($objectServiceLocator); if (isset($config['type_field'])) { $strategy->setTypeField($config['type_field']); } if (isset($config['validate_object'])) { $strategy->setValidateObject($config['validate_object']); } if (isset($config['clone_object'])) { $strategy->setCloneObject($config['clone_object']); } return $strategy; }
public function testGetSetCloneObject() { $strategy = new ServiceLocatorStrategy($this->serviceManager); $strategy->setCloneObject(true); $this->assertSame(true, $strategy->getCloneObject()); }