6
6
use NewfoldLabs \WP \Module \Onboarding \Data \Options ;
7
7
use NewfoldLabs \WP \Module \Onboarding \Data \Services \PreviewsService ;
8
8
use NewfoldLabs \WP \Module \Onboarding \Data \Services \SiteGenService as LegacySiteGenService ;
9
- use NewfoldLabs \WP \Module \Onboarding \Data \ Services \FlowService ;
9
+ use NewfoldLabs \WP \Module \Onboarding \Services \SiteInfoService ;
10
10
11
11
12
12
use function NewfoldLabs \WP \ModuleLoader \container ;
13
13
14
+ /**
15
+ * App Service for handling onboarding application lifecycle.
16
+ *
17
+ * This service manages the start and completion of the onboarding process,
18
+ * including initialization of required services, publishing selected content,
19
+ * and saving site information for other modules to access.
20
+ */
14
21
class AppService {
15
22
16
23
/**
@@ -46,13 +53,13 @@ public function start(): void {
46
53
*
47
54
* @param string $selected_sitegen_homepage The selected sitegen homepage to publish.
48
55
* @return void
49
- * @throws \Exception
56
+ * @throws \Exception When homepage publishing fails.
50
57
*/
51
58
public function complete ( string $ selected_sitegen_homepage ): void {
52
59
// Publish selected homepage.
53
60
$ result = ( new SiteGenService () )->publish_homepage ( $ selected_sitegen_homepage );
54
61
if ( \is_wp_error ( $ result ) ) {
55
- throw new \Exception ( $ result ->get_error_message () );
62
+ throw new \Exception ( esc_html ( $ result ->get_error_message () ) );
56
63
}
57
64
// Trash Preview pages.
58
65
PreviewsService::trash_preview_pages ();
@@ -73,8 +80,8 @@ public function complete( string $selected_sitegen_homepage ): void {
73
80
array (
74
81
'label_key ' => 'value ' ,
75
82
),
76
- __ ( 'Help us improve ' , 'wp-module-onboarding-data ' ),
77
- __ ( 'How satisfied were you with the ease of creating your website? ' , 'wp-module-onboarding-data ' ),
83
+ __ ( 'Help us improve ' , 'wp-module-onboarding ' ),
84
+ __ ( 'How satisfied were you with the ease of creating your website? ' , 'wp-module-onboarding ' ),
78
85
);
79
86
}
80
87
}
0 commit comments