Skip to content
Snippets Groups Projects
Commit 5a0d5f74 authored by Nikolay Grachev's avatar Nikolay Grachev
Browse files

Issue #3465287 by Kasey_MK: Error: Call to a member function isPermanent() on...

Issue #3465287 by Kasey_MK: Error: Call to a member function isPermanent() on null in _file_rename_widget_custom_process()
parent 011fea58
No related branches found
No related tags found
No related merge requests found
......@@ -161,27 +161,28 @@ function _file_rename_widget_custom_process(array $element, FormStateInterface $
$file_storage = \Drupal::entityTypeManager()->getStorage('file');
$file_id = $element['#default_value']['target_id'];
/** @var FileInterface $file */
$file = $file_storage->load($file_id);
$element['file_' . $file_id]['rename_link'] = [
'#name' => $parents_prefix . '_rename_link',
'#type' => 'link',
'#title' => t('Rename'),
'#url' => Url::fromRoute('entity.file.rename_form', ['file' => $file_id], [
'query' => [
'destination' => $request_destination,
if ($file = $file_storage->load($file_id)) {
$element['file_' . $file_id]['rename_link'] = [
'#name' => $parents_prefix . '_rename_link',
'#type' => 'link',
'#title' => t('Rename'),
'#url' => Url::fromRoute('entity.file.rename_form', ['file' => $file_id], [
'query' => [
'destination' => $request_destination,
],
]),
'#access' => $file->isPermanent() && \Drupal::currentUser()->hasPermission('rename files'),
'#weight' => 0,
'#prefix' => '<small class="file-rename__link-wrapper">',
'#suffix' => '</small>',
'#attributes' => [
'class' => ['admin-link'],
'target' => '_blank',
],
]),
'#access' => $file->isPermanent() && \Drupal::currentUser()->hasPermission('rename files'),
'#weight' => 0,
'#prefix' => '<small class="file-rename__link-wrapper">',
'#suffix' => '</small>',
'#attributes' => [
'class' => ['admin-link'],
'target' => '_blank',
],
'#attached' => ['library' => ['file_rename/backend-styles']],
];
return $element;
'#attached' => ['library' => ['file_rename/backend-styles']],
];
return $element;
}
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment