browser_development-8.x-1.x-dev/modules/browser_development_assist/browser_development_assist.module
modules/browser_development_assist/browser_development_assist.module
<?php
/**
* @file
* Contains development_assistant.module.
*/
use Drupal\browser_development_assist\Processing\FileSystemStructure;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Asset\AttachedAssetsInterface;
/**
* Implements hook_help().
*/
function browser_development_assist_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'help.page.browser_development_assist':
$output = '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('Allows browser development to') . '</br>';
$output .= t('be uninstalled on production and replaces') . '</br>';
$output .= t('certain functionality so the developers') . '</br>';
$output .= t('final output renders correctly, mitigates') . '</br>';
$output .= t('potential attack and performance issues.') . '</p>';
return $output;
default:
}
}
/**
* Implements hook_library_info_build().
*/
function browser_development_assist_library_info_build() {
// Attaching file library array.
$css = FileSystemStructure::getCssFilePath();
return [
'browser-development-assist' => [
'version' => 'VERSION',
'css' => [
'theme' => [
"$css" => []
]
],
],
];
}
/**
* Attaches
*
* Implements hook_page_attachments().
*/
function browser_development_assist_page_attachments(array &$page) {
$active = \Drupal::theme()->getActiveTheme()->getName();
$current_theme = \Drupal::config('system.theme')->get('default');
if ($active === $current_theme) {
$page['#attached']['library'][] = 'browser_development_assist/browser-development-assist';
}
}
/**
* Implements hook_css_alter().
*/
function browser_development_assist_css_alter(&$css, AttachedAssetsInterface $assets) {
$library = \Drupal::service('library.discovery')
->getLibraryByName('browser_development_assist', 'browser-development-assist');
$path = $library['css'][0]['data'];
if (isset($css[$path])) {
$css[$path]['group'] = 300;
}
}
