Skip to content

Commit

Permalink
Remove Drupal <=9.2 BC bridge
Browse files Browse the repository at this point in the history
  • Loading branch information
mxr576 committed Jul 27, 2022
1 parent 23411c5 commit 94437ad
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions src/Plugin/Field/FieldFormatter/SwaggerUIFileFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class SwaggerUIFileFormatter extends FileFormatterBase implements ContainerFacto
*/
public function __construct(string $plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, string $label, string $view_mode, array $third_party_settings, TranslationInterface $string_translation, LoggerInterface $logger, ?FileUrlGeneratorInterface $file_url_generator = NULL) {
// phpcs:ignore DrupalPractice.Objects.GlobalDrupal.GlobalDrupal
if (!$file_url_generator && \Drupal::getContainer()->has('file_url_generator')) {
if (!$file_url_generator) {
// The nicest thing that can be said about the required format by this
// sniff is "insufficient".
// phpcs:ignore Drupal.Semantics.FunctionTriggerError
Expand Down Expand Up @@ -165,15 +165,7 @@ protected function getSwaggerFileUrlFromField(FieldItemInterface $field_item, ar
if (isset($this->fileEntityCache[$context['field_items']->getEntity()->id()][$field_item->getValue()['target_id']])) {
/** @var \Drupal\file\Entity\File $file */
$file = $this->fileEntityCache[$context['field_items']->getEntity()->id()][$field_item->getValue()['target_id']];
if ($this->fileUrlGenerator) {
$url = $this->fileUrlGenerator->generateAbsoluteString($file->getFileUri());
}
else {
// @todo Remove this BC layer when minimum required Drupal core version
// gets bumped to Drupal 9.3.0 or above.
// @phpstan-ignore-next-line
$url = file_create_url($file->getFileUri());
}
$url = $this->fileUrlGenerator->generateAbsoluteString($file->getFileUri());
if ($url === FALSE) {
$this->logger->error('URL could not be created for %file file.', [
'%file' => $file->label(),
Expand Down

0 comments on commit 94437ad

Please sign in to comment.