web/lib/Zend/Navigation/Page/Uri.php
changeset 64 162c1de6545a
parent 19 1c2f13fd785c
child 68 ecaf28ffe26e
equal deleted inserted replaced
63:5b37998e522e 64:162c1de6545a
       
     1 <?php
       
     2 /**
       
     3  * Zend Framework
       
     4  *
       
     5  * LICENSE
       
     6  *
       
     7  * This source file is subject to the new BSD license that is bundled
       
     8  * with this package in the file LICENSE.txt.
       
     9  * It is also available through the world-wide-web at this URL:
       
    10  * http://framework.zend.com/license/new-bsd
       
    11  * If you did not receive a copy of the license and are unable to
       
    12  * obtain it through the world-wide-web, please send an email
       
    13  * to license@zend.com so we can send you a copy immediately.
       
    14  *
       
    15  * @category   Zend
       
    16  * @package    Zend_Navigation
       
    17  * @subpackage Page
       
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    20  * @version    $Id: Uri.php 20096 2010-01-06 02:05:09Z bkarwin $
       
    21  */
       
    22 
       
    23 /**
       
    24  * @see Zend_Navigation_Page_Abstract
       
    25  */
       
    26 require_once 'Zend/Navigation/Page.php';
       
    27 
       
    28 /**
       
    29  * Represents a page that is defined by specifying a URI
       
    30  *
       
    31  * @category   Zend
       
    32  * @package    Zend_Navigation
       
    33  * @subpackage Page
       
    34  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    35  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    36  */
       
    37 class Zend_Navigation_Page_Uri extends Zend_Navigation_Page
       
    38 {
       
    39     /**
       
    40      * Page URI
       
    41      *
       
    42      * @var string|null
       
    43      */
       
    44     protected $_uri = null;
       
    45 
       
    46     /**
       
    47      * Sets page URI
       
    48      *
       
    49      * @param  string $uri                page URI, must a string or null
       
    50      * @return Zend_Navigation_Page_Uri   fluent interface, returns self
       
    51      * @throws Zend_Navigation_Exception  if $uri is invalid
       
    52      */
       
    53     public function setUri($uri)
       
    54     {
       
    55         if (null !== $uri && !is_string($uri)) {
       
    56             require_once 'Zend/Navigation/Exception.php';
       
    57             throw new Zend_Navigation_Exception(
       
    58                     'Invalid argument: $uri must be a string or null');
       
    59         }
       
    60 
       
    61         $this->_uri = $uri;
       
    62         return $this;
       
    63     }
       
    64 
       
    65     /**
       
    66      * Returns URI
       
    67      *
       
    68      * @return string
       
    69      */
       
    70     public function getUri()
       
    71     {
       
    72         return $this->_uri;
       
    73     }
       
    74 
       
    75     /**
       
    76      * Returns href for this page
       
    77      *
       
    78      * @return string
       
    79      */
       
    80     public function getHref()
       
    81     {
       
    82         return $this->getUri();
       
    83     }
       
    84 
       
    85     // Public methods:
       
    86 
       
    87     /**
       
    88      * Returns an array representation of the page
       
    89      *
       
    90      * @return array
       
    91      */
       
    92     public function toArray()
       
    93     {
       
    94         return array_merge(
       
    95             parent::toArray(),
       
    96             array(
       
    97                 'uri' => $this->getUri()
       
    98             ));
       
    99     }
       
   100 }