Skip to content

Commit e77aa5f

Browse files
committed
Merge branch 'feature/security-update' into develop
2 parents b02be24 + 9d74e94 commit e77aa5f

File tree

9 files changed

+997
-854
lines changed

9 files changed

+997
-854
lines changed

composer.lock

Lines changed: 949 additions & 839 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/profiles/custom/os2loop/modules/os2loop_documents/src/Controller/EntityPrintController.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Drupal\Console\Core\Utils\NestedArray;
66
use Drupal\Core\Controller\ControllerBase;
77
use Drupal\Core\Entity\EntityTypeManagerInterface;
8+
use Drupal\Core\File\FileUrlGeneratorInterface;
89
use Drupal\Core\Render\RendererInterface;
910
use Drupal\node\NodeInterface;
1011
use Drupal\os2loop_documents\Form\SettingsForm;
@@ -37,13 +38,21 @@ class EntityPrintController extends ControllerBase {
3738
*/
3839
private $renderer;
3940

41+
/**
42+
* The file url generator.
43+
*
44+
* @var \Drupal\Core\File\FileUrlGeneratorInterface
45+
*/
46+
private $fileUrlGenerator;
47+
4048
/**
4149
* {@inheritdoc}
4250
*/
43-
public function __construct(Settings $settings, EntityTypeManagerInterface $entityTypeManager, RendererInterface $renderer) {
51+
public function __construct(Settings $settings, EntityTypeManagerInterface $entityTypeManager, RendererInterface $renderer, FileUrlGeneratorInterface $fileUrlGenerator) {
4452
$this->config = $settings->getConfig(SettingsForm::SETTINGS_NAME)->get('pdf');
4553
$this->fileStorage = $entityTypeManager->getStorage('file');
4654
$this->renderer = $renderer;
55+
$this->fileUrlGenerator = $fileUrlGenerator;
4756
}
4857

4958
/**
@@ -53,7 +62,8 @@ public static function create(ContainerInterface $container) {
5362
return new static(
5463
$container->get(Settings::class),
5564
$container->get('entity_type.manager'),
56-
$container->get('renderer')
65+
$container->get('renderer'),
66+
$container->get('file_url_generator')
5767
);
5868
}
5969

@@ -101,7 +111,7 @@ private function getFileUrl(array $configPath) {
101111
/** @var \Drupal\file\FileInterface|null $file */
102112
$file = $this->fileStorage->load($fileId);
103113

104-
return $file ? file_create_url($file->getFileUri()) : NULL;
114+
return $file ? $this->fileUrlGenerator->generateAbsoluteString($file->getFileUri()) : NULL;
105115
}
106116

107117
}

web/profiles/custom/os2loop/modules/os2loop_media/modules/os2loop_media_fixtures/os2loop_media_fixtures.services.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ services:
66
arguments:
77
- '@entity_type.manager'
88
- '@file_system'
9+
- '@file.repository'

web/profiles/custom/os2loop/modules/os2loop_media/modules/os2loop_media_fixtures/src/Fixture/MediaFixture.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Drupal\content_fixtures\Fixture\FixtureGroupInterface;
77
use Drupal\Core\File\FileSystemInterface;
88
use Drupal\Core\Entity\EntityTypeManagerInterface;
9+
use Drupal\file\FileRepositoryInterface;
910
use Drupal\media\Entity\Media;
1011

1112
/**
@@ -29,17 +30,27 @@ class MediaFixture extends AbstractFixture implements FixtureGroupInterface {
2930
*/
3031
protected $entityTypeManager;
3132

33+
/**
34+
* The file repository.
35+
*
36+
* @var \Drupal\file\FileRepositoryInterface
37+
*/
38+
protected $fileRepository;
39+
3240
/**
3341
* MediaFixture constructor.
3442
*
3543
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
3644
* Entity type manager.
3745
* @param \Drupal\Core\File\FileSystemInterface $fileSystem
3846
* Filesystem.
47+
* @param \Drupal\file\FileRepositoryInterface $fileRepository
48+
* File repository.
3949
*/
40-
public function __construct(EntityTypeManagerInterface $entityTypeManager, FileSystemInterface $fileSystem) {
50+
public function __construct(EntityTypeManagerInterface $entityTypeManager, FileSystemInterface $fileSystem, FileRepositoryInterface $fileRepository) {
4151
$this->entityTypeManager = $entityTypeManager;
4252
$this->fileSystem = $fileSystem;
53+
$this->fileRepository = $fileRepository;
4354
}
4455

4556
/**
@@ -89,8 +100,9 @@ private function loadFiles(): array {
89100
if (!is_dir(dirname($destination))) {
90101
$this->fileSystem->mkdir(dirname($destination), 0755, TRUE);
91102
}
92-
$loadedFiles[] = file_save_data(
93-
file_get_contents($file->uri), $destination,
103+
$loadedFiles[] = $this->fileRepository->writeData(
104+
file_get_contents($file->uri),
105+
$destination,
94106
FileSystemInterface::EXISTS_REPLACE
95107
);
96108
}

web/profiles/custom/os2loop/modules/os2loop_media/src/Plugin/Field/FieldFormatter/FileImageFormatter.php

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Drupal\os2loop_media\Plugin\Field\FieldFormatter;
44

55
use Drupal\Core\Entity\EntityTypeManagerInterface;
6+
use Drupal\Core\Extension\ExtensionPathResolver;
67
use Drupal\Core\Field\FieldDefinitionInterface;
78
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
89
use Drupal\image\Entity\ImageStyle;
@@ -30,12 +31,20 @@ class FileImageFormatter extends FileFormatterBase implements ContainerFactoryPl
3031
*/
3132
private $entityTypeManager;
3233

34+
/**
35+
* The extension path resolver.
36+
*
37+
* @var \Drupal\Core\Extension\ExtensionPathResolver
38+
*/
39+
private $extensionPathResolver;
40+
3341
/**
3442
* Constructor for a custom file formatter.
3543
*/
36-
public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, EntityTypeManagerInterface $entityTypeManager) {
44+
public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, EntityTypeManagerInterface $entityTypeManager, ExtensionPathResolver $extensionPathResolver) {
3745
parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode, $third_party_settings);
3846
$this->entityTypeManager = $entityTypeManager;
47+
$this->extensionPathResolver = $extensionPathResolver;
3948
}
4049

4150
/**
@@ -50,7 +59,8 @@ public static function create(ContainerInterface $container, array $configuratio
5059
$configuration['label'],
5160
$configuration['view_mode'],
5261
$configuration['third_party_settings'],
53-
$container->get('entity_type.manager')
62+
$container->get('entity_type.manager'),
63+
$container->get('extension.path.resolver')
5464
);
5565
}
5666

@@ -78,7 +88,7 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
7888
}
7989
else {
8090
// If not an image use drupals fallback generic file icon.
81-
$image_url = drupal_get_path('module', 'media') . '/images/icons/generic.png';
91+
$image_url = $this->extensionPathResolver->getPath('module', 'media') . '/images/icons/generic.png';
8292
$image_uri = 'public://styles/media_library/public/media-icons/generic/generic.png';
8393
// Ensure file exists.
8494
$style = $this->entityTypeManager->getStorage('image_style')->load('media_library');

web/profiles/custom/os2loop/modules/os2loop_oembed/src/TwigExtension/TwigExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function getFilters(): array {
8989
*/
9090
public function createVideo(array $text): ?string {
9191
// Set string depending on field type.
92-
$string = isset($text['#plain_text']) ? $text['#plain_text'] : $text['#context']['value'];
92+
$string = $text['#plain_text'] ?? $text['#context']['value'];
9393
if (!empty($this->findIframe($string))) {
9494
$string = $this->handleIframe($string);
9595
}

web/profiles/custom/os2loop/modules/os2loop_revision_date/src/Plugin/Action/SetRevisionDate.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function execute($node = NULL) {
4848
* The next time the node should be revisioned.
4949
*/
5050
private function getNextRevisionDate(): DrupalDateTime {
51-
$extend = isset($this->configuration['time_span']) ? $this->configuration['time_span'] : 'now';
51+
$extend = $this->configuration['time_span'] ?? 'now';
5252
return new DrupalDateTime($extend, date_default_timezone_get());
5353
}
5454

web/profiles/custom/os2loop/modules/os2loop_upvote/src/Helper/FlagHelper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public function preprocessField(array &$variables) {
5050
else {
5151
if (isset($comment_flag_counts['os2loop_upvote_upvote_button'])) {
5252
// If there is no upvoted comment, set it to current comment.
53-
$upvoted_comment = isset($upvoted_comment) ? $upvoted_comment : $comment;
53+
$upvoted_comment = $upvoted_comment ?? $comment;
5454

5555
// Get number of upvotes for comment and upvoted comment.
5656
$upvoted_comment_upvotes = intval($this->flagCountManager->getEntityFlagCounts($upvoted_comment['#comment']));

web/profiles/custom/os2loop/themes/os2loop_theme/os2loop_theme.theme

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use Drupal\user\Entity\User;
1616
* Site logo for menu.
1717
*/
1818
function os2loop_theme_preprocess(&$variables) {
19-
$variables['logopath'] = file_url_transform_relative(file_create_url(theme_get_setting('logo.url')));
19+
$variables['logopath'] = \Drupal::service('file_url_generator')->generateString(theme_get_setting('logo.url'));
2020
$variables['os2loop_container_class'] = theme_get_setting('container_class') ?: 'container-fluid';
2121
};
2222

@@ -196,7 +196,7 @@ function os2loop_theme_form_system_theme_settings_alter(&$form, FormStateInterfa
196196
'file_validate_extensions' => ['css'],
197197
'file_validate_size' => [10000000],
198198
],
199-
'#default_value' => isset($uploaded_file) ? $uploaded_file : NULL,
199+
'#default_value' => $uploaded_file ?? NULL,
200200
'#upload_location' => 'public://custom_color_scheme/',
201201
];
202202

@@ -231,7 +231,7 @@ function os2loop_theme_library_info_alter(&$libraries, $extension) {
231231
else {
232232
$file = File::load($custom_scheme[0]);
233233
$uri = $file->getFileUri();
234-
$url = Url::fromUri(file_create_url($uri))->toString();
234+
$url = Url::fromUri(\Drupal::service('file_url_generator')->generateAbsoluteString($uri))->toString();
235235
$stylesheet = $url;
236236
}
237237

0 commit comments

Comments
 (0)