@@ -31,51 +31,7 @@ trait UseDisplayBackOfficeHeader
3131{
3232 public function hookDisplayBackOfficeHeader (): string
3333 {
34- $ controller = \Tools::getValue ('controller ' );
35- $ minimizedGuideHtml = '' ;
36- if ($ controller !== 'AdminPsClassicEditionHomepageController ' ) {
37- $ setupGuideDataPresenter = \Context::getContext ()->controller ->getContainer ()->get (SetupGuideDataPresenter::class);
38- $ setupData = $ setupGuideDataPresenter ->getSetupGuideData ();
39- $ remainingStepsToComplete = false ;
40- foreach ($ setupData as $ setupStep ) {
41- if (!$ setupStep ['isCompleted ' ]) {
42- $ remainingStepsToComplete = true ;
43- break ;
44- }
45- }
46-
47- // Only display the minimized setup guide when there are remaining steps to finish
48- if ($ remainingStepsToComplete ) {
49- // Init URLs for setup guide
50- $ router = \Context::getContext ()->controller ->getContainer ()->get ('router ' );
51- $ setupGuideApiUrl = $ router ->generate ('ps_classic_edition_setup_guide_api_index ' , [], UrlGeneratorInterface::ABSOLUTE_URL );
52- $ setupGuideApiUrlEdit = $ router ->generate ('ps_classic_edition_setup_guide_api_edit ' , [], UrlGeneratorInterface::ABSOLUTE_URL );
53-
54- // Init accounts
55- $ psAccountHelper = \Context::getContext ()->controller ->getContainer ()->get (PsAccountHelper::class);
56- $ psAccountsSettings = $ psAccountHelper ->loadAccountSettings ();
57- $ urlAccountsCdn = $ psAccountsSettings ['urlAccountsCdn ' ];
58- $ accountsUserToken = $ psAccountsSettings ['accountUserToken ' ];
59- $ psShopID = $ psAccountsSettings ['psShopID ' ];
60- $ psAccountID = $ psAccountsSettings ['psAccountID ' ];
61-
62- // Include the minimized setup guide (only if some steps are still needed)
63- $ baseLink = \Context::getContext ()->link ->getAdminBaseLink ();
64- $ minimizedGuideHtml = '<script type="module" src=" ' . $ baseLink . '/modules/ps_classic_edition/views/js/vue/assets/index.js"></script> ' ;
65- $ minimizedGuideHtml .= PHP_EOL . "
66- <script src= \"$ urlAccountsCdn \" rel= \"preload \"></script>
67- <script>
68- window.minimizedGuideContext = {
69- \"SETUP_GUIDE_API_URL \": \"$ setupGuideApiUrl \",
70- \"SETUP_GUIDE_API_URL_EDIT \": \"$ setupGuideApiUrlEdit \",
71- \"'userToken \": \"$ accountsUserToken \",
72- \"psAccountShopID \": \"$ psShopID \",
73- \"psAccountID \": \"$ psAccountID \"
74- };
75- </script>
76- " ;
77- }
78- }
34+ $ minimizedGuideHtml = $ this ->getMinimizedGuideHtml ();
7935
8036 return <<<END
8137 {$ minimizedGuideHtml }
@@ -85,4 +41,62 @@ public function hookDisplayBackOfficeHeader(): string
8541 </script>
8642 END ;
8743 }
44+
45+ private function getMinimizedGuideHtml (): string
46+ {
47+ $ controller = \Tools::getValue ('controller ' );
48+ if ($ controller === 'AdminPsClassicEditionHomepageController ' ) {
49+ return '' ;
50+ }
51+
52+ if ((bool ) \Configuration::get ('PS_SETUP_GUIDE_MODAL_IS_HIDDEN ' )) {
53+ return '' ;
54+ }
55+
56+ $ setupGuideDataPresenter = \Context::getContext ()->controller ->getContainer ()->get (SetupGuideDataPresenter::class);
57+ $ setupData = $ setupGuideDataPresenter ->getSetupGuideData ();
58+ $ remainingStepsToComplete = false ;
59+ foreach ($ setupData as $ setupStep ) {
60+ if (!$ setupStep ['isCompleted ' ]) {
61+ $ remainingStepsToComplete = true ;
62+ break ;
63+ }
64+ }
65+
66+ // Only display the minimized setup guide when there are remaining steps to finish
67+ if (!$ remainingStepsToComplete ) {
68+ return '' ;
69+ }
70+
71+ // Init URLs for setup guide
72+ $ router = \Context::getContext ()->controller ->getContainer ()->get ('router ' );
73+ $ setupGuideApiUrl = $ router ->generate ('ps_classic_edition_setup_guide_api_index ' , [], UrlGeneratorInterface::ABSOLUTE_URL );
74+ $ setupGuideApiUrlEdit = $ router ->generate ('ps_classic_edition_setup_guide_api_edit ' , [], UrlGeneratorInterface::ABSOLUTE_URL );
75+
76+ // Init accounts
77+ $ psAccountHelper = \Context::getContext ()->controller ->getContainer ()->get (PsAccountHelper::class);
78+ $ psAccountsSettings = $ psAccountHelper ->loadAccountSettings ();
79+ $ urlAccountsCdn = $ psAccountsSettings ['urlAccountsCdn ' ];
80+ $ accountsUserToken = $ psAccountsSettings ['accountUserToken ' ];
81+ $ psShopID = $ psAccountsSettings ['psShopID ' ];
82+ $ psAccountID = $ psAccountsSettings ['psAccountID ' ];
83+
84+ // Include the minimized setup guide (only if some steps are still needed)
85+ $ baseLink = \Context::getContext ()->link ->getAdminBaseLink ();
86+ $ minimizedGuideHtml = '<script type="module" src=" ' . $ baseLink . '/modules/ps_classic_edition/views/js/vue/assets/index.js"></script> ' ;
87+ $ minimizedGuideHtml .= PHP_EOL . "
88+ <script src= \"$ urlAccountsCdn \" rel= \"preload \"></script>
89+ <script>
90+ window.minimizedGuideContext = {
91+ \"SETUP_GUIDE_API_URL \": \"$ setupGuideApiUrl \",
92+ \"SETUP_GUIDE_API_URL_EDIT \": \"$ setupGuideApiUrlEdit \",
93+ \"'userToken \": \"$ accountsUserToken \",
94+ \"psAccountShopID \": \"$ psShopID \",
95+ \"psAccountID \": \"$ psAccountID \"
96+ };
97+ </script>
98+ " ;
99+
100+ return $ minimizedGuideHtml ;
101+ }
88102}
0 commit comments