File indexing completed on 2025-01-26 05:29:16
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Application 0017 * @subpackage Resource 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 * @version $Id$ 0021 */ 0022 0023 /** 0024 * @see Zend_Application_Resource_ResourceAbstract 0025 */ 0026 // require_once 'Zend/Application/Resource/ResourceAbstract.php'; 0027 0028 0029 /** 0030 * Resource for settings view options 0031 * 0032 * @uses Zend_Application_Resource_ResourceAbstract 0033 * @category Zend 0034 * @package Zend_Application 0035 * @subpackage Resource 0036 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0037 * @license http://framework.zend.com/license/new-bsd New BSD License 0038 */ 0039 class Zend_Application_Resource_View extends Zend_Application_Resource_ResourceAbstract 0040 { 0041 /** 0042 * @var Zend_View_Interface 0043 */ 0044 protected $_view; 0045 0046 /** 0047 * Defined by Zend_Application_Resource_Resource 0048 * 0049 * @return Zend_View 0050 */ 0051 public function init() 0052 { 0053 $view = $this->getView(); 0054 0055 $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer'); 0056 $viewRenderer->setView($view); 0057 return $view; 0058 } 0059 0060 /** 0061 * Retrieve view object 0062 * 0063 * @return Zend_View 0064 */ 0065 public function getView() 0066 { 0067 if (null === $this->_view) { 0068 $options = $this->getOptions(); 0069 $this->_view = new Zend_View($options); 0070 0071 if (isset($options['doctype'])) { 0072 $this->_view->doctype()->setDoctype(strtoupper($options['doctype'])); 0073 if (isset($options['charset']) && $this->_view->doctype()->isHtml5()) { 0074 $this->_view->headMeta()->setCharset($options['charset']); 0075 } 0076 } 0077 if (isset($options['contentType'])) { 0078 $this->_view->headMeta()->appendHttpEquiv('Content-Type', $options['contentType']); 0079 } 0080 if (isset($options['assign']) && is_array($options['assign'])) { 0081 $this->_view->assign($options['assign']); 0082 } 0083 } 0084 return $this->_view; 0085 } 0086 }