Skip to content

Commit

Permalink
move code
Browse files Browse the repository at this point in the history
  • Loading branch information
yeniatencio committed Dec 10, 2024
1 parent 9733d80 commit 8e5a65a
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions modules/tide_media/tide_media.module
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,6 @@ function tide_media_form_media_form_alter(&$form, FormStateInterface $form_state
* Implements template_preprocess_field().
*/
function tide_media_preprocess_field(&$variables) {
$route_name = \Drupal::routeMatch()->getRouteName();
$current_user = \Drupal::currentUser();
$roles = $current_user->getRoles();

if ($route_name === 'entity.user.edit_form' && in_array('secure_file_user', $roles)) {
$url = Url::fromRoute('entity.user.canonical', ['user' => $current_user->id()]);
$response = new RedirectResponse($url->toString());
$response->send();
exit();
}

if ($variables['field_name'] == 'field_media_file') {
$element = $variables['element'];
if ($element['#entity_type'] == 'media' && $element['#bundle'] == 'document' && $element['#view_mode'] == 'embedded') {
Expand Down Expand Up @@ -478,6 +467,22 @@ function tide_media_file_presave(FileInterface $file) {
}
}

/**
* Implements hook_preprocess_HOOK().
*/
function tide_media_preprocess_page(&$variables) {
$route_name = \Drupal::routeMatch()->getRouteName();
$current_user = \Drupal::currentUser();
$roles = $current_user->getRoles();

if ($route_name === 'entity.user.edit_form' && in_array('secure_file_user', $roles)) {
$url = \Drupal\Core\Url::fromRoute('entity.user.canonical', ['user' => $current_user->id()]);
$response = new RedirectResponse($url->toString());
$response->send();
exit();
}
}

/**
* Implements hook_menu_local_tasks_alter().
*/
Expand Down

0 comments on commit 8e5a65a

Please sign in to comment.