/** * @test */ public function can_get_set_model() { $mav = new ModelAndView('name'); $mav->add(array('key1' => 'value1')); $model = $mav->getModel(); $this->assertEquals($model['key1'], 'value1'); }
public function _ExceptionException($exception) { $modelAndView = new ModelAndView('layout'); $modelAndView->add(array('viewName' => 'exception')); $modelAndView->add(array('exception' => $exception)); return $modelAndView; }
public function someAction() { $session = HttpSession::getSession(); $session->setAttribute('aSessionVariable', array('user' => 'aUser')); $modelAndView = new ModelAndView('some'); $modelAndView->add(array('somestring' => 'Hello World', 'arguments' => func_get_args())); $modelAndView->add(array('headers' => array('Cache-Control: no-cache', 'Pragma: no-cache'))); return $modelAndView; }
/** * This will resolve the given ModelAndView to a view in the filesystem * (an absolute path to a file). * * @param ModelAndView $modelAndView What to render. * * @see Ding\Mvc.IViewResolver::resolve() * @return HttpView */ public function resolve(ModelAndView $modelAndView) { $name = $modelAndView->getName(); $path = $this->_path . DIRECTORY_SEPARATOR . $this->_prefix . $name . $this->_suffix; if ($this->_logger->isDebugEnabled()) { $this->_logger->debug('Using viewpath: ' . $path); } return new HttpView($modelAndView, $path); }
/** * @test */ public function can_render_and_translate() { // For language stuff ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . RESOURCES_DIR); $this->expectOutputString('hi there'); $mav = new ModelAndView('some'); $mav->add(array('headers' => array('HTTP/1.0 404 Not Found'))); $container = ContainerImpl::getInstance($this->_properties); $resolver = $container->getBean('HttpViewResolver3'); $view = $resolver->resolve($mav); $render = $container->getBean('HttpViewRender'); $render->render($view); $this->assertEquals($render->translate('abundle', 'message.some', array('arg1' => '1', 'arg2' => '2', 'arg3' => '3')), 'This is a test message, arg1=1 arg2=2 arg3=3'); $session = HttpSession::getSession(); $session->setAttribute('LANGUAGE', 'es_AR'); $this->assertEquals($render->translate('abundle', 'message.some', array('arg1' => '1', 'arg2' => '2', 'arg3' => '3')), 'Este es un mensaje de prueba, arg1=1 arg2=2 arg3=3'); }
public function mainAction() { $modelAndView = new ModelAndView('layout'); $modelAndView->add(array('viewName' => 'home')); return $modelAndView; }
public function somethingSmartyAction() { $model = new ModelAndView('someSmarty'); $model->add(array('a' => 'b')); return $model; }
public function __construct($object, \Oak\Json\ISerializer $jsonUtils, array $headers = array()) { $options = array('json' => $jsonUtils->serialize($object), 'headers' => \array_merge(array('Cache-Control: no-cache, must-revalidate', 'Expires: Mon, 26 Jul 1997 05:00:00 GMT', 'Content-type: application/json'), $headers)); parent::__construct('json/common', $options); }