/** * render the content of an existing view : $controller/$action and set the response to the modal content * @param View $view * @param string $controller a Phalcon controller * @param string $action a Phalcon action * @param $params The parameters to pass to the view */ public function renderContent($view, $controller, $action, $params = NULL) { $template = $view->getRender($controller, $action, $params, function ($view) { $view->setRenderLevel(View::LEVEL_ACTION_VIEW); }); $this->content = $template; }
/** * {@inheritdoc} */ public function render($params = array()) { $currentViewsDir = $this->view->getViewsDir(); $this->view->setViewsDir($this->getServiceViewPath()); $this->view->disableLevel(View::LEVEL_LAYOUT); $content = $this->view->getRender('services', $this->templateName, $params); //rollback viewsDir $this->view->setViewsDir($currentViewsDir); return $content; }
/** * @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); }
public function renderToolbar() { $view = new View(); $viewDir = dirname(__FILE__) . '/views/'; $view->setViewsDir($viewDir); // set vars $view->debugWidget = $this; $content = $view->getRender('toolbar', 'index'); return $content; }
public function testGetRender() { $view = new Phalcon\Mvc\View(); $view->setViewsDir('unit-tests/views/'); $content = $view->getRender('test5', 'index', array('cool_var' => 'le-this')); $this->assertEquals($content, '<html>Hey, this is a partial, also le-this</html>' . PHP_EOL); }
/** * @covers \Phalcon\Mvc\View::__isset */ public function testViewParamIsset() { $view = new View(); $view->setViewsDir('unit-tests/views/'); $view->set_param = 'something'; $content = $view->getRender('test16', 'index'); $this->assertEquals($content, '<html>1</html>' . PHP_EOL); }
/** * @return string */ public function renderToolbar() { $view = new View(); $viewDir = __DIR__ . '/views/'; $view->setViewsDir($viewDir); $view->setVar('debugWidget', $this); $content = $view->getRender('toolbar', 'index'); return $content; }
/** * @covers \Phalcon\Mvc\View::__isset */ public function testViewParamIsset() { $this->specify("Setting View parameters doesn't work", function () { $view = new View(); $view->setViewsDir(PATH_DATA . "views" . DIRECTORY_SEPARATOR); $view->set_param = "something"; $content = $view->getRender("test16", "index"); expect($content)->equals("<html>1</html>" . PHP_EOL); }); }