コード例 #1
0
ファイル: Test_ModelAndView.php プロジェクト: im286er/Ding
 /**
  * @test
  */
 public function can_get_set_model()
 {
     $mav = new ModelAndView('name');
     $mav->add(array('key1' => 'value1'));
     $model = $mav->getModel();
     $this->assertEquals($model['key1'], 'value1');
 }
コード例 #2
0
ファイル: Exception.php プロジェクト: im286er/Ding
 public function _ExceptionException($exception)
 {
     $modelAndView = new ModelAndView('layout');
     $modelAndView->add(array('viewName' => 'exception'));
     $modelAndView->add(array('exception' => $exception));
     return $modelAndView;
 }
コード例 #3
0
ファイル: example.php プロジェクト: im286er/Ding
 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;
 }
コード例 #4
0
ファイル: HttpViewResolver.php プロジェクト: im286er/Ding
 /**
  * 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);
 }
コード例 #5
0
ファイル: Test_HttpView.php プロジェクト: im286er/Ding
 /**
  * @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');
 }
コード例 #6
0
ファイル: Main.php プロジェクト: im286er/Ding
 public function mainAction()
 {
     $modelAndView = new ModelAndView('layout');
     $modelAndView->add(array('viewName' => 'home'));
     return $modelAndView;
 }
コード例 #7
0
 public function somethingSmartyAction()
 {
     $model = new ModelAndView('someSmarty');
     $model->add(array('a' => 'b'));
     return $model;
 }
コード例 #8
0
 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);
 }