@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @param string |
81 | 81 | * @param function |
82 | 82 | * |
83 | - * @return Blade |
|
83 | + * @return Templater |
|
84 | 84 | */ |
85 | 85 | public function addFunction($functionName, $callback) { |
86 | 86 | if($this->adapter_name == 'twig') { |
@@ -93,6 +93,7 @@ discard block |
||
93 | 93 | * Load adapter, currently we are using 2 adapters: twig and blade |
94 | 94 | * |
95 | 95 | * @var $adapter_name string Path to template folder. |
96 | + * @param string $adapter_name |
|
96 | 97 | * @return mixed |
97 | 98 | */ |
98 | 99 | public function loadAdapter($adapter_name) { |
@@ -134,7 +135,7 @@ discard block |
||
134 | 135 | * |
135 | 136 | * @var $app_name string Your application name, should be lowercase, letters only. |
136 | 137 | * |
137 | - * @return object \VA\Templater\Engine |
|
138 | + * @return Templater \VA\Templater\Engine |
|
138 | 139 | */ |
139 | 140 | public function setWordPressThemeSupport($app_name) { |
140 | 141 | // Path to templates folder in wordpress theme |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @var $adapter object Template Engine object |
23 | 23 | */ |
24 | - private $adapter = []; |
|
24 | + private $adapter = [ ]; |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Template adapter, it would be twig or any php template lib. |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @return Twig_Environment |
56 | 56 | */ |
57 | 57 | public function loadTwig() { |
58 | - if(!$this->adapter) { |
|
58 | + if (!$this->adapter) { |
|
59 | 59 | $loader = new Twig_Loader_Filesystem($this->dir_path); |
60 | 60 | $this->adapter = new Twig_Environment($loader, array( |
61 | 61 | |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | * @return Blade |
71 | 71 | */ |
72 | 72 | public function loadBlade() { |
73 | - $this->adapter = new Blade($this->dir_path,'/tmp');//second parameter is where cache view is located. |
|
73 | + $this->adapter = new Blade($this->dir_path, '/tmp'); //second parameter is where cache view is located. |
|
74 | 74 | return $this->adapter; |
75 | 75 | } |
76 | 76 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | * @return Blade |
84 | 84 | */ |
85 | 85 | public function addFunction($functionName, $callback) { |
86 | - if($this->adapter_name == 'twig') { |
|
86 | + if ($this->adapter_name == 'twig') { |
|
87 | 87 | $this->adapter->addFunction(new \Twig_SimpleFunction($functionName, $callback)); |
88 | 88 | } |
89 | 89 | return $this; |
@@ -96,11 +96,11 @@ discard block |
||
96 | 96 | * @return mixed |
97 | 97 | */ |
98 | 98 | public function loadAdapter($adapter_name) { |
99 | - if(!$this->adapter) { // |
|
99 | + if (!$this->adapter) { // |
|
100 | 100 | $method_name = 'load'.ucfirst($adapter_name); |
101 | - if(method_exists($this, $method_name)) { |
|
101 | + if (method_exists($this, $method_name)) { |
|
102 | 102 | $this->$method_name(); |
103 | - }else{ |
|
103 | + }else { |
|
104 | 104 | throw new \Exception("Could not load adapter $adapter_name"); |
105 | 105 | } |
106 | 106 | } |
@@ -115,14 +115,14 @@ discard block |
||
115 | 115 | * |
116 | 116 | * @return string Rendered HTML/text |
117 | 117 | */ |
118 | - public function render($template, $data = []) { |
|
119 | - if($this->adapter_name == 'twig') |
|
118 | + public function render($template, $data = [ ]) { |
|
119 | + if ($this->adapter_name == 'twig') |
|
120 | 120 | { |
121 | 121 | return $this->adapter->render($template, $data); |
122 | 122 | } |
123 | - elseif($this->adapter_name == 'blade') |
|
123 | + elseif ($this->adapter_name == 'blade') |
|
124 | 124 | { |
125 | - return $this->adapter->view()->make($template,$data)->render(); |
|
125 | + return $this->adapter->view()->make($template, $data)->render(); |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
@@ -138,16 +138,16 @@ discard block |
||
138 | 138 | */ |
139 | 139 | public function setWordPressThemeSupport($app_name) { |
140 | 140 | // Path to templates folder in wordpress theme |
141 | - $theme_template_path = get_template_directory() . '/templates/'. $app_name; |
|
141 | + $theme_template_path = get_template_directory().'/templates/'.$app_name; |
|
142 | 142 | |
143 | 143 | // Create folder path if it does not exists. |
144 | - if(!file_exists($theme_template_path)) { |
|
144 | + if (!file_exists($theme_template_path)) { |
|
145 | 145 | wp_mkdir_p($theme_template_path); |
146 | 146 | } |
147 | 147 | |
148 | 148 | // Preapare template folders |
149 | 149 | $template_folders = [ |
150 | - $theme_template_path, // Load this path first |
|
150 | + $theme_template_path, // Load this path first |
|
151 | 151 | $this->dir_path // Load this path second |
152 | 152 | ]; |
153 | 153 | $loader = new \Twig_Loader_Filesystem($template_folders); |