Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
SimpleViewAsyncController.php
Go to the documentation of this file.
1<?php
2
4
15 protected static $views = [ ];
16
17 protected function _includeFileAsString($filename, $pdata) {
18 $key = \md5 ( \json_encode ( $pdata ) );
19 if (! isset ( self::$views [$filename] [$key] )) {
20 if (isset ( $pdata )) {
21 \extract ( $pdata );
22 }
23 \ob_start ();
24 include ($filename);
25 return self::$views [$filename] [$key] = \ob_get_clean ();
26 }
27 return self::$views [$filename] [$key];
28 }
29
41 public function loadView(string $viewName, $pData = NULL, bool $asString = false) {
42 $filename = \ROOT . \DS . 'views' . \DS . $viewName;
43 if ($asString) {
44 return $this->_includeFileAsString ( $filename, $pData );
45 }
46 echo $this->_includeFileAsString ( $filename, $pData );
47 }
48}
Default controller displaying php views only with an async server (Swoole, workerman).
loadView(string $viewName, $pData=NULL, bool $asString=false)
Loads the php view $viewName possibly passing the variables $pdata.
Default controller displaying php views only.