mason-8.x-1.x-dev/mason.module
mason.module
<?php
/**
* @file
* Provides Mason integration to create a perfect gapless grid of elements.
*/
use Drupal\mason\MasonDefault;
/**
* Provides a convenient shortcut for procedural hooks.
*
* @return \Drupal\mason\MasonManager
* |\Drupal\mason\MasonSkinManager
* The Mason class instances.
*/
// @codingStandardsIgnoreStart
function mason($key = 'manager') {
static $manager;
static $skin_manager;
if (!isset($manager)) {
$manager = \Drupal::service('mason.manager');
$skin_manager = \Drupal::service('mason.skin_manager');
}
switch ($key) {
case 'skin':
return $skin_manager;
default:
return $manager;
}
}
// @codingStandardsIgnoreEnd
/**
* Implements hook_theme().
*/
function mason_theme() {
$themes = [];
foreach (['mason', 'box'] as $item) {
$key = $item == 'mason' ? 'mason' : 'mason_' . $item;
$themes[$key] = [
'render element' => 'element',
'file' => 'templates/mason.theme.inc',
];
}
return $themes;
}
/**
* Implements hook_library_info_build().
*/
function mason_library_info_build() {
/* @phpstan-ignore-next-line */
return mason('skin')->libraryInfoBuild();
}
/**
* Implements hook_config_schema_info_alter().
*/
function mason_config_schema_info_alter(array &$definitions) {
blazy()->configSchemaInfoAlter($definitions, 'mason_base', MasonDefault::extendedSettings());
}
/**
* Provides a wrapper to replace deprecated libraries_get_path() at ease.
*
* @todo remove post blazy:2.17.
*/
function mason_libraries_get_path($name, $base_path = FALSE) {
return blazy()->getLibrariesPath($name, $base_path);
}
/**
* Returns the path.
*
* @todo remove post blazy:2.17.
*/
function mason_get_path($type, $name, $absolute = FALSE) {
return blazy()->getPath($type, $name, $absolute);
}
/**
* Implements hook_help().
*/
function mason_help($route_name) {
if ($route_name == 'help.page.mason') {
$output = file_get_contents(dirname(__FILE__) . '/README.md');
return blazy()->markdown($output);
}
return '';
}
