You are here

class SettingsHelper in Acquia Lift Connector 8

Same name and namespace in other branches
  1. 8.4 src/Service/Helper/SettingsHelper.php \Drupal\acquia_lift\Service\Helper\SettingsHelper
  2. 8.3 src/Service/Helper/SettingsHelper.php \Drupal\acquia_lift\Service\Helper\SettingsHelper

Defines the Settings Helper class.

Hierarchy

Expanded class hierarchy of SettingsHelper

6 files declare their use of SettingsHelper
acquia_lift.install in ./acquia_lift.install
Installation file for Acquia Lift module.
acquia_lift.module in ./acquia_lift.module
Drupal Module: Acquia Lift
AdminSettingsForm.php in src/Form/AdminSettingsForm.php
Contains \Drupal\acquia_lift\Form\AdminSettingsForm.
DataApi.php in src/Service/Api/DataApi.php
Contains \Drupal\acquia_lift\Service\Api\DataApi.
PathContext.php in src/Service/Context/PathContext.php
Contains \Drupal\acquia_lift\Service\Context\PathContext.

... See full list

File

src/Service/Helper/SettingsHelper.php, line 16
Contains \Drupal\acquia_lift\Service\Helper\SettingsHelper.

Namespace

Drupal\acquia_lift\Service\Helper
View source
class SettingsHelper {

  /**
   * Default identity type's default value.
   */
  const DEFAULT_IDENTITY_TYPE_DEFAULT = 'email';

  /**
   * Get front-end credential settings.
   *
   * @param array $credential_settings
   *   Credential settings array.
   * @return array
   *   Get front end settings array.
   * @throws \Drupal\acquia_lift\Exception\MissingSettingsException
   */
  public static function getFrontEndCredentialSettings($credential_settings) {
    if (empty($credential_settings['account_name']) || !isset($credential_settings['customer_site']) || empty($credential_settings['js_path'])) {
      throw new MissingSettingsException('Cannot generate front-end credential settings because some settings are missing.');
    }
    return [
      'account_name' => $credential_settings['account_name'],
      'customer_site' => $credential_settings['customer_site'],
      'js_path' => $credential_settings['js_path'],
    ];
  }

  /**
   * Is an invalid credential.
   *
   * @param array
   *   Credential settings array.
   * @return boolean
   *   True if is an invalid credential.
   */
  public static function isInvalidCredential($credential_settings) {

    // Required credential need to be filled.
    if (empty($credential_settings['account_name']) || empty($credential_settings['api_url']) || empty($credential_settings['access_key']) || empty($credential_settings['secret_key']) || empty($credential_settings['js_path'])) {
      return TRUE;
    }

    // URLs need to be valid.
    if (!UrlHelper::isValid($credential_settings['api_url']) || !UrlHelper::isValid($credential_settings['js_path'])) {
      return TRUE;
    }
    return FALSE;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SettingsHelper::DEFAULT_IDENTITY_TYPE_DEFAULT constant Default identity type's default value.
SettingsHelper::getFrontEndCredentialSettings public static function Get front-end credential settings.
SettingsHelper::isInvalidCredential public static function Is an invalid credential.