Skip to content

Commit 516fbaa

Browse files
author
Stephen Lucero
committed
Issue #3457946 by slucero: Fix Deprecations and Breaking Issues for Drupal 10.3
1 parent fba5977 commit 516fbaa

9 files changed

Lines changed: 140 additions & 127 deletions

File tree

‎modules/patternkit_media_library/patternkit_media_library.services.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ services:
44
arguments:
55
- '@entity_type.manager'
66
- '@file_url_generator'
7+
tags:
8+
- { name: media_library.opener }

‎patternkit.services.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ services:
5050
- '@patternkit.schema.data_preprocessor.factory'
5151
- '@patternkit.pattern.dependency_resolver'
5252
- '@logger.channel.patternkit'
53+
- '@?plugin.manager.sdc'
5354
patternkit.asset.library.parser.file:
5455
parent: patternkit.asset.library.parser.base
5556
class: Drupal\patternkit\Asset\PatternLibraryParser\FilePatternLibraryParser

‎src/Asset/PatternLibraryParserBase.php‎

Lines changed: 17 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Drupal\Core\Logger\LoggerChannelInterface;
1515
use Drupal\Core\StreamWrapper\StreamWrapperManagerInterface;
1616
use Drupal\Core\StringTranslation\StringTranslationTrait;
17+
use Drupal\Core\Theme\ComponentPluginManager;
1718
use Drupal\Core\Theme\ThemeManagerInterface;
1819
use Drupal\patternkit\Entity\PatternInterface;
1920
use Drupal\patternkit\Exception\PatternAssetException;
@@ -44,41 +45,13 @@ abstract class PatternLibraryParserBase extends LibraryDiscoveryParser implement
4445
*/
4546
protected const DEFAULT_CATEGORY = 'default';
4647

47-
/**
48-
* Serializes and de-serializes data.
49-
*
50-
* @var \Drupal\Component\Serialization\SerializationInterface
51-
*/
52-
protected SerializationInterface $serializer;
53-
5448
/**
5549
* The entity storage handler for the patternkit_pattern entity.
5650
*
5751
* @var \Drupal\Core\Entity\EntityStorageInterface
5852
*/
5953
protected EntityStorageInterface $patternStorage;
6054

61-
/**
62-
* The schema data preprocessor factory service.
63-
*
64-
* @var \Drupal\patternkit\Schema\DataPreProcessorFactory
65-
*/
66-
protected DataPreProcessorFactory $dataPreProcessorFactory;
67-
68-
/**
69-
* The pattern dependency resolver service.
70-
*
71-
* @var \Drupal\patternkit\Asset\PatternDependencyResolver
72-
*/
73-
protected PatternDependencyResolver $patternDependencyResolver;
74-
75-
/**
76-
* The patternkit logger channel.
77-
*
78-
* @var \Drupal\Core\Logger\LoggerChannelInterface
79-
*/
80-
protected LoggerChannelInterface $logger;
81-
8255
/**
8356
* Constructor for PatternLibraryParser implementations.
8457
*
@@ -104,30 +77,37 @@ abstract class PatternLibraryParserBase extends LibraryDiscoveryParser implement
10477
* The pattern dependency resolver service.
10578
* @param \Drupal\Core\Logger\LoggerChannelInterface $logger
10679
* The patternkit logger channel.
80+
* @param \Drupal\Core\Theme\ComponentPluginManager|null $componentPluginManager
81+
* The theme component plugin manager if available.
10782
*
10883
* @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
10984
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
11085
*/
11186
public function __construct(
112-
SerializationInterface $serializer,
87+
protected SerializationInterface $serializer,
11388
string $root,
11489
ModuleHandlerInterface $module_handler,
11590
ThemeManagerInterface $theme_manager,
11691
StreamWrapperManagerInterface $stream_wrapper,
11792
LibrariesDirectoryFileFinder $libraries_directory_file_finder,
11893
ExtensionPathResolver $extension_path_resolver,
11994
EntityTypeManagerInterface $entity_type_manager,
120-
DataPreProcessorFactory $dataPreProcessorFactory,
121-
PatternDependencyResolver $patternDependencyResolver,
122-
LoggerChannelInterface $logger,
95+
protected DataPreProcessorFactory $dataPreProcessorFactory,
96+
protected PatternDependencyResolver $patternDependencyResolver,
97+
protected LoggerChannelInterface $logger,
98+
?ComponentPluginManager $componentPluginManager = NULL,
12399
) {
124-
parent::__construct($root, $module_handler, $theme_manager, $stream_wrapper, $libraries_directory_file_finder, $extension_path_resolver);
100+
parent::__construct(
101+
$root,
102+
$module_handler,
103+
$theme_manager,
104+
$stream_wrapper,
105+
$libraries_directory_file_finder,
106+
$extension_path_resolver,
107+
$componentPluginManager,
108+
);
125109

126-
$this->serializer = $serializer;
127110
$this->patternStorage = $entity_type_manager->getStorage('patternkit_pattern');
128-
$this->dataPreProcessorFactory = $dataPreProcessorFactory;
129-
$this->patternDependencyResolver = $patternDependencyResolver;
130-
$this->logger = $logger;
131111
}
132112

133113
/**

‎tests/src/Functional/BlockTest.php‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,6 @@ public function testBlockCacheTags(): void {
4343
$pattern = $block->getPatternEntity();
4444
$pattern_id = $pattern->id();
4545

46-
// The page cache only works for anonymous users.
47-
$this->drupalLogout();
48-
4946
// Enable page caching.
5047
$config = $this->config('system.performance');
5148
$config->set('cache.page.max_age', 300);

‎tests/src/Functional/PatternkitBrowserTestBase.php‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Drupal\Tests\patternkit\Traits\JsonDecodeTrait;
99
use Drupal\Tests\patternkit\Traits\PatternkitBlockHelperTrait;
1010
use Drupal\Tests\patternkit\Traits\SchemaFixtureTrait;
11+
use Drupal\user\UserInterface;
1112

1213
/**
1314
* A base class for all patternkit browser tests.
@@ -47,6 +48,13 @@ abstract class PatternkitBrowserTestBase extends BrowserTestBase {
4748
*/
4849
protected EntityStorageInterface $patternStorage;
4950

51+
/**
52+
* A test user with editor permissions.
53+
*
54+
* @var \Drupal\user\UserInterface
55+
*/
56+
protected UserInterface $editorUser;
57+
5058
/**
5159
* {@inheritdoc}
5260
*/

‎tests/src/Unit/Asset/LibraryTest.php‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,8 @@ protected function setUp(): void {
167167
);
168168

169169
// Prepare and mock services called from the container.
170-
$this->streamWrapperManager = new StreamWrapperManager();
171-
172170
$this->container = new ContainerBuilder();
171+
$this->streamWrapperManager = new StreamWrapperManager($this->container);
173172
$this->container->set('stream_wrapper_manager', $this->streamWrapperManager);
174173
\Drupal::setContainer($this->container);
175174
}

‎tests/src/Unit/Asset/PatternLibraryParser/PatternLibraryParserBaseTest.php‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Drupal\Tests\patternkit\Unit\Asset\PatternLibraryParser;
44

5+
use Drupal\Core\Theme\ComponentPluginManager;
56
use Drupal\patternkit\Asset\PatternLibraryParserBase;
67
use Drupal\patternkit\Asset\PatternLibraryParserInterface;
78
use Drupal\patternkit\Entity\PatternInterface;
@@ -35,6 +36,10 @@ protected function getParserInstance(): PatternLibraryParserInterface {
3536
$this->entityTypeManager->getStorage('patternkit_pattern')
3637
->willReturn($this->patternStorage->reveal());
3738

39+
if (class_exists(ComponentPluginManager::class)) {
40+
$componentPluginManager = $this->prophesize(ComponentPluginManager::class);
41+
}
42+
3843
return $this->getMockForAbstractClass(PatternLibraryParserBase::class, [
3944
$this->serializer->reveal(),
4045
$this->vfsRoot->url(),
@@ -47,6 +52,7 @@ protected function getParserInstance(): PatternLibraryParserInterface {
4752
$this->dataPreProcessorFactory->reveal(),
4853
$this->patternDependencyResolver->reveal(),
4954
$this->logger->reveal(),
55+
isset($componentPluginManager) ? $componentPluginManager->reveal() : NULL,
5056
]);
5157
}
5258

‎tests/src/Unit/Asset/PatternLibraryParser/PatternLibraryParserTestBase.php‎

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Drupal\Core\Extension\ModuleHandlerInterface;
1313
use Drupal\Core\Logger\LoggerChannelInterface;
1414
use Drupal\Core\StreamWrapper\StreamWrapperManagerInterface;
15+
use Drupal\Core\Theme\ComponentPluginManager;
1516
use Drupal\Core\Theme\ThemeManagerInterface;
1617
use Drupal\patternkit\Asset\PatternDependencyResolver;
1718
use Drupal\patternkit\Asset\PatternLibraryParserInterface;
@@ -44,87 +45,94 @@ abstract class PatternLibraryParserTestBase extends UnitTestCase {
4445
/**
4546
* The module handler service.
4647
*
47-
* @var \Drupal\Core\Extension\ModuleHandlerInterface|\Prophecy\Prophecy\ObjectProphecy
48+
* @var \Prophecy\Prophecy\ObjectProphecy<\Drupal\Core\Extension\ModuleHandlerInterface>
4849
*/
4950
protected ObjectProphecy $moduleHandler;
5051

5152
/**
5253
* The theme manager service.
5354
*
54-
* @var \Drupal\Core\Theme\ThemeManagerInterface|\Prophecy\Prophecy\ObjectProphecy
55+
* @var \Prophecy\Prophecy\ObjectProphecy<\Drupal\Core\Theme\ThemeManagerInterface>
5556
*/
5657
protected ObjectProphecy $themeManager;
5758

5859
/**
5960
* A serializer service.
6061
*
61-
* @var \Drupal\Component\Serialization\SerializationInterface|\Prophecy\Prophecy\ObjectProphecy
62+
* @var \Prophecy\Prophecy\ObjectProphecy<\Drupal\Component\Serialization\SerializationInterface>
6263
*/
6364
protected ObjectProphecy $serializer;
6465

6566
/**
6667
* The stream wrapper manager service.
6768
*
68-
* @var \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface|\Prophecy\Prophecy\ObjectProphecy
69+
* @var \Prophecy\Prophecy\ObjectProphecy<\Drupal\Core\StreamWrapper\StreamWrapperManagerInterface>
6970
*/
7071
protected ObjectProphecy $streamWrapperManager;
7172

7273
/**
7374
* The library directory file finder service.
7475
*
75-
* @var \Drupal\Core\Asset\LibrariesDirectoryFileFinder|\Prophecy\Prophecy\ObjectProphecy
76+
* @var \Prophecy\Prophecy\ObjectProphecy<\Drupal\Core\Asset\LibrariesDirectoryFileFinder>
7677
*/
7778
protected ObjectProphecy $librariesDirectoryFileFinder;
7879

7980
/**
8081
* The extension path resolver service.
8182
*
82-
* @var \Drupal\Core\Extension\ExtensionPathResolver|\Prophecy\Prophecy\ObjectProphecy
83+
* @var \Prophecy\Prophecy\ObjectProphecy<\Drupal\Core\Extension\ExtensionPathResolver>
8384
*/
8485
protected ObjectProphecy $extensionPathResolver;
8586

8687
/**
8788
* The entity type manager service.
8889
*
89-
* @var \Drupal\Core\Entity\EntityTypeManagerInterface|\Prophecy\Prophecy\ObjectProphecy
90+
* @var \Prophecy\Prophecy\ObjectProphecy<\Drupal\Core\Entity\EntityTypeManagerInterface>
9091
*/
9192
protected ObjectProphecy $entityTypeManager;
9293

9394
/**
9495
* The pattern storage handler.
9596
*
96-
* @var \Drupal\Core\Entity\EntityStorageInterface|\Prophecy\Prophecy\ObjectProphecy
97+
* @var \Prophecy\Prophecy\ObjectProphecy<\Drupal\Core\Entity\EntityStorageInterface>
9798
*/
9899
protected ObjectProphecy $patternStorage;
99100

100101
/**
101102
* The schema data preprocessor factory service.
102103
*
103-
* @var \Drupal\patternkit\Schema\DataPreProcessorFactory|\Prophecy\Prophecy\ObjectProphecy
104+
* @var \Prophecy\Prophecy\ObjectProphecy<\Drupal\patternkit\Schema\DataPreProcessorFactory>
104105
*/
105106
protected ObjectProphecy $dataPreProcessorFactory;
106107

107108
/**
108109
* The pattern dependency resolver service.
109110
*
110-
* @var \Drupal\patternkit\Asset\PatternDependencyResolver|ObjectProphecy
111+
* @var \Prophecy\Prophecy\ObjectProphecy<\Drupal\patternkit\Asset\PatternDependencyResolver>
111112
*/
112113
protected ObjectProphecy $patternDependencyResolver;
113114

114115
/**
115116
* The patternkit logger channel.
116117
*
117-
* @var \Drupal\Core\Logger\LoggerChannelInterface|\Prophecy\Prophecy\ObjectProphecy
118+
* @var \Prophecy\Prophecy\ObjectProphecy<\Drupal\Core\Logger\LoggerChannelInterface>
118119
*/
119120
protected ObjectProphecy $logger;
120121

121122
/**
122123
* The pattern environment service.
123124
*
124-
* @var \Drupal\patternkit\PatternkitEnvironment|\Prophecy\Prophecy\ObjectProphecy
125+
* @var \Prophecy\Prophecy\ObjectProphecy<\Drupal\patternkit\PatternkitEnvironment>
125126
*/
126127
protected ObjectProphecy $environment;
127128

129+
/**
130+
* The component plugin manager service if it exists.
131+
*
132+
* @var \Prophecy\Prophecy\ObjectProphecy<\Drupal\Core\Theme\ComponentPluginManager>|null
133+
*/
134+
protected ?ObjectProphecy $componentPluginManager;
135+
128136
/**
129137
* The pattern library parser being tested.
130138
*
@@ -178,6 +186,8 @@ protected function setUpParserDependencies(): void {
178186
$this->logger = $this->prophesize(LoggerChannelInterface::class);
179187
$this->environment = $this->prophesize(PatternkitEnvironment::class);
180188
$this->environment->isDebug()->willReturn(FALSE);
189+
$this->componentPluginManager = class_exists(ComponentPluginManager::class) ?
190+
$this->prophesize(ComponentPluginManager::class) : NULL;
181191

182192
$this->entityTypeManager->getStorage('patternkit_pattern')
183193
->willReturn($this->patternStorage->reveal());
@@ -205,6 +215,7 @@ protected function getParserInstance(): PatternLibraryParserInterface {
205215
$this->dataPreProcessorFactory->reveal(),
206216
$this->patternDependencyResolver->reveal(),
207217
$this->logger->reveal(),
218+
is_null($this->componentPluginManager) ? NULL : $this->componentPluginManager->reveal(),
208219
);
209220

210221
if ($parser instanceof PatternkitEnvironmentAwareInterface) {
@@ -235,6 +246,7 @@ protected function getPartialMock(): MockBuilder {
235246
$this->dataPreProcessorFactory->reveal(),
236247
$this->patternDependencyResolver->reveal(),
237248
$this->logger->reveal(),
249+
is_null($this->componentPluginManager) ? NULL : $this->componentPluginManager->reveal(),
238250
]);
239251
}
240252

0 commit comments

Comments
 (0)