PHP Class Newscoop\Services\UserService

Show file Open project: sourcefabric/newscoop Class Usage Examples

Protected Properties

Property Type Description
$auth Zend_Auth
$currentUser Newscoop\Entity\User
$em Doctrine\Common\Persistence\ObjectManager
$repository Newscoop\Entity\Repository\UserRepository
$security Symfony\Component\Security\Core\SecurityContext
$userIp

Public Methods

Method Description
__construct ( Doctrine\Common\Persistence\ObjectManager $em, Zend_Auth $auth, SecurityContext $security )
checkUsername ( string $username ) : boolean Test if username is available
countAll ( ) : integer Count all users
countBy ( array $criteria ) : integer Count users by given criteria
createPending ( string $email, string | null $firstName = null, string | null $lastName = null, string | null $subscriber = null, $publication = null ) : User Create pending user
createUser ( string $email, string $password, $username, string $firstName = null, string $lastName = null, integer $publication, $public = true, $userTypes = [], $isAdmin = false ) Create new activated user
delete ( User $user ) : void Delete user
extractCriteriaFromRequest ( $request )
find ( integer $id ) : User Find user
findAll ( ) : mixed Find all users
findBy ( array $criteria, array $orderBy = null, integer | null $limit = null, integer | null $offset = null ) : mixed Find by given criteria
findByAuthor ( integer $authorId ) : User | null Find user by author
findOneBy ( array $criteria ) : User Find one by given criteria
generateUsername ( string $firstName, string $lastName ) : string Generate username
getClassName ( ) : string Get user entity class name
getCollection ( array $criteria, array $orderBy, integer $limit = null, integer $offset = null ) : PaginatedCollection Get collection by given criteria
getCurrentUser ( ) : User Get current user
getGroupOptions ( ) : array Get user group options
getPublicUserCount ( ) : integer Get count of public users
getUserIp ( ) : string Get user IP
loadUserByUsername ( $username )
loginUser ( User $user, string $providerKey ) : UsernamePasswordToken Log in user
renameUser ( object $command ) : void Rename user
save ( array $data, User $user = null ) : User Save user
savePending ( array $data, User $user ) : void Save pending user
setActive ( User $user ) : void Set user active
setUserIp ( string $userIp = null ) : string Set user IP
updateUserPoints ( Symfony\Component\EventDispatcher\GenericEvent $event ) : void Update user points
userIpResolver ( Request $request ) : string Resolve user IP from provided data

Private Methods

Method Description
getRepository ( ) : Newscoop\Entity\Repository\UserRepository Get repository for user entity

Method Details

__construct() public method

public __construct ( Doctrine\Common\Persistence\ObjectManager $em, Zend_Auth $auth, SecurityContext $security )
$em Doctrine\Common\Persistence\ObjectManager
$auth Zend_Auth
$security Symfony\Component\Security\Core\SecurityContext

checkUsername() public method

Test if username is available
public checkUsername ( string $username ) : boolean
$username string
return boolean

countAll() public method

Count all users
public countAll ( ) : integer
return integer

countBy() public method

Count users by given criteria
public countBy ( array $criteria ) : integer
$criteria array
return integer

createPending() public method

Create pending user
public createPending ( string $email, string | null $firstName = null, string | null $lastName = null, string | null $subscriber = null, $publication = null ) : User
$email string
$firstName string | null
$lastName string | null
$subscriber string | null
return Newscoop\Entity\User

createUser() public method

Create new activated user
public createUser ( string $email, string $password, $username, string $firstName = null, string $lastName = null, integer $publication, $public = true, $userTypes = [], $isAdmin = false )
$email string
$password string
$firstName string
$lastName string
$publication integer

delete() public method

Delete user
public delete ( User $user ) : void
$user Newscoop\Entity\User
return void

extractCriteriaFromRequest() public method

public extractCriteriaFromRequest ( $request )

find() public method

Find user
public find ( integer $id ) : User
$id integer
return Newscoop\Entity\User

findAll() public method

Find all users
public findAll ( ) : mixed
return mixed

findBy() public method

Find by given criteria
public findBy ( array $criteria, array $orderBy = null, integer | null $limit = null, integer | null $offset = null ) : mixed
$criteria array
$orderBy array
$limit integer | null
$offset integer | null
return mixed

findByAuthor() public method

Find user by author
public findByAuthor ( integer $authorId ) : User | null
$authorId integer
return Newscoop\Entity\User | null

findOneBy() public method

Find one by given criteria
public findOneBy ( array $criteria ) : User
$criteria array
return Newscoop\Entity\User

generateUsername() public method

Generate username
public generateUsername ( string $firstName, string $lastName ) : string
$firstName string
$lastName string
return string

getClassName() public method

Get user entity class name
public getClassName ( ) : string
return string

getCollection() public method

Get collection by given criteria
public getCollection ( array $criteria, array $orderBy, integer $limit = null, integer $offset = null ) : PaginatedCollection
$criteria array
$orderBy array
$limit integer
$offset integer
return Newscoop\PaginatedCollection

getCurrentUser() public method

Get current user
public getCurrentUser ( ) : User
return Newscoop\Entity\User

getGroupOptions() public method

Get user group options
public getGroupOptions ( ) : array
return array

getPublicUserCount() public method

Get count of public users
public getPublicUserCount ( ) : integer
return integer

getUserIp() public method

Get user IP
public getUserIp ( ) : string
return string

loadUserByUsername() public method

public loadUserByUsername ( $username )

loginUser() public method

Log in user
public loginUser ( User $user, string $providerKey ) : UsernamePasswordToken
$user Newscoop\Entity\User
$providerKey string
return Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken

renameUser() public method

Rename user
public renameUser ( object $command ) : void
$command object
return void

save() public method

Save user
public save ( array $data, User $user = null ) : User
$data array
$user Newscoop\Entity\User
return Newscoop\Entity\User

savePending() public method

Save pending user
public savePending ( array $data, User $user ) : void
$data array
$user Newscoop\Entity\User
return void

setActive() public method

Set user active
public setActive ( User $user ) : void
$user Newscoop\Entity\User
return void

setUserIp() public method

Set user IP
public setUserIp ( string $userIp = null ) : string
$userIp string User IP
return string

updateUserPoints() public method

Update user points
public updateUserPoints ( Symfony\Component\EventDispatcher\GenericEvent $event ) : void
$event Symfony\Component\EventDispatcher\GenericEvent
return void

userIpResolver() public method

Resolve user IP from provided data
public userIpResolver ( Request $request ) : string
$request Symfony\Component\HttpFoundation\Request Request object
return string $userIp User IP

Property Details

$auth protected property

protected Zend_Auth $auth
return Zend_Auth

$currentUser protected property

protected User,Newscoop\Entity $currentUser
return Newscoop\Entity\User

$em protected property

protected ObjectManager,Doctrine\Common\Persistence $em
return Doctrine\Common\Persistence\ObjectManager

$repository protected property

protected UserRepository,Newscoop\Entity\Repository $repository
return Newscoop\Entity\Repository\UserRepository

$security protected property

protected SecurityContext,Symfony\Component\Security\Core $security
return Symfony\Component\Security\Core\SecurityContext

$userIp protected property

protected $userIp