Skip to content
This repository has been archived by the owner on Feb 23, 2020. It is now read-only.

Commit

Permalink
Added templates for Registration entities.
Browse files Browse the repository at this point in the history
Added default twig template.
Added theme hook.
Added registration template variable preprocessor.
  • Loading branch information
dpi committed Oct 18, 2015
1 parent 94e1b02 commit 9476ace
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
30 changes: 29 additions & 1 deletion rng.module
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use Drupal\rng\Exception\InvalidEventException;
use Drupal\courier\Entity\TemplateCollection;
use Drupal\rng\RuleComponentInterface;
use Drupal\rng\Plugin\Action\CourierTemplateCollection;
use Drupal\Core\Render\Element;

/**
* Implements hook_help().
Expand Down Expand Up @@ -164,4 +165,31 @@ function rng_entity_predelete(EntityInterface $entity) {
}
}
}
}
}

/**
* Implements hook_theme().
*/
function rng_theme() {
return [
'registration' => [
'render element' => 'elements',
],
];
}

/**
* Prepares variables for registration templates.
*
* Default template: registration.html.twig.
*
* @param array $variables
* An associative array containing:
* - elements: An associative array containing the user information and any
* - attributes: HTML attributes for the containing element.
*/
function template_preprocess_registration(array &$variables) {
foreach (Element::children($variables['elements']) as $key) {
$variables['content'][$key] = $variables['elements'][$key];
}
}
21 changes: 21 additions & 0 deletions templates/registration.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{#
/**
* @file registration.html.twig
* Default theme implementation to show a registration.
*
* This template is used when viewing registrations entities.
*
* Available variables:
* - content: A list of content items. Use 'content' to print all content, or
* - attributes: HTML attributes for the container element.
*
* @see template_preprocess_registration()
*
* @ingroup themeable
*/
#}
<div{{ attributes.addClass('registration') }}>
{% if content %}
{{- content -}}
{% endif %}
</div>

0 comments on commit 9476ace

Please sign in to comment.