function gutenberg_theme_suggestions_page_alter in Gutenberg 8.2
Same name and namespace in other branches
- 8 gutenberg.module \gutenberg_theme_suggestions_page_alter()
Implements hook_theme_suggestions_HOOK_alter().
File
- ./
gutenberg.module, line 704 - Provides integration with the Gutenberg editor.
Code
function gutenberg_theme_suggestions_page_alter(array &$suggestions, array $variables) {
if (!in_array('page__node__edit', $suggestions) && !in_array('page__node__add', $suggestions)) {
return;
}
$config = \Drupal::service('config.factory')
->getEditable('gutenberg.settings');
$node = \Drupal::routeMatch()
->getParameter('node');
if (!$node) {
$route_match = \Drupal::service('current_route_match');
if (!$route_match
->getParameter('node_type')) {
return;
}
$node_type = $route_match
->getParameter('node_type')
->get('type');
}
else {
$node_type = $node->type
->getString();
}
$gutenberg_enabled = $config
->get($node_type . '_enable_full');
if ($gutenberg_enabled) {
if (in_array('page__node__edit', $suggestions)) {
$suggestions = [
'page__node__edit__gutenberg',
];
}
if (in_array('page__node__add', $suggestions)) {
$suggestions = [
'page__node__add__gutenberg',
];
}
}
}