feature_toggle-2.0.x-dev/feature_toggle.module

feature_toggle.module
<?php

/**
 * @file
 * Hook implementations of Feature Toggle module.
 */

/**
 * Implements hook_theme().
 */
function feature_toggle_theme() {
  return [
    'feature_toggle_form' => [
      'render element' => 'form',
      'file' => 'feature_toggle.theme.inc',
    ],
  ];
}

/**
 * Implements hook_page_attachments().
 */
function feature_toggle_page_attachments(array &$attachments) {
  $features = \Drupal::service('feature_toggle.feature_manager')->getFeatures();
  /** @var \Drupal\feature_toggle\FeatureStatusInterface $feature_status */
  $feature_status = \Drupal::service('feature_toggle.feature_status');
  $enabled = [];
  foreach ($features as $feature) {
    /** @var \Drupal\feature_toggle\Feature $feature */
    if ($feature_status->getStatus($feature->name())) {
      $enabled[] = $feature->name();
    }
  }
  $attachments['#attached']['drupalSettings']['feature_toggle']['enabled'] = $enabled;
}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc