@@ -79,6 +79,7 @@ discard block |
||
79 | 79 | * Load adapter, currently we are using 2 adapters: twig and blade |
80 | 80 | * |
81 | 81 | * @var $adapter_name string Path to template folder. |
82 | + * @param string $adapter_name |
|
82 | 83 | * @return Twig_Environment || Blade |
83 | 84 | */ |
84 | 85 | public function loadAdapter($adapter_name) { |
@@ -121,7 +122,7 @@ discard block |
||
121 | 122 | * |
122 | 123 | * @var $app_name string Your application name, should be lowercase, letters only. |
123 | 124 | * |
124 | - * @return object \VA\Templater\Engine |
|
125 | + * @return Templater \VA\Templater\Engine |
|
125 | 126 | */ |
126 | 127 | public function setWordPressThemeSupport($app_name) { |
127 | 128 | // Path to templates folder in wordpress theme |
@@ -134,12 +134,12 @@ |
||
134 | 134 | |
135 | 135 | // Preapare template folders |
136 | 136 | $template_folders = [ |
137 | - $theme_template_path, // Load this path first |
|
138 | - $this->dir_path // Load this path second |
|
139 | - ]; |
|
140 | - $loader = new \Twig_Loader_Filesystem($template_folders); |
|
141 | - $this->adapter->setLoader($loader); |
|
142 | - return $this; |
|
137 | + $theme_template_path, // Load this path first |
|
138 | + $this->dir_path // Load this path second |
|
139 | + ]; |
|
140 | + $loader = new \Twig_Loader_Filesystem($template_folders); |
|
141 | + $this->adapter->setLoader($loader); |
|
142 | + return $this; |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | } |
146 | 146 | \ No newline at end of file |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | * @return Twig_Environment |
57 | 57 | */ |
58 | 58 | public function loadTwig() { |
59 | - if(!$this->adapter) { |
|
59 | + if (!$this->adapter) { |
|
60 | 60 | $loader = new Twig_Loader_Filesystem($this->dir_path); |
61 | 61 | $this->adapter = new Twig_Environment($loader, array( |
62 | 62 | |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * @return Blade |
72 | 72 | */ |
73 | 73 | public function loadBlade() { |
74 | - $this->adapter = new Blade($this->dir_path,'/tmp');//second parameter is where cache view is located. |
|
74 | + $this->adapter = new Blade($this->dir_path, '/tmp'); //second parameter is where cache view is located. |
|
75 | 75 | return $this->adapter; |
76 | 76 | } |
77 | 77 | |
@@ -82,11 +82,11 @@ discard block |
||
82 | 82 | * @return Twig_Environment || Blade |
83 | 83 | */ |
84 | 84 | public function loadAdapter($adapter_name) { |
85 | - if(!$this->adapter) { // |
|
85 | + if (!$this->adapter) { // |
|
86 | 86 | $method_name = 'load'.ucfirst($adapter_name); |
87 | - if(method_exists($this, $method_name)) { |
|
87 | + if (method_exists($this, $method_name)) { |
|
88 | 88 | $this->$method_name(); |
89 | - }else{ |
|
89 | + }else { |
|
90 | 90 | exit; |
91 | 91 | //throw new \Exception(__("Could not load adapter $adapter_name", "va-templater")); |
92 | 92 | } |
@@ -102,14 +102,14 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @return string Rendered HTML/text |
104 | 104 | */ |
105 | - public function render($template, $data = []) { |
|
106 | - if($this->adapter_name == 'twig') |
|
105 | + public function render($template, $data = [ ]) { |
|
106 | + if ($this->adapter_name == 'twig') |
|
107 | 107 | { |
108 | 108 | return $this->adapter->render($template, $data); |
109 | 109 | } |
110 | - elseif($this->adapter_name == 'blade') |
|
110 | + elseif ($this->adapter_name == 'blade') |
|
111 | 111 | { |
112 | - return $this->adapter->view()->make($template,$data)->render(); |
|
112 | + return $this->adapter->view()->make($template, $data)->render(); |
|
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
@@ -125,16 +125,16 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function setWordPressThemeSupport($app_name) { |
127 | 127 | // Path to templates folder in wordpress theme |
128 | - $theme_template_path = get_template_directory() . '/templates/'. $app_name; |
|
128 | + $theme_template_path = get_template_directory().'/templates/'.$app_name; |
|
129 | 129 | |
130 | 130 | // Create folder path if it does not exists. |
131 | - if(!file_exists($theme_template_path)) { |
|
131 | + if (!file_exists($theme_template_path)) { |
|
132 | 132 | wp_mkdir_p($theme_template_path); |
133 | 133 | } |
134 | 134 | |
135 | 135 | // Preapare template folders |
136 | 136 | $template_folders = [ |
137 | - $theme_template_path, // Load this path first |
|
137 | + $theme_template_path, // Load this path first |
|
138 | 138 | $this->dir_path // Load this path second |
139 | 139 | ]; |
140 | 140 | $loader = new \Twig_Loader_Filesystem($template_folders); |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | $method_name = 'load'.ucfirst($adapter_name); |
87 | 87 | if(method_exists($this, $method_name)) { |
88 | 88 | $this->$method_name(); |
89 | - }else{ |
|
89 | + } else{ |
|
90 | 90 | exit; |
91 | 91 | //throw new \Exception(__("Could not load adapter $adapter_name", "va-templater")); |
92 | 92 | } |
@@ -106,8 +106,7 @@ discard block |
||
106 | 106 | if($this->adapter_name == 'twig') |
107 | 107 | { |
108 | 108 | return $this->adapter->render($template, $data); |
109 | - } |
|
110 | - elseif($this->adapter_name == 'blade') |
|
109 | + } elseif($this->adapter_name == 'blade') |
|
111 | 110 | { |
112 | 111 | return $this->adapter->view()->make($template,$data)->render(); |
113 | 112 | } |
@@ -39,6 +39,7 @@ discard block |
||
39 | 39 | * Load Twig as default adapter |
40 | 40 | * |
41 | 41 | * @var $dir_path string Path to template folder. |
42 | + * @param string $dir_path |
|
42 | 43 | * @return Twig_Environment |
43 | 44 | */ |
44 | 45 | public function loadTwig($dir_path) { |
@@ -72,7 +73,7 @@ discard block |
||
72 | 73 | * |
73 | 74 | * @var $app_name string Your application name, should be lowercase, letters only. |
74 | 75 | * |
75 | - * @return object \VA\Templater\Engine |
|
76 | + * @return Engine \VA\Templater\Engine |
|
76 | 77 | */ |
77 | 78 | public function setWordPressThemeSupport($app_name) { |
78 | 79 | $template_folders = [ |
@@ -76,12 +76,12 @@ |
||
76 | 76 | */ |
77 | 77 | public function setWordPressThemeSupport($app_name) { |
78 | 78 | $template_folders = [ |
79 | - get_template_directory() . '/templates/'. $app_name, |
|
80 | - $this->dir_path |
|
81 | - ]; |
|
82 | - $loader = new \Twig_Loader_Filesystem($template_folders); |
|
83 | - $this->adapter->setLoader($loader); |
|
84 | - return $this; |
|
79 | + get_template_directory() . '/templates/'. $app_name, |
|
80 | + $this->dir_path |
|
81 | + ]; |
|
82 | + $loader = new \Twig_Loader_Filesystem($template_folders); |
|
83 | + $this->adapter->setLoader($loader); |
|
84 | + return $this; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | } |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | * @return Twig_Environment |
43 | 43 | */ |
44 | 44 | public function loadTwig($dir_path) { |
45 | - if(!$this->adapter) { |
|
45 | + if (!$this->adapter) { |
|
46 | 46 | $loader = new \Twig_Loader_Filesystem($dir_path); |
47 | 47 | $this->adapter = new \Twig_Environment($loader, array( |
48 | 48 | |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | */ |
77 | 77 | public function setWordPressThemeSupport($app_name) { |
78 | 78 | $template_folders = [ |
79 | - get_template_directory() . '/templates/'. $app_name, |
|
79 | + get_template_directory().'/templates/'.$app_name, |
|
80 | 80 | $this->dir_path |
81 | 81 | ]; |
82 | 82 | $loader = new \Twig_Loader_Filesystem($template_folders); |