13
13
use Drupal \Core \DependencyInjection \ContainerInjectionInterface ;
14
14
use Drupal \Core \Extension \ModuleHandlerInterface ;
15
15
use Drupal \Core \File \FileSystemInterface ;
16
+ use Drupal \Core \Logger \LoggerChannelInterface ;
16
17
use Drupal \Core \Serialization \Yaml ;
17
18
use Drupal \Core \Theme \ThemeManagerInterface ;
18
19
use Drupal \patternkit \Form \PatternkitSettingsForm ;
@@ -50,6 +51,9 @@ class PatternLibraryCollector extends CacheCollector implements ContainerInjecti
50
51
/** @var \Drupal\patternkit\PatternLibraryPluginManager */
51
52
protected $ libraryPluginManager ;
52
53
54
+ /** @var \Drupal\Core\Logger\LoggerChannelInterface */
55
+ protected $ logger ;
56
+
53
57
/** @var \Drupal\Core\Extension\ModuleHandlerInterface */
54
58
protected $ moduleHandler ;
55
59
@@ -74,6 +78,8 @@ class PatternLibraryCollector extends CacheCollector implements ContainerInjecti
74
78
* Provide the file system service.
75
79
* @param \Drupal\Core\Lock\LockBackendInterface $lock
76
80
* Provide the lock backend.
81
+ * @param \Drupal\Core\Logger\LoggerChannelInterface $logger
82
+ * Provide the logging channel.
77
83
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
78
84
* Provide a module handler.
79
85
* @param \Drupal\patternkit\PatternLibraryPluginManager $library_plugin_manager
@@ -89,6 +95,7 @@ public function __construct(
89
95
FileSystemInterface $ file_system ,
90
96
PatternLibraryPluginManager $ library_plugin_manager ,
91
97
LockBackendInterface $ lock ,
98
+ LoggerChannelInterface $ logger ,
92
99
ModuleHandlerInterface $ module_handler ,
93
100
$ root ,
94
101
ThemeManagerInterface $ theme_manager ) {
@@ -97,6 +104,7 @@ public function __construct(
97
104
$ this ->config = $ this ->configFactory ->get (PatternkitSettingsForm::SETTINGS );
98
105
$ this ->fileSystem = $ file_system ;
99
106
$ this ->libraryPluginManager = $ library_plugin_manager ;
107
+ $ this ->logger = $ logger ;
100
108
$ this ->moduleHandler = $ module_handler ;
101
109
$ this ->root = $ root ;
102
110
$ this ->themeManager = $ theme_manager ;
@@ -120,6 +128,8 @@ public static function create(ContainerInterface $container): self {
120
128
$ file_system = $ container ->get ('file_system ' );
121
129
/** @var \Drupal\Core\Lock\LockBackendInterface $lock */
122
130
$ lock = $ container ->get ('lock ' );
131
+ /** @var \Drupal\Core\Logger\LoggerChannelInterface $logger */
132
+ $ logger = $ container ->get ('@logger.channel.default ' );
123
133
/** @var \Drupal\Core\Extension\ModuleHandlerInterface $module_handler */
124
134
$ module_handler = $ container ->get ('module_handler ' );
125
135
/** @var string $root */
@@ -132,6 +142,7 @@ public static function create(ContainerInterface $container): self {
132
142
$ file_system ,
133
143
$ library_plugin_manager ,
134
144
$ lock ,
145
+ $ logger ,
135
146
$ module_handler ,
136
147
$ root ,
137
148
$ theme_manager );
@@ -159,8 +170,13 @@ public function getLibraryDefinitions(): array {
159
170
// (if cache enabled, otherwise just a slow, redundant memcache set).
160
171
if ($ cache_enabled ) {
161
172
// Explicit copy of the data into cache_set to avoid implicit copy.
173
+ // @todo Evaluate encoding via JSON instead to shrink data size.
162
174
$ this ->cache ->set (static ::PERSISTENT_CACHE_ID ,
163
175
$ cached_metadata );
176
+ $ cache = $ this ->cache ->get (static ::PERSISTENT_CACHE_ID );
177
+ if ($ cache ->data !== $ cached_metadata ) {
178
+ $ this ->logger ->warning ('Error storing Patternkit Library Metadata in cache. Check that memcache or your caching module has be configured correctly. ' );
179
+ }
164
180
}
165
181
}
166
182
return $ cached_metadata ;
0 commit comments