17 use Psr\Log\LoggerInterface;
27 private $contentProvider;
39 private static $cachePrefix =
'release-notification-content-';
44 private $cacheStorage;
54 private $productMetadata;
82 LoggerInterface $logger
84 $this->contentProvider = $contentProvider;
85 $this->renderer = $render;
86 $this->cacheStorage = $cacheStorage;
88 $this->productMetadata = $productMetadata;
106 $modalContent = $this->getNotificationContent();
109 $pages = $modalContent[
'pages'];
110 $pageCount = count($pages);
113 foreach ($pages as
$page) {
114 $meta = $this->buildNotificationMeta($meta,
$page, $counter++ == $pageCount);
117 $meta = $this->hideNotification($meta);
131 private function buildNotificationMeta(array $meta, array
$page, $isLastPage)
133 $meta[
'notification_modal_' .
$page[
'name']][
'arguments'][
'data'][
'config'] = [
134 'isTemplate' =>
false,
135 'componentType' => Component\Modal::NAME
138 $meta[
'notification_modal_' .
$page[
'name']][
'children'][
'notification_fieldset'][
'children']
139 [
'notification_text'][
'arguments'][
'data'][
'config'] = [
140 'text' => $this->renderer->getNotificationContent(
$page)
144 $meta[
'notification_modal_' .
$page[
'name']][
'arguments'][
'data'][
'config'][
'options'] = [
145 'title' => $this->renderer->getNotificationTitle(
$page),
151 'targetName' =>
'${ $.name }',
152 'actionName' =>
'closeReleaseNotes' 155 'class' =>
'release-notification-button-next' 160 $meta[
'notification_modal_' .
$page[
'name']][
'children'][
'notification_fieldset'][
'children']
161 [
'notification_buttons'][
'children'][
'notification_button_next'][
'arguments'][
'data'][
'config'] = [
162 'buttonClasses' =>
'hide-release-notification' 165 $meta[
'notification_modal_' .
$page[
'name']][
'arguments'][
'data'][
'config'][
'options'] = [
166 'title' => $this->renderer->getNotificationTitle(
$page)
179 private function hideNotification(array $meta)
181 $meta[
'notification_modal_1'][
'arguments'][
'data'][
'config'][
'options'] = [
193 private function getNotificationContent()
195 $version = strtolower($this->getTargetVersion());
196 $edition = strtolower($this->productMetadata->getEdition());
197 $locale = strtolower($this->session->getUser()->getInterfaceLocale());
200 $modalContent = $this->cacheStorage->load($cacheKey);
201 if ($modalContent ===
false) {
202 $modalContent = $this->contentProvider->getContent(
$version,
$edition, $locale);
203 $this->cacheStorage->save($modalContent, $cacheKey);
206 return !$modalContent ? $modalContent : $this->unserializeContent($modalContent);
215 private function unserializeContent($modalContent)
220 $result = $this->serializer->unserialize($modalContent);
221 }
catch (\InvalidArgumentException $e) {
222 $this->logger->warning(
224 'Failed to unserialize the release notification content. The error is: %s',
239 private function getTargetVersion()
241 $metadataVersion = $this->productMetadata->getVersion();
242 $version = strstr($metadataVersion,
'-',
true);
foreach(array_keys($composerData['require']) as $requiredPackage) if(empty($edition)) if(!empty($opts['edition'])) $edition
__construct(ContentProviderInterface $contentProvider, NotificationRenderer $render, CacheInterface $cacheStorage, SerializerInterface $serializer, ProductMetadataInterface $productMetadata, Session $session, LoggerInterface $logger)