Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion patternkit.services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ services:
arguments: ['@patternkit.library.discovery.collector']
patternkit.library.discovery.collector:
class: Drupal\patternkit\PatternLibraryCollector
arguments: ['@cache.discovery', '@config.factory', '@file_system', '@plugin.manager.library.pattern', '@lock', '@module_handler', '@app.root', '@theme.manager']
arguments: ['@cache.discovery', '@config.factory', '@file_system', '@plugin.manager.library.pattern', '@lock', '@logger.channel.default', '@module_handler', '@app.root', '@theme.manager']
tags:
- { name: needs_destruction }
patternkit.library.discovery.parser.file:
Expand Down
16 changes: 16 additions & 0 deletions src/PatternLibraryCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\File\FileSystemInterface;
use Drupal\Core\Logger\LoggerChannelInterface;
use Drupal\Core\Serialization\Yaml;
use Drupal\Core\Theme\ThemeManagerInterface;
use Drupal\patternkit\Form\PatternkitSettingsForm;
Expand Down Expand Up @@ -50,6 +51,9 @@ class PatternLibraryCollector extends CacheCollector implements ContainerInjecti
/** @var \Drupal\patternkit\PatternLibraryPluginManager */
protected $libraryPluginManager;

/** @var \Drupal\Core\Logger\LoggerChannelInterface */
protected $logger;

/** @var \Drupal\Core\Extension\ModuleHandlerInterface */
protected $moduleHandler;

Expand All @@ -74,6 +78,8 @@ class PatternLibraryCollector extends CacheCollector implements ContainerInjecti
* Provide the file system service.
* @param \Drupal\Core\Lock\LockBackendInterface $lock
* Provide the lock backend.
* @param \Drupal\Core\Logger\LoggerChannelInterface $logger
* Provide the logging channel.
* @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
* Provide a module handler.
* @param \Drupal\patternkit\PatternLibraryPluginManager $library_plugin_manager
Expand All @@ -89,6 +95,7 @@ public function __construct(
FileSystemInterface $file_system,
PatternLibraryPluginManager $library_plugin_manager,
LockBackendInterface $lock,
LoggerChannelInterface $logger,
ModuleHandlerInterface $module_handler,
$root,
ThemeManagerInterface $theme_manager) {
Expand All @@ -97,6 +104,7 @@ public function __construct(
$this->config = $this->configFactory->get(PatternkitSettingsForm::SETTINGS);
$this->fileSystem = $file_system;
$this->libraryPluginManager = $library_plugin_manager;
$this->logger = $logger;
$this->moduleHandler = $module_handler;
$this->root = $root;
$this->themeManager = $theme_manager;
Expand All @@ -120,6 +128,8 @@ public static function create(ContainerInterface $container): self {
$file_system = $container->get('file_system');
/** @var \Drupal\Core\Lock\LockBackendInterface $lock */
$lock = $container->get('lock');
/** @var \Drupal\Core\Logger\LoggerChannelInterface $logger */
$logger = $container->get('@logger.channel.default');
/** @var \Drupal\Core\Extension\ModuleHandlerInterface $module_handler */
$module_handler = $container->get('module_handler');
/** @var string $root */
Expand All @@ -132,6 +142,7 @@ public static function create(ContainerInterface $container): self {
$file_system,
$library_plugin_manager,
$lock,
$logger,
$module_handler,
$root,
$theme_manager);
Expand Down Expand Up @@ -159,8 +170,13 @@ public function getLibraryDefinitions(): array {
// (if cache enabled, otherwise just a slow, redundant memcache set).
if ($cache_enabled) {
// Explicit copy of the data into cache_set to avoid implicit copy.
// @todo Evaluate encoding via JSON instead to shrink data size.
$this->cache->set(static::PERSISTENT_CACHE_ID,
$cached_metadata);
$cache = $this->cache->get(static::PERSISTENT_CACHE_ID);
if ($cache->data !== $cached_metadata) {
$this->logger->warning('Error storing Patternkit Library Metadata in cache. Check that memcache or your caching module has be configured correctly.');
}
}
}
return $cached_metadata;
Expand Down