Skip to content

Commit 6cab33b

Browse files
committed
remove unnecessary/broken pathauto and operation hooks
1 parent 37198b5 commit 6cab33b

File tree

2 files changed

+17
-138
lines changed

2 files changed

+17
-138
lines changed

file_entity.module

Lines changed: 4 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -217,21 +217,6 @@ function file_entity_entity_type_alter(&$entity_types) {
217217
//$entity_types['file']['metatags'] = TRUE;
218218
}
219219

220-
/**
221-
* Check if a file entity is readable or not.
222-
*
223-
* @param object $file
224-
* A file entity object from file_load().
225-
*
226-
* @return boolean
227-
* TRUE if the file is using a readable stream wrapper, or FALSE otherwise.
228-
*/
229-
function file_entity_file_is_readable($file) {
230-
$scheme = file_uri_scheme($file->uri);
231-
$wrappers = \Drupal::service('stream_wrapper_manager')->getWrappers(StreamWrapperInterface::READ);
232-
return !empty($wrappers[$scheme]);
233-
}
234-
235220
/**
236221
* Returns whether the current page is the full page view of the passed-in file.
237222
*
@@ -341,21 +326,6 @@ function file_entity_theme_suggestions_file_alter(array &$suggestions, array $va
341326
$suggestions[] = 'file__' . $file->id() . '__' . $view_mode;
342327
}
343328

344-
/**
345-
* Returns the file type name of the passed file or file type string.
346-
*
347-
* @param $file
348-
* A file object or string that indicates the file type to return.
349-
*
350-
* @return
351-
* The file type name or FALSE if the file type is not found.
352-
*/
353-
function file_entity_type_get_name(FileInterface $file) {
354-
$type = is_object($file) ? $file->type : $file;
355-
$info = entity_get_info('file');
356-
return isset($info['bundles'][$type]['label']) ? $info['bundles'][$type]['label'] : FALSE;
357-
}
358-
359329
/**
360330
* Returns a list of available file type names.
361331
*
@@ -380,19 +350,6 @@ function file_entity_view_mode_label($view_mode, $default = FALSE) {
380350
return isset($labels[$view_mode]) ? $labels[$view_mode] : $default;
381351
}
382352

383-
/**
384-
* Return a specific stream wrapper's registry information.
385-
*
386-
* @param $scheme
387-
* A URI scheme, a stream is referenced as "scheme://target".
388-
*
389-
* @see file_get_stream_wrappers()
390-
*/
391-
function file_entity_get_stream_wrapper($scheme) {
392-
$wrappers = file_get_stream_wrappers();
393-
return isset($wrappers[$scheme]) ? $wrappers[$scheme] : FALSE;
394-
}
395-
396353
/**
397354
* @defgroup file_entity_access File access rights
398355
* @{
@@ -638,28 +595,6 @@ function file_entity_file_download($uri) {
638595
* @} End of "defgroup file_entity_access".
639596
*/
640597

641-
/**
642-
* Implements hook_file_operations().
643-
*/
644-
function file_entity_file_operations() {
645-
$operations = array(
646-
'permanent' => array(
647-
'label' => t('Indicate that the selected files are permanent and should not be deleted'),
648-
'callback' => 'file_entity_mass_update',
649-
'callback arguments' => array('updates' => array('status' => FILE_STATUS_PERMANENT)),
650-
),
651-
'temporary' => array(
652-
'label' => t('Indicate that the selected files are temporary and should be removed during cron runs'),
653-
'callback' => 'file_entity_mass_update',
654-
'callback arguments' => array('updates' => array('status' => 0)),
655-
),
656-
'delete' => array(
657-
'label' => t('Delete selected files'),
658-
'callback' => NULL,
659-
),
660-
);
661-
return $operations;
662-
}
663598

664599
/**
665600
* Check if a file entity is considered local or not.
@@ -697,79 +632,6 @@ function file_entity_file_is_writeable(FileInterface $file) {
697632
* @{
698633
*/
699634

700-
/**
701-
* Implements hook_file_operations() on behalf of pathauto.module.
702-
*/
703-
function pathauto_file_operations() {
704-
$operations['pathauto_update_alias'] = array(
705-
'label' => t('Update URL alias'),
706-
'callback' => 'pathauto_file_update_alias_multiple',
707-
'callback arguments' => array('bulkupdate', array('message' => TRUE)),
708-
);
709-
return $operations;
710-
}
711-
712-
/**
713-
* Update action wrapper for pathauto_file_update_alias().
714-
*/
715-
function pathauto_file_update_action($file, $context = array()) {
716-
pathauto_file_update_alias($file, 'bulkupdate', array('message' => TRUE));
717-
}
718-
719-
/**
720-
* @} End of "name pathauto_file".
721-
*/
722-
723-
/**
724-
* Implements hook_form_FORM_ID_alter() for file_entity_edit() on behalf of path.module.
725-
*/
726-
function path_form_file_entity_edit_alter(&$form, $form_state) {
727-
// Make sure this does not show up on the delete confirmation form.
728-
if (empty($form_state['confirm_delete'])) {
729-
$file = $form_state['file'];
730-
$langcode = function_exists('entity_language') ? entity_language('file', $file) : NULL;
731-
$langcode = !empty($langcode) ? $langcode : LANGUAGE_NONE;
732-
$conditions = array('source' => 'file/' . $file->fid, 'language' => $langcode);
733-
$path = (isset($file->fid) ? path_load($conditions) : array());
734-
if ($path === FALSE) {
735-
$path = array();
736-
}
737-
$path += array(
738-
'pid' => NULL,
739-
'source' => isset($file->fid) ? 'file/' . $file->fid : NULL,
740-
'alias' => '',
741-
'language' => $langcode,
742-
);
743-
$form['path'] = array(
744-
'#type' => 'fieldset',
745-
'#title' => t('URL path settings'),
746-
'#collapsible' => TRUE,
747-
'#collapsed' => empty($path['alias']),
748-
'#group' => 'additional_settings',
749-
'#attributes' => array(
750-
'class' => array('path-form'),
751-
),
752-
'#attached' => array(
753-
'js' => array(drupal_get_path('module', 'path') . '/path.js'),
754-
),
755-
'#access' => user_access('create url aliases') || user_access('administer url aliases'),
756-
'#weight' => 30,
757-
'#tree' => TRUE,
758-
'#element_validate' => array('path_form_element_validate'),
759-
);
760-
$form['path']['alias'] = array(
761-
'#type' => 'textfield',
762-
'#title' => t('URL alias'),
763-
'#default_value' => $path['alias'],
764-
'#maxlength' => 255,
765-
'#description' => t('Optionally specify an alternative URL by which this file can be accessed. For example, type "about" when writing an about page. Use a relative path and don\'t add a trailing slash or the URL alias won\'t work.'),
766-
);
767-
$form['path']['pid'] = array('#type' => 'value', '#value' => $path['pid']);
768-
$form['path']['source'] = array('#type' => 'value', '#value' => $path['source']);
769-
$form['path']['language'] = array('#type' => 'value', '#value' => $path['language']);
770-
}
771-
}
772-
773635
// @todo move
774636
function file_entity_entity_base_field_info(EntityTypeInterface $entity_type) {
775637
// @todo: Make this configurable and/or remove if
@@ -789,6 +651,10 @@ function file_entity_entity_base_field_info(EntityTypeInterface $entity_type) {
789651
}
790652
}
791653

654+
/**
655+
* @} End of "name pathauto_file".
656+
*/
657+
792658
/**
793659
* Checks if pattern(s) match mimetype(s).
794660
*/

src/Entity/FileEntity.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Drupal\Core\Entity\EntityStorageInterface;
1212
use Drupal\Core\Entity\EntityTypeInterface;
1313
use Drupal\Core\Field\BaseFieldDefinition;
14+
use Drupal\Core\StreamWrapper\StreamWrapperInterface;
1415
use Drupal\file\Entity\File;
1516
use Drupal\file\FileInterface;
1617

@@ -310,6 +311,18 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
310311
return $fields;
311312
}
312313

314+
/**
315+
* Check if a file entity is readable or not.
316+
*
317+
* @return bool
318+
* TRUE if the file is using a readable stream wrapper, or FALSE otherwise.
319+
*/
320+
function isReadable() {
321+
$scheme = file_uri_scheme($this->getFileUri());
322+
$wrappers = \Drupal::service('stream_wrapper_manager')->getWrappers(StreamWrapperInterface::READ);
323+
return !empty($wrappers[$scheme]);
324+
}
325+
313326
/**
314327
* {@inheritdoc}
315328
*/

0 commit comments

Comments
 (0)