Location: PHPKode > projects > SimpleSPML > SimpleSPML/lib/msg/password/ResetPasswordResponse.php
<?php
require_once "lib/msg/core/Response.php";

/*
<complexType name = "ResetPasswordResponseType">
    <complexContent>
        <extension base = "spml:ResponseType">
            <sequence>
                <element name = "password" type = "string" minOccurs = "0" />
            </sequence>
        </extension>
    </complexContent>
</complexType>
*/

/**
 * ResetPasswordResponse
 * 
 * Provider response to a ResetPasswordRequest message
 * 
 * @package SimpleSPML
 * @author Alessandra Bozzo <hide@address.com>
 */
class ResetPasswordResponse extends Response
{
    /**
	 * Contain the newly changed password value
	 * that is associated with the specified object
	 * 
	 * @access protected
	 * @var XsdString
	 */
    protected $password = null;

    /**
     * Constructor
     */
    public function __construct()
    {
        $this->setBaseElements("password");
        
        parent::__construct();
    }
    
    /**
     * Return password value
     * @access public
     * @return XsdString
     */
    public function __getPassword()
    {
        return $this->password;
    }
    
    /**
     * Sets the value of password
     * @access public
     * @param string $password 
     */
    public function __setPassword($password)
    {
        if($password)
        {
            try
            {
                $this->password = new XsdString($password);
            }
            
            catch(Exception $e)
            {
                throw new WrongTypeException(get_class($this) . "::password");
            }
        }
    }
    
    /**
     * Read the SPML message
     * @access public
     * @param SimpleXMLIterator $obj
     */
    public function readMessage($obj)
    {
        $this->checkNamespace($obj, "urn:oasis:names:tc:SPML:2:0");
        
        // Load elements
        $children = $obj->children();
        
        // password
        if($children->password)
        {
            $this->setElement("password", (string) $children->password);
            unset($children->password);
        }
        
        parent::readMessage($obj);
        
        if(!$this->isValid())
            throw new InvalidMessageException(get_class($this));
    }
    
    /**
     * Write the SPML message
     * @access public
     * @param int $level
     * @return string
     */
    public function writeMessage($level = 0)
    {
        if(!$this->isValid())
            throw new InvalidObjectException(get_class($this));
        
        $ind = $this->indentation($level);
        
        $spmlstr = $ind . '<resetPasswordResponse xmlns="urn:oasis:names:tc:SPML:2:0"';
        
        // write resetPasswordResponse attributes
        $spmlstr .= $this->writeAttributes();
                
        // write parent elements
        $spmlmidstr = parent::writeMessage($level + 1);
        
        // write resetPasswordResponse elements
        $midind = $this->indentation($level + 1);
        
        if($this->password)
            $spmlmidstr .= $midind . '<password>' . $this->password->ToString() . '</password>
';
        
        return $this->tagCloser("resetPasswordResponse", $spmlstr, $spmlmidstr, $ind);
    }
}
?>
Return current item: SimpleSPML