本文整理汇总了PHP中Phalcon\Mvc\View::setVars方法的典型用法代码示例。如果您正苦于以下问题:PHP View::setVars方法的具体用法?PHP View::setVars怎么用?PHP View::setVars使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phalcon\Mvc\View
的用法示例。
在下文中一共展示了View::setVars方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render
/**
* @param string $layout
*
* @return string
*/
public function render($layout = 'edit')
{
$column = $this->_params->getParam('name');
$prefix = $this->_params->getParam('source');
$fieldId = ($prefix ? $prefix . '_' : '') . $column;
$fieldName = $prefix ? $prefix . '[' . $column . ']' : $column;
$defaultParams = $this->_params->getParams();
unset($defaultParams['name']);
$tagParams = array_merge([$fieldName], $this->_params->getParam('tag', []), ['value' => $this->getValue(), 'id' => $fieldId] + $defaultParams);
$this->_params->setParam('id', $fieldId);
// все параметры уже добавлены, в общем списке они не нужны
unset($tagParams['tag']);
$tagParams['class'] = isset($tagParams['class']) ? $tagParams['class'] . ' form-control' : 'form-control';
$layout = $this->_params->getParam('options.layout', $layout);
$this->beforeRender($tagParams);
$this->_view->setLayout($layout);
$this->_view->setVars(['field' => $this, 'model' => $this->_model, 'params' => $this->_params, 'tag' => $tagParams]);
return $this->_view->getRender($this->getLayoutDir($layout), $layout);
}
示例2: View
<?php
/**
* Created by Rem.
* Author: Dmitry Kushneriv
* Email: remkwadriga@yandex.ua
* Date: 07-08-2015
* Time: 16:10 PM
*
* @var \Phalcon\Config $config
*/
use Phalcon\Mvc\View;
use Phalcon\Mvc\View\Engine\Volt as VoltEngine;
$view = new View();
$view->setViewsDir($config->application->viewsDir);
$view->setVars($config->view->vars->toArray());
$view->registerEngines(['.volt' => function ($view, $di) use($config) {
$volt = new VoltEngine($view, $di);
$volt->setOptions($config->volt->options->toArray());
$functions = $config->volt->functions->toArray();
foreach ($functions as $name => $function) {
$volt->getCompiler()->addFunction($name, function ($params) use($function) {
if (is_array($function)) {
$funcArray = $function;
$function = $funcArray['function'];
if (isset($funcArray['params']) && !empty($funcArray['params'])) {
if (!is_array($params)) {
$params = (array) $params;
}
$params = array_merge($params, $funcArray['params']);
$params = serialize(array_filter($params));