2
2
3
3
namespace ModularityFormBuilder \Entity ;
4
4
5
+ use ModularityFormBuilder \Blade \Blade ;
5
6
use ModularityFormBuilder \Helper \NestedFields ;
6
7
7
8
class PostType
@@ -11,7 +12,7 @@ class PostType
11
12
public $ namePlural ;
12
13
public $ args ;
13
14
14
- public function __construct ($ postTypeSlug , $ nameSingular , $ namePlural , $ args = array ())
15
+ public function __construct (private Blade $ bladeInstance , $ postTypeSlug , $ nameSingular , $ namePlural , $ args = array ())
15
16
{
16
17
$ this ->postTypeSlug = $ postTypeSlug ;
17
18
$ this ->nameSingular = $ nameSingular ;
@@ -295,10 +296,8 @@ public function formdataDisplay()
295
296
if (!$ this ->isGrantedUser ($ data ['module_id ' ])) {
296
297
//Error message
297
298
$ this ->renderBlade (
298
- 'unauthorized.blade.php ' ,
299
- array (
300
- FORM_BUILDER_MODULE_PATH . 'source/php/Module/views/admin '
301
- ),
299
+ 'unauthorized ' ,
300
+ '/admin ' ,
302
301
array (
303
302
'title ' => __ ("Access denied " , 'modularity-form-builder ' ),
304
303
'message ' => __ ("You don't have the sufficient permissions to view this post. " , 'modularity-form-builder ' ),
@@ -328,10 +327,8 @@ public function formdataDisplay()
328
327
if (is_admin () && isset ($ fields ['editable_back_end ' ]) && $ fields ['editable_back_end ' ] == true ) {
329
328
//Editable
330
329
$ this ->renderBlade (
331
- 'form-edit.blade.php ' ,
332
- array (
333
- FORM_BUILDER_MODULE_PATH . 'source/php/Module/views '
334
- ),
330
+ 'form-edit ' ,
331
+ '' ,
335
332
$ data
336
333
);
337
334
} elseif (self ::editableFrontend ($ post )) {
@@ -348,28 +345,22 @@ public function formdataDisplay()
348
345
349
346
//Static
350
347
$ this ->renderBlade (
351
- 'form-data.blade.php ' ,
352
- array (
353
- FORM_BUILDER_MODULE_PATH . 'source/php/Module/views/admin '
354
- ),
348
+ 'form-data ' ,
349
+ '/admin ' ,
355
350
$ data
356
351
);
357
352
358
353
//Editable
359
354
$ this ->renderBlade (
360
- 'form-edit-front.blade.php ' ,
361
- array (
362
- FORM_BUILDER_MODULE_PATH . 'source/php/Module/views '
363
- ),
355
+ 'form-edit-front ' ,
356
+ "" ,
364
357
$ data
365
358
);
366
359
} else {
367
360
//Static
368
361
$ this ->renderBlade (
369
- 'form-data.blade.php ' ,
370
- array (
371
- FORM_BUILDER_MODULE_PATH . 'source/php/Module/views/admin '
372
- ),
362
+ 'form-data ' ,
363
+ '/admin ' ,
373
364
$ data
374
365
);
375
366
}
@@ -529,15 +520,16 @@ private static function findMatchingNestedIndataArrayValue(&$nestedIndataArray,
529
520
* @param array $path Array with file paths
530
521
* @param array $data Template data
531
522
*/
532
- public function renderBlade ($ fileName , $ path , $ data = array ())
523
+ public function renderBlade (string $ viewName , string $ path = '' , $ data = array ())
533
524
{
534
- add_filter ('Municipio/blade/view_paths ' , array ($ this , 'addViewPaths ' ), 2 , 1 );
535
- $ template = new \Municipio \template ();
536
- $ view = \Municipio \Helper \Template::locateTemplate ($ fileName , $ path );
537
- $ view = $ template ->cleanViewPath ($ fileName );
538
- if (function_exists ('render_blade_view ' )) {
539
- echo render_blade_view ($ view , $ data );
540
- }
525
+ $ html = $ this ->bladeInstance ->render (
526
+ $ viewName ,
527
+ $ data ,
528
+ true ,
529
+ [FORM_BUILDER_MODULE_VIEW_PATH . $ path ]
530
+ );
531
+
532
+ echo $ html ;
541
533
}
542
534
543
535
/**
0 commit comments