Newscoop\Entity\User::setStatus PHP Method

setStatus() public method

Set status
public setStatus ( integer $status ) : Newscoop\Entity\User
$status integer
return Newscoop\Entity\User
    public function setStatus($status)
    {
        static $statuses = array(self::STATUS_INACTIVE, self::STATUS_ACTIVE, self::STATUS_BANNED, self::STATUS_DELETED);
        if (!in_array($status, $statuses)) {
            throw new \InvalidArgumentException("Unknown status '{$status}'");
        }
        $this->status = $status;
        return $this;
    }

Usage Example

示例#1
0
 private function addUser($name, $status = 1, $isPublic = 1)
 {
     $user = new User($name);
     $user->setStatus($status);
     $user->setPublic($isPublic);
     $this->em->persist($user);
     $this->em->flush();
 }
All Usage Examples Of Newscoop\Entity\User::setStatus