Skip to content

Commit

Permalink
Fix broken installation. (#61)
Browse files Browse the repository at this point in the history
Added condition check to validate if mautic is installed or not.
  • Loading branch information
mohit-rocks authored Feb 21, 2021
1 parent 0b9b2fa commit 65b96cd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions Config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
'class' => \MauticPlugin\GrapesJsBuilderBundle\EventSubscriber\AssetsSubscriber::class,
'arguments' => [
'grapesjsbuilder.config',
'mautic.install.service',
],
],
'grapesjsbuilder.event.email.subscriber' => [
Expand Down
7 changes: 6 additions & 1 deletion EventSubscriber/AssetsSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Mautic\CoreBundle\CoreEvents;
use Mautic\CoreBundle\Event\CustomAssetsEvent;
use Mautic\InstallBundle\Install\InstallService;
use MauticPlugin\GrapesJsBuilderBundle\Integration\Config;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

Expand All @@ -16,9 +17,10 @@ class AssetsSubscriber implements EventSubscriberInterface
*/
private $config;

public function __construct(Config $config)
public function __construct(Config $config, InstallService $installer)
{
$this->config = $config;
$this->installer = $installer;
}

public static function getSubscribedEvents()
Expand All @@ -30,6 +32,9 @@ public static function getSubscribedEvents()

public function injectAssets(CustomAssetsEvent $assetsEvent)
{
if (!$this->installer->checkIfInstalled()) {
return;
}
if ($this->config->isPublished()) {
$assetsEvent->addScript('plugins/GrapesJsBuilderBundle/Assets/library/js/builder.js');
$assetsEvent->addScript('plugins/GrapesJsBuilderBundle/Assets/library/js/grapes.min.js');
Expand Down

0 comments on commit 65b96cd

Please sign in to comment.