Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 292096

Convert format_size() to a TranslationInterface::formatByteSize() method and a StringTranslationTrait::formatByteSize() helper

$
0
0

Problem/Motivation

format_size() is still a procedural function. Convert it to a object oriented code.

Proposed resolution

  • Add a ::formatByteSize() method to TranslationInterface and its TranslationManager implementation
  • Add a ::formatByteSize() method to StringTranslationTrait as a helper to access TranslationManager::formatByteSize.
  • Deprecate and remove usages of format_size().
  • Add related PHP unit tests.

This way any object implementing StringTranslationTrait (forms, plugins, controllers etc.) can simply replace format_size with $this->formatByteSize, while other code (procedural functions, hook implementations, etc) can replace with \Drupal::translation()->formatByteSize.

Remaining tasks

review/commit

User interface changes

none

API changes

See proposed resolution.


Viewing all articles
Browse latest Browse all 292096

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>