예제 #1
0
 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;
 }
예제 #3
0
파일: User.php 프로젝트: hoangpt/nextcms
 /**
  * Check if there is user with given username or email address
  *
  * @param \User\Entity\User $user
  * @return bool
  */
 public function exist($user)
 {
     if ($user->email == null && $user->user_name == null) {
         return true;
     }
     $criteria = [];
     if ($user->email) {
         $criteria[] = ['email' => $user->email];
     }
     if ($user->user_name) {
         $criteria[] = ['user_name' => $user->user_name];
     }
     $count = $this->userMapper->count(['$or' => $criteria]);
     return $count > 0;
 }
예제 #4
0
 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;
     }));
 }
예제 #5
0
 public function getUserRepository()
 {
     $class = User::getOption('user_entity_class');
     return $this->getDocumentManager()->getRepository($class);
 }
 /**
  * @return string
  */
 public function __invoke()
 {
     $users = $this->userMapper->findAll(16, 'created_at', 'DESC');
     return $this->getView()->render('user/helper/new-users', ['users' => $users]);
 }