You are here

function ds_theme in Display Suite 8.3

Same name and namespace in other branches
  1. 8.4 ds.module \ds_theme()
  2. 8.2 ds.module \ds_theme()
  3. 6.3 ds.module \ds_theme()
  4. 6 ds.module \ds_theme()
  5. 6.2 ds.module \ds_theme()
  6. 7.2 ds.module \ds_theme()
  7. 7 ds.module \ds_theme()

Implements hook_theme().

File

./ds.module, line 45
Display Suite core functions.

Code

function ds_theme() {
  $theme_functions = [];
  $theme_functions['ds_entity_view'] = [
    'render element' => 'content',
  ];

  // Field templates.
  if (\Drupal::config('ds.settings')
    ->get('field_template')) {
    $field_layouts = \Drupal::service('plugin.manager.ds.field.layout')
      ->getDefinitions();
    foreach ($field_layouts as $key => $plugin) {
      if ($key != 'default') {
        $theme_functions['field__' . $plugin['theme']] = [
          'render element' => 'elements',
          'template' => strtr($plugin['theme'], '_', '-'),
          'base hook' => 'field',
          'path' => drupal_get_path('module', $plugin['provider']) . '/templates',
        ];
        if (!empty($plugin['path'])) {
          $theme_functions['field__' . $plugin['theme']]['file'] = $plugin['path'];
        }
      }
    }
  }
  return $theme_functions;
}