Skip to content

Commit f5e7548

Browse files
authored
Fix missing class error (#8)
* Fix missing class error * Add empty line
1 parent e898eeb commit f5e7548

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

common/templates/config_form.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?php
22

33
use PrestaShop\PrestaShop\Core\Addon\Module\ModuleManager;
4-
use PrestaShop\PrestaShop\Core\Addon\Module\ModuleManagerBuilder;
54

65
if (!defined('_PS_VERSION_')) {
76
exit;
@@ -111,16 +110,15 @@
111110
type="checkbox"
112111
name="sync_prod_reviews"
113112
<?= $module->getConfigValue('SYNC_PROD_REVIEWS') ? 'checked ' : ''; ?>
114-
<?= !moduleManager()->isInstalled('productcomments') || !moduleManager()->isEnabled('productcomments') ? 'disabled' : '' ?>
115113
/>
116114
<?= $module->l('Sync product reviews to PrestaShop', 'config_form') ?>
117115
</label>
118116

119-
<?php if (moduleManager()->isEnabled('productcomments')): ?>
117+
<?php if (hasProductCommentsModule()): ?>
120118
<p class="preference_description">
121119
<?= sprintf($module->l('Automatically display product reviews collected using %s on your PrestaShop store', 'config_form'), $module->getDisplayName()); ?>
122120
</p>
123-
<?php elseif(!moduleManager()->isInstalled('productcomments')): ?>
121+
<?php elseif(!hasProductCommentsModule()): ?>
124122
<div class="custom_alert_danger">Please install the <a href="https://addons.prestashop.com/en/undownloadable/9144-product-comments.html">Product Comments</a> module to use this option.</div>
125123
<?php else: ?>
126124
<div class="custom_alert_warning">Please enable the Product Comments module to use this option.</div>
@@ -195,8 +193,13 @@
195193
<?php endif; ?>
196194

197195
<?php
198-
function moduleManager() {
199-
$moduleManagerBuilder = ModuleManagerBuilder::getInstance();
200-
return $moduleManagerBuilder->build();
196+
function hasProductCommentsModule() {
197+
if (!class_exists('PrestaShop\PrestaShop\Core\Addon\Module\ModuleManagerBuilder')) {
198+
return false;
199+
}
200+
$moduleManagerBuilder = PrestaShop\PrestaShop\Core\Addon\Module\ModuleManagerBuilder::getInstance();
201+
$moduleManager = $moduleManagerBuilder->build();
202+
return $moduleManager->isInstalled('productcomments');
201203
}
202-
?>
204+
?>
205+

0 commit comments

Comments
 (0)