33namespace Flextype \Plugin \Admin \Controllers ;
44
55use Flextype \Component \Filesystem \Filesystem ;
6- use Flextype \ Component \ Session \ Session ;
6+
77use Flextype \Component \Arrays \Arrays ;
88use function Flextype \Component \I18n \__ ;
99use Respect \Validation \Validator as v ;
@@ -82,7 +82,7 @@ public function index(Request $request, Response $response) : Response
8282 }
8383 }
8484
85- $ entry_current = flextype ('entries ' )->fetch ($ this ->getEntryID ($ query ));
85+ $ entry_current = flextype ('entries ' )->fetchSingle ($ this ->getEntryID ($ query ))-> toArray ( );
8686
8787 if (isset ($ entry_current ['items_view ' ])) {
8888 $ items_view = $ entry_current ['items_view ' ];
@@ -92,12 +92,16 @@ public function index(Request $request, Response $response) : Response
9292
9393 $ entries_list = [];
9494 $ entries_collection = [];
95- $ entries_collection = collect (flextype ('entries ' )->fetchCollection ($ this ->getEntryID ($ query ), ['depth ' => ['1 ' ]]))->orderBy ('published_at ' , 'DESC ' )->all ();
95+ $ entries_collection = arrays (flextype ('entries ' )
96+ ->fetchCollection ($ this ->getEntryID ($ query ),
97+ ['depth ' => ['1 ' ]]))
98+ ->sortBy ('published_at ' , 'DESC ' )
99+ ->toArray ();
96100
97101 foreach ($ entries_collection as $ slug => $ body ) {
98102 $ entries_list [$ slug ] = $ body ;
99- if (find ()->in (PATH ['project ' ] . '/entries/ ' . $ slug )->depth ('>=1 ' )->depth ('<=2 ' )->hasResults ()) {
100- $ entries_list [$ slug ] += ['has_children ' => true ] ;
103+ if (filesystem ()-> find ()->in (PATH ['project ' ] . '/entries/ ' . $ slug )->depth ('>=1 ' )->depth ('<=2 ' )->hasResults ()) {
104+ $ entries_list [$ slug ]['has_children ' ] = true ;
101105 }
102106 }
103107
@@ -158,7 +162,7 @@ public function add(Request $request, Response $response) : Response
158162 $ response ,
159163 'plugins/admin/templates/content/entries/add.html ' ,
160164 [
161- 'entries_list ' => collect (flextype ('entries ' )->fetchCollection ($ this ->getEntryID ($ query )))->orderBy ('order_by ' , 'ASC ' )->all (),
165+ 'entries_list ' => arrays (flextype ('entries ' )->fetchCollection ($ this ->getEntryID ($ query )))->sortBy ('order_by ' , 'ASC ' )->toArray (),
162166 'menu_item ' => 'entries ' ,
163167 'current_id ' => $ this ->getEntryID ($ query ),
164168 'parts ' => $ parts ,
@@ -231,7 +235,7 @@ public function addProcess(Request $request, Response $response) : Response
231235 if (flextype ('fieldsets ' )->has ($ data ['fieldset ' ])) {
232236
233237 // Get fieldset
234- $ fieldset = flextype ('fieldsets ' )->fetch ($ data ['fieldset ' ]);
238+ $ fieldset = flextype ('fieldsets ' )->fetchSingle ($ data ['fieldset ' ]);
235239
236240 // Init entry data
237241 $ data_from_post = [];
@@ -332,7 +336,7 @@ public function type(Request $request, Response $response) : Response
332336 $ parts = [0 => '' ];
333337 }
334338
335- $ entry = flextype ('entries ' )->fetch ($ this ->getEntryID ($ query ));
339+ $ entry = flextype ('entries ' )->fetchSingle ($ this ->getEntryID ($ query ))-> toArray ( );
336340
337341 $ fieldsets = [];
338342
@@ -400,7 +404,7 @@ public function typeProcess(Request $request, Response $response) : Response
400404
401405 $ id = $ post_data ['id ' ];
402406
403- $ entry = flextype ('entries ' )->fetch ($ id );
407+ $ entry = flextype ('entries ' )->fetchSingle ($ id)-> toArray ( );
404408
405409 Arrays::delete ($ entry , 'slug ' );
406410 Arrays::delete ($ entry , 'id ' );
@@ -451,7 +455,7 @@ public function move(Request $request, Response $response) : Response
451455 $ entry_id_current = array_pop ($ parts );
452456
453457 // Fetch entry
454- $ entry = flextype ('entries ' )->fetch ($ this ->getEntryID ($ query ));
458+ $ entry = flextype ('entries ' )->fetchSingle ($ this ->getEntryID ($ query ))-> toArray ( );
455459
456460 // Set Entries IDs in parts
457461 if (isset ($ query ['id ' ])) {
@@ -462,7 +466,7 @@ public function move(Request $request, Response $response) : Response
462466
463467 // Get entries list
464468 $ entries_list ['/ ' ] = '/ ' ;
465- foreach (flextype ('entries ' )->fetchCollection ('' , ['depth ' => '>0 ' , 'order_by ' => ['field ' => ['id ' ]]]) as $ _entry ) {
469+ foreach (flextype ('entries ' )->fetchCollection ('' , ['depth ' => '>0 ' , 'order_by ' => ['field ' => ['id ' ]]])-> toArray () as $ _entry ) {
466470 if ($ _entry ['id ' ] != '' ) {
467471 $ entries_list [$ _entry ['id ' ]] = $ _entry ['id ' ];
468472 } else {
@@ -515,11 +519,11 @@ public function moveProcess(Request $request, Response $response)
515519 $ entry_id_current = $ data ['entry_id_current ' ];
516520
517521 if (!flextype ('entries ' )->has ($ data ['parent_entry ' ] . '/ ' . $ entry_id_current )) {
518- if (flextype ('entries ' )->rename (
522+ if (flextype ('entries ' )->move (
519523 $ data ['entry_id_path_current ' ],
520524 $ data ['parent_entry ' ] . '/ ' . $ entry_id_current
521525 )) {
522- flextype ('media_folders ' )->rename ('entries/ ' . $ data ['entry_id_path_current ' ], 'entries/ ' . $ data ['parent_entry ' ] . '/ ' . $ entry_id_current );
526+ flextype ('media_folders ' )->move ('entries/ ' . $ data ['entry_id_path_current ' ], 'entries/ ' . $ data ['parent_entry ' ] . '/ ' . $ entry_id_current );
523527
524528 flextype ('flash ' )->addMessage ('success ' , __ ('admin_message_entry_moved ' ));
525529 } else {
@@ -601,11 +605,11 @@ public function renameProcess(Request $request, Response $response) : Response
601605 $ name = $ data ['name ' ];
602606 }
603607
604- if (flextype ('entries ' )->rename (
608+ if (flextype ('entries ' )->move (
605609 $ data ['entry_path_current ' ],
606610 $ data ['entry_parent ' ] . '/ ' . $ name )
607611 ) {
608- flextype ('media_folders ' )->rename ('entries/ ' . $ data ['entry_path_current ' ], 'entries/ ' . $ data ['entry_parent ' ] . '/ ' . flextype ('slugify ' )->slugify ($ data ['name ' ]));
612+ flextype ('media_folders ' )->move ('entries/ ' . $ data ['entry_path_current ' ], 'entries/ ' . $ data ['entry_parent ' ] . '/ ' . flextype ('slugify ' )->slugify ($ data ['name ' ]));
609613 flextype ('flash ' )->addMessage ('success ' , __ ('admin_message_entry_renamed ' ));
610614 } else {
611615 flextype ('flash ' )->addMessage ('error ' , __ ('admin_message_entry_was_not_renamed ' ));
@@ -662,7 +666,9 @@ public function duplicateProcess(Request $request, Response $response) : Respons
662666 flextype ('media_folders ' )->copy ('entries/ ' . $ id , 'entries/ ' . $ id . '-duplicate- ' . $ random_date , true );
663667
664668 if (Filesystem::has (PATH ['project ' ] . '/uploads ' . '/entries/ ' . $ id )) {
665- Filesystem::copy (PATH ['project ' ] . '/uploads ' . '/entries/ ' . $ id , PATH ['project ' ] . '/uploads ' . '/entries/ ' . $ id . '-duplicate- ' . $ random_date , true );
669+ filesystem ()
670+ ->directory (PATH ['project ' ] . '/uploads ' . '/entries/ ' . $ id )
671+ ->copy (PATH ['project ' ] . '/uploads ' . '/entries/ ' . $ id . '-duplicate- ' . $ random_date );
666672 } else {
667673 Filesystem::createDir (PATH ['project ' ] . '/uploads ' . '/entries/ ' . $ id . '-duplicate- ' . $ random_date );
668674 }
@@ -698,7 +704,7 @@ public function edit(Request $request, Response $response) : Response
698704 flextype ('registry ' )->set ('entries.fields.parsers.settings.enabled ' , false );
699705
700706 // Get Entry
701- $ entry = flextype ('entries ' )->fetch ($ this ->getEntryID ($ query ));
707+ $ entry = flextype ('entries ' )->fetchSingle ($ this ->getEntryID ($ query ))-> toArray ( );
702708
703709 Arrays::delete ($ entry , 'slug ' );
704710 Arrays::delete ($ entry , 'id ' );
@@ -894,11 +900,10 @@ public function editProcess(Request $request, Response $response) : Response
894900 isset ($ data ['flatpickr-date-format ' ]) and Arrays::delete ($ data , 'flatpickr-date-format ' );
895901 isset ($ data ['flatpickr-locale ' ]) and Arrays::delete ($ data , 'flatpickr-locale ' );
896902
897-
898- $ data ['published_by ' ] = Session::get ('uuid ' );
903+ $ data ['published_by ' ] = flextype ('session ' )->get ('uuid ' );
899904
900905 // Fetch entry
901- $ entry = flextype ('entries ' )->fetch ($ id );
906+ $ entry = flextype ('entries ' )->fetchSingle ($ id)-> toArray ( );
902907 Arrays::delete ($ entry , 'slug ' );
903908 Arrays::delete ($ entry , 'id ' );
904909 Arrays::delete ($ entry , 'modified_at ' );
0 commit comments