public function getServiceConfig() { return array('factories' => array('zfcuser_user_mapper' => function ($sm) { $options = $sm->get('zfcuser_module_options'); $mapper = new Mapper\User(); $mapper->setDbAdapter($sm->get('zfcuser_zend_db_adapter')); $entityClass = $options->getUserEntityClass(); $mapper->setEntityPrototype(new $entityClass()); $mapper->setHydrator(new Mapper\UserHydrator()); return $mapper; })); }
/** * @param ServiceLocatorInterface $serviceManager * @return User */ public function createService(ServiceLocatorInterface $serviceManager) { /* @var Options\ModuleOptions $options */ $options = $serviceManager->get('zfcuser_module_options'); $entityClass = $options->getUserEntityClass(); /* @var Db\Adapter\Adapter $dbAdapter */ $dbAdapter = $serviceManager->get('zfcuser_zend_db_adapter'); $mapper = new User(); $mapper->setDbAdapter($dbAdapter); $mapper->setEntityPrototype(new $entityClass()); $mapper->setHydrator(new Mapper\UserHydrator()); return $mapper; }
public function getServiceConfig() { return array('invokables' => array('User\\Authentication\\Adapter\\Db' => 'User\\Authentication\\Adapter\\Db', 'User\\Authentication\\Storage\\Db' => 'User\\Authentication\\Storage\\Db'), 'factories' => array('User\\Entity\\Role' => function ($sm) { return new Role(); }, 'User\\Entity\\User' => function ($sm) { return new User(); }, 'User\\View\\UnauthorizedStrategy' => function ($sm) { return new UnauthorizedStrategy(); }, 'User\\Authentication\\Adapter\\OAuth2Adapter' => 'User\\Authentication\\Adapter\\Factory\\OAuth2AdapterFactory', 'zfcuser_redirect_callback' => 'User\\Service\\Factory\\RedirectCallbackFactory', 'User_user_mapper' => function ($sm) { $options = $sm->get('zfcuser_module_options'); $mapper = new Mapper\User(); $mapper->setDbAdapter($sm->get('zfcuser_zend_db_adapter')); $entityClass = $options->getUserEntityClass(); $mapper->setEntityPrototype(new $entityClass()); $mapper->setHydrator(new Mapper\UserHydrator()); $mapper->setTableName($options->getTableName()); return $mapper; }, 'GoogleClient' => function ($sm) { $config = $sm->get('Config'); $gapi_settings = isset($config['User']['gapi']) ? $config['User']['gapi'] : false; if ($gapi_settings) { $client = new \Google_Client(); $client->setAccessType('offline'); $client->setApplicationName('Target Media Partners'); $client->setClientId($gapi_settings['CLIENT_ID']); $client->setClientSecret($gapi_settings['CLIENT_SECRET']); $client->setRedirectUri($gapi_settings['CALLBACK']); $client->setDeveloperKey($gapi_settings['DEVELOPER_KEY']); $client->setScopes(array('profile', 'email')); return $client; } else { throw new \Exception('Settings for the Google Application were not found.'); } }, 'GoogleAuth' => function ($sm) { $serviceLocator = $sm; $googleAuth = new GoogleAuthService($serviceLocator); return $googleAuth; }, 'User\\Cache' => function ($sm) { $cache = \Zend\Cache\StorageFactory::factory(array('adapter' => 'filesystem', 'plugins' => array('exception_handler' => array('throw_exceptions' => FALSE), 'serializer'))); $cache->setOptions(array('cache_dir' => './data/cache', 'ttl' => 60 * 60)); return $cache; })); }