Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,11 @@ jobs:
# verbose: true

- name: Upload logs as artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: mautic-logs
name: mautic-logs-${{ matrix.php-versions }}-${{ github.run_id }}
path: var/logs/
if-no-files-found: warn
compression-level: 6
overwrite: false
include-hidden-files: false
1 change: 0 additions & 1 deletion Config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,6 @@
'class' => ConfigProvider::class,
'arguments' => [
'mautic.helper.core_parameters',
'database_connection',
],
],
'custom_field.type.provider' => [
Expand Down
29 changes: 2 additions & 27 deletions Provider/ConfigProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@

namespace MauticPlugin\CustomObjectsBundle\Provider;

use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Exception;
use Mautic\CoreBundle\Helper\CoreParametersHelper;
use MauticPlugin\CustomObjectsBundle\Entity\CustomObject;

class ConfigProvider
{
/**
* @var string
*/
public const CONFIG_PLUGIN_NAME = 'CustomObjectsBundle';
public const CONFIG_PARAM_ENABLED = 'custom_objects_enabled';
public const CONFIG_PARAM_ITEM_VALUE_TO_CONTACT_RELATION_LIMIT = 'custom_object_item_value_to_contact_relation_limit';

Expand All @@ -25,38 +21,17 @@ class ConfigProvider
*/
private $coreParametersHelper;

/**
* @var Connection
*/
private $connection;

public function __construct(CoreParametersHelper $coreParametersHelper, Connection $connection)
public function __construct(CoreParametersHelper $coreParametersHelper)
{
$this->coreParametersHelper = $coreParametersHelper;
$this->connection = $connection;
}

/**
* Returns true if the Custom Objects plugin is enabled.
*/
public function pluginIsEnabled(): bool
{
$pluginEnabled = (bool) $this->coreParametersHelper->get(self::CONFIG_PARAM_ENABLED, true);
if (!$pluginEnabled) {
return false;
}

try {
$pluginWasInstalledBefore = $this->connection
->executeQuery('SELECT id FROM plugins WHERE bundle=:pluginName', ['pluginName' => self::CONFIG_PLUGIN_NAME])
->rowCount();
$customObjectsTableExists = $this->connection
->executeQuery('SHOW TABLES LIKE :tableName', ['tableName' => CustomObject::TABLE_NAME])
->rowCount();
return $pluginWasInstalledBefore && $customObjectsTableExists;
} catch (Exception $e) {
return false;
}
return (bool) $this->coreParametersHelper->get(self::CONFIG_PARAM_ENABLED, true);
}

public function isCustomObjectMergeFilterEnabled(): bool
Expand Down
4 changes: 0 additions & 4 deletions Security/Permissions/CustomObjectPermissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ public function __construct(
*/
public function definePermissions(): void
{
if (!$this->isEnabled()) {
return;
}

$this->addExtendedPermissions(['custom_fields', self::NAME]);

$customObjects = $this->getCustomObjects();
Expand Down