You are here

function add_to_head_get_settings in Add To Head 8

Helper to get the settings.

Parameters

string $scope (Optional) - filter the scopes of the returned settings.:

Return value

array Array of profiles, including those defined by other modules.

6 calls to add_to_head_get_settings()
AddToHeadController::adminOverview in src/Controller/AddToHeadController.php
AddToHeadDeleteProfileForm::submitForm in src/Form/AddToHeadDeleteProfileForm.php
Form submission handler.
AddToHeadParamConverter::convert in src/ParamConverter/AddToHeadParamConverter.php
Converts path variables to their corresponding objects.
add_to_head_css_alter in ./add_to_head.module
Implements hook_css_alter().
add_to_head_page_attachments_alter in ./add_to_head.module
Implements hook_page_attachments_alter().

... See full list

File

./add_to_head.module, line 16
Add To Head allows arbitrary insertion of code into the head of the page based on path selection.

Code

function add_to_head_get_settings($scope = NULL) {

  // Fetch the profile information stored in the DB.
  $settings = \Drupal::config('add_to_head.settings')
    ->get('add_to_head_profiles');
  $settings = $settings ? $settings : array();

  // Allow other modules to alter profile settings. Additional profiles may be added here.
  \Drupal::moduleHandler()
    ->alter('add_to_head_profiles', $settings);
  if ($scope) {
    $settings = array_filter($settings, function ($profile) use ($scope) {
      return $profile['scope'] == $scope;
    });
  }
  return $settings;
}