Skip to content

Commit

Permalink
updating uploads helper
Browse files Browse the repository at this point in the history
  • Loading branch information
iruzevic committed Jan 4, 2024
1 parent cc4a11a commit 816c21b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
4 changes: 4 additions & 0 deletions src/Config/UtilsConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ class UtilsConfig
public const FILTER_PUBLIC_FILTERS_DATA = self::FILTER_PREFIX . '_public_filters_data';
public const FILTER_SETTINGS_NONE_TRANSLATABLE_NAMES = self::FILTER_PREFIX . '_settings_none_translatable_names';

public const INTEGRATION_TYPE_DEFAULT = 'default';
public const INTEGRATION_TYPE_NO_BUILDER = 'no-builder';
public const INTEGRATION_TYPE_COMPLEX = 'complex';

/**
* API validator output key.
*
Expand Down
15 changes: 4 additions & 11 deletions src/Helpers/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@

namespace EightshiftForms\Helpers;

use EightshiftForms\Hooks\Filters;
use EightshiftForms\Integrations\ActiveCampaign\SettingsActiveCampaign;
use EightshiftForms\Integrations\Jira\SettingsJira;
use EightshiftForms\Integrations\Mailer\SettingsMailer;
use EightshiftForms\Integrations\Pipedrive\SettingsPipedrive;
use EightshiftForms\Troubleshooting\SettingsDebug;
use EightshiftFormsUtils\Config\UtilsConfig;
use EightshiftFormsUtilsVendor\EightshiftLibs\Helpers\Components;
use RecursiveArrayIterator;
Expand Down Expand Up @@ -395,15 +389,16 @@ public static function getFormDetailsById(string $formId): array

$output['type'] = $type;
$output['typeFilter'] = $blockName['name'];
$output['integrationType'] = $settings['integrationType'] ?? '';
$output['label'] = $settings['labels']['title'] ?? '';
$output['icon'] = $settings['labels']['icon'] ?? '';
$output['itemId'] = $blocks['innerBlocks'][0]['attrs']["{$type}IntegrationId"] ?? '';
$output['innerId'] = $blocks['innerBlocks'][0]['attrs']["{$type}IntegrationInnerId"] ?? '';
$output['fields'] = $blocks;
$output['fieldsOnly'] = $fieldsOnly;

switch ($output['typeFilter']) {
case SettingsActiveCampaign::SETTINGS_TYPE_KEY:
switch ($output['integrationType']) {
case UtilsConfig::INTEGRATION_TYPE_COMPLEX:
if ($output['itemId'] && $output['type'] && $output['innerId']) {
$output['isValid'] = true;

Expand All @@ -412,9 +407,7 @@ public static function getFormDetailsById(string $formId): array
}
}
break;
case SettingsMailer::SETTINGS_TYPE_KEY:
case SettingsJira::SETTINGS_TYPE_KEY:
case SettingsPipedrive::SETTINGS_TYPE_KEY:
case UtilsConfig::INTEGRATION_TYPE_NO_BUILDER:
if ($output['type']) {
$output['isValid'] = true;

Expand Down
7 changes: 3 additions & 4 deletions src/Helpers/SettingsOutputHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

namespace EightshiftForms\Helpers;

use EightshiftForms\Hooks\Filters;
use EightshiftFormsUtils\Config\UtilsConfig;

/**
Expand All @@ -30,7 +29,7 @@ final class SettingsOutputHelper
*/
public static function getIntro(string $type): array
{
$data = \apply_filters(Filters::FILTER_SETTINGS_DATA, [])[$type]['labels'] ?? [];
$data = \apply_filters(UtilsConfig::FILTER_SETTINGS_DATA, [])[$type]['labels'] ?? [];

if (!$data) {
return [];
Expand Down Expand Up @@ -70,7 +69,7 @@ public static function getNoActiveFeature(): array
*/
public static function getNoValidGlobalConfig(string $type): array
{
$title = \apply_filters(Filters::FILTER_SETTINGS_DATA, [])[$type]['labels']['title'] ?? [];
$title = \apply_filters(UtilsConfig::FILTER_SETTINGS_DATA, [])[$type]['labels']['title'] ?? [];

if (!$title) {
return [];
Expand Down Expand Up @@ -306,7 +305,7 @@ public static function getPartialFormFieldNames(array $fieldNames): string
*/
public static function getPartialFormResponseTags(string $formType): string
{
$tags = \apply_filters(Filters::FILTER_SETTINGS_DATA, [])[$formType]['emailTemplateTags'] ?? [];
$tags = \apply_filters(UtilsConfig::FILTER_SETTINGS_DATA, [])[$formType]['emailTemplateTags'] ?? [];

if ($tags) {
return SettingsOutputHelper::getPartialFormFieldNames(\array_keys($tags));
Expand Down

0 comments on commit 816c21b

Please sign in to comment.