View source
<?php
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\rng\EventTypeInterface;
use Drupal\Core\Render\Element;
function rng_help($route_name, RouteMatchInterface $route_match) {
switch ($route_name) {
case 'rng.registration_type.overview':
$output = '<p>' . t('Each registration type is a form that is filled to create a registration. Events can choose which registration type to use for its registrations.') . '</p>';
return $output;
}
}
function rng_entity_access(EntityInterface $entity, $operation, AccountInterface $account) {
$rng_access = \Drupal::service('rng.entity.access');
return $rng_access
->hook_entity_access($entity, $operation, $account);
}
function rng_form_alter(&$form, FormStateInterface $form_state, $form_id) {
if ($form_id == 'user_admin_permissions') {
$form['permissions']['rng register self'][AccountInterface::ANONYMOUS_ROLE]['#disabled'] = TRUE;
$form['permissions']['rng register self'][AccountInterface::ANONYMOUS_ROLE]['#access'] = FALSE;
}
}
function rng_cron() {
$rng_cron = \Drupal::service('rng.cron');
$rng_cron
->hook_cron();
}
function rng_entity_operation(EntityInterface $entity) {
$operations = [];
if ($entity instanceof EventTypeInterface) {
$operations['access_defaults'] = array(
'title' => t('Event access defaults'),
'url' => Url::fromRoute('entity.event_type.access_defaults', [
'event_type' => $entity
->id(),
]),
'weight' => 20,
);
}
return $operations;
}
function rng_entity_insert(EntityInterface $entity) {
$rng_model = \Drupal::service('rng.entity.model');
$rng_model
->hook_entity_postsave($entity, FALSE);
}
function rng_entity_update(EntityInterface $entity) {
$rng_model = \Drupal::service('rng.entity.model');
$rng_model
->hook_entity_postsave($entity, TRUE);
}
function rng_entity_predelete(EntityInterface $entity) {
$rng_model = \Drupal::service('rng.entity.model');
$rng_model
->hook_entity_predelete($entity);
}
function rng_theme() {
return [
'registration' => [
'render element' => 'elements',
],
];
}
function template_preprocess_registration(array &$variables) {
foreach (Element::children($variables['elements']) as $key) {
$variables['content'][$key] = $variables['elements'][$key];
}
}