本文整理汇总了PHP中Zend_Layout::setView方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Layout::setView方法的具体用法?PHP Zend_Layout::setView怎么用?PHP Zend_Layout::setView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Layout
的用法示例。
在下文中一共展示了Zend_Layout::setView方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Instance of construct
*
* @param string $layout
* @param array $options
*/
public function __construct($layout = 'email', array $options = array())
{
$this->frontController = \Zend_Controller_Front::getInstance();
$resources = $this->frontController->getParam('bootstrap')->getOption('resources');
if (isset($options['layout'])) {
$this->layout = new \Zend_Layout($options['layout']);
} elseif (isset($resources['layout'])) {
$this->layout = new \Zend_Layout($resources['layout']);
} else {
$this->layout = new \Zend_Layout();
}
if (isset($options['view'])) {
$this->layout->setView(new \Zend_View($options['view']));
} elseif (isset($resources['view'])) {
$this->layout->setView(new \Zend_View($resources['view']));
} else {
$this->layout->setView(new \Zend_View());
}
$scriptPath = APPLICATION_PATH . self::EMAIL_PATH;
if (null !== $this->frontController->getModuleDirectory()) {
$scriptPath = $this->frontController->getModuleDirectory() . self::EMAIL_PATH;
}
$this->layout->setLayout($layout);
$this->setScriptPath($scriptPath);
}
示例2: _prepareLayout
/**
* Prepare layout instance to be used
*
* @return void
*/
private function _prepareLayout()
{
// set the view object
$this->_layout->setView($this->view);
// set the layout path
$this->_layout->setLayoutPath($this->getApplicationPath() . '/layouts/scripts/');
}
示例3: setLayout
/**
*
* Layout setter. If no layout indicated a new one is created.
* @param Zend_Layout $layout
*/
public function setLayout(Zend_Layout $layout = null)
{
if (isset($layout)) {
$this->_layout = $layout;
$this->_layout->setView($this->getView());
} else {
$this->getLayout();
}
return $this;
}
示例4: postDispatch
public function postDispatch()
{
$layouts = array_reverse($this->_layouts);
$mvcLayout = Zend_Layout::getMvcInstance();
$mvcContentKey = $mvcLayout->getContentKey();
$content = $this->getResponse()->getBody();
$view = $this->_cloneView();
$layout = new Zend_Layout(array('layoutPath' => $mvcLayout->getLayoutPath(), 'viewSuffix' => $mvcLayout->getViewSuffix()));
$layout->setView($view);
foreach ($layouts as $layoutName) {
$layout->setLayout($layoutName);
$layout->{$mvcContentKey} = $this->getResponse()->getBody();
$this->getResponse()->setBody($layout->render());
}
}
示例5: testViewAccessorsAllowSettingView
/**
* @return void
*/
public function testViewAccessorsAllowSettingView()
{
$layout = new Zend_Layout();
$view = new Zend_View();
$layout->setView($view);
$received = $layout->getView();
$this->assertSame($view, $received);
}
示例6: getMailContent
/**
* Render mail content using a view and template
*
* @param string $template
* @param array $substitutions
* @param array $placeholders
* @param string $mode
* @param string $layout
* @param string $layoutPath
*/
public function getMailContent($template, $substitutions, $placeholders = array(), $mode = 'html', $layout = null, $layoutPath = null)
{
// Create the return variable
$return = '';
// Create a view renderer
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
$view = clone $viewRenderer->view;
// Create a layout object and set it to app_path/emails/layouts
if ($layoutPath === null || $layoutPath == '') {
$layoutPath = PUBLIC_PATH . $view->templateUrl('') . 'email' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR;
}
// Create the layout object
$layoutObject = new Zend_Layout($layoutPath);
// Add the script path to the view that overrules the default path
$application = $this->getFrontController()->getParam('application');
$module = $this->getRequest()->getModuleName();
$scriptPath = $view->layout()->getViewScriptPath() . '/views/' . $application . '/modules/' . $module . '/';
if (!in_array($scriptPath, $view->getScriptPaths())) {
$view->addScriptPath($scriptPath);
}
// Add the default email folder for the layout/template
$view->addScriptPath(PUBLIC_PATH . $view->templateUrl('') . 'email' . DIRECTORY_SEPARATOR . 'views');
// Assign all substitutions (e.g. view variables) to the view view
foreach ($substitutions as $key => $sub) {
$view->{$key} = $sub;
}
// Replace all placeholders
if (is_array($placeholders)) {
foreach ($placeholders as $key => $sub) {
}
}
// Set the view object to the layout object
$layoutObject->setView($view);
// Initialize a default layout
if ($layout === null || $layout == '') {
$layout = 'default';
}
switch ($mode) {
case 'html':
// Render html version of template & assign to $return
$layoutObject->content = $view->render($template . '.html.phtml');
// Set the layout
$layoutObject->setLayout('' . $layout . '.html');
// Render the layout output
$return = $layoutObject->render();
// Assimilate the stylesheet in the html
$stylesheet = $layoutPath . $layout . '.css';
if (file_exists($stylesheet)) {
$stylesheetContent = file_get_contents($stylesheet);
$test = new CSSToInlineStyles($return, $stylesheetContent);
$return = $test->convert(true);
}
break;
case 'text':
// Render text version of template & assign to $return
$layoutObject->content = $view->render($template . '.text.phtml');
// Set the layout
$layoutObject->setLayout('' . $layout . '.text');
// Render the layout output
$return = $layoutObject->render();
break;
}
// Replace the placeholders in the content
$return = $this->_replacePlaceholders($return, $placeholders);
// all done, return output
return $return;
}
示例7: setOptions
/**
* Set Options from an Array
*
* @param array $options
* @return Bgy\Mail\Template Provides fluent interface
*/
public function setOptions(array $options = array())
{
if (isset($options['view'])) {
$view = $options['view'];
if (is_string($view)) {
$view = new $view();
}
} else {
// Set default view to Zend_View
$view = new \Zend_View();
}
unset($options['view']);
if (isset($options['layout'])) {
$layout = $options['layout'];
if (is_string($layout)) {
$layout = new $layout();
}
} else {
// Default layout to Zend_Layout
$layout = new \Zend_Layout();
}
if (isset($options['htmlRenderer'])) {
$htmlRenderer = $options['htmlRenderer'];
if (is_string($htmlRenderer)) {
$htmlRenderer = new $htmlRenderer();
}
} else {
// Default provided Html Renderer to convert Html to Text
$htmlRenderer = new Template\Html\Renderer\SimpleText();
}
$this->setHtmlRenderer($htmlRenderer);
unset($options['htmlRenderer']);
$layout->setView($view);
$this->setLayout($layout);
$this->setView($view);
unset($options['layout']);
if (!isset($options['layoutScript'])) {
// Default layout script name 'layout'
$options['layoutScript'] = 'layout';
}
foreach ($options as $key => $value) {
$method = 'set' . ucfirst($key);
if (method_exists($this, $method)) {
$this->{$method}($value);
}
unset($options[$key]);
}
return $this;
}
示例8: injectResources
/**
* Creates simulated resources and injects them into the given bootstrapper.
*
* @param Mol_Test_Bootstrap $bootstrapper
*/
protected function injectResources(Mol_Test_Bootstrap $bootstrapper)
{
$bootstrapper->simulateResource('log', new Zend_Log($this->logWriter));
$view = $this->createView();
$bootstrapper->simulateResource('view', $view);
$layout = new Zend_Layout();
$layout->setView($view);
$view->getHelper('layout')->setLAyout($layout);
$bootstrapper->simulateResource('layout', $layout);
}