dsfr_paragraph-2.1.x-dev/dsfr_paragraph.module

dsfr_paragraph.module
<?php 

/**
 * Implements hook_install
 */
function dsfr_paragraph_install() {

  \Drupal::service('dsfr_paragraph.paragraphManage')->paraInstall();
}

/**
 * Implements hook_theme_registry_alter().
 */
function dsfr_paragraph_theme_registry_alter( &$theme_registry ) {

  $dp_path = \Drupal::service('extension.path.resolver')->getPath('module', 'dsfr_paragraph');

  // Override TEMPLATES
  // ----------------------------------------------------------------------------------------------- //
  # layout_paragraphs
  $theme_registry['layout_paragraphs']['path'] = $dp_path . '/templates';
  $theme_registry['layout_paragraphs_builder_component_menu']['path'] = $dp_path . '/templates';
  $theme_registry['layout_paragraphs_builder_controls']['path'] = $dp_path . '/templates';
  $theme_registry['layout_paragraphs_builder_formatter']['path'] = $dp_path . '/templates';
  $theme_registry['layout_paragraphs_builder']['path'] = $dp_path . '/templates';
  $theme_registry['layout_paragraphs_insert_component_btn']['path'] = $dp_path . '/templates';
  # paragraphs
  $theme_registry['paragraph']['theme_path'] = $dp_path;
  $theme_registry['paragraph']['path'] = $dp_path . '/templates';
  // ----------------------------------------------------------------------------------------------- //
}

function dsfr_paragraph_js_alter(&$javascript) {
  unset($javascript['modules/contrib/layout_paragraphs/js/component-list.js']);
}

/**
 * Implements hook_theme().
 */
function dsfr_paragraph_theme( $existing, $type, $theme, $path ) {

  $p = 'paragraph';
  $templates = [];
  $components = [
    'accordions',
    'alert',
    'badges',
    'block', 
    'buttons',
    'callout',
    'ckeditor',
    'code', 
    'franceconnect',
    'highlight',
    'image',
    'link',
    'quote',
    'search',
    'tabs',
    'tags',
    'title',
    'tooltip'
  ];

  $templates['settings'] = [
    'variables' => [
      'data' => [], 
      'form_paragraph_node' => []
    ],
    'template' => 'settings' 
  ];

  foreach( $components as $value ) {

    $keyword = $p. '__dsfr_' . $value;
    $template = $p . '--dsfr-' . $value;
    $templates[$keyword] = [ 'template' => $template, 'base hook' => $p ];
  }

  return $templates;
}

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

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