added the newByUserId constructor
This commit is contained in:
parent
8702ee8de2
commit
7e37c6aec4
1 changed files with 29 additions and 0 deletions
|
|
@ -173,6 +173,35 @@ sub new {
|
|||
return $self;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 newByUserId ( session, [userId] )
|
||||
|
||||
Constructor.
|
||||
|
||||
=head3 session
|
||||
|
||||
A reference to the current session.
|
||||
|
||||
=head3 userId
|
||||
|
||||
A unique userId. Will pull from the session if not specified.
|
||||
|
||||
=cut
|
||||
|
||||
sub newByUserId {
|
||||
my ($class, $session, $userId) = @_;
|
||||
unless (defined $session && $session->isa("WebGUI::Session")) {
|
||||
WebGUI::Error::InvalidObject->throw(expected=>"WebGUI::Session", got=>(ref $session), error=>"Need a session.");
|
||||
}
|
||||
$userId ||= $session->user->userId;
|
||||
unless (defined $userId) {
|
||||
WebGUI::Error::InvalidParam->throw( param=>$userId, error=>"Need a userId.");
|
||||
}
|
||||
return $class->new($session, $session->db->quickScalar("select vendorId from vendor where userId=?",[$userId]));
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 session ()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue