diff --git a/helfi_navigation.module b/helfi_navigation.module index a91c42d..02fdfca 100644 --- a/helfi_navigation.module +++ b/helfi_navigation.module @@ -179,7 +179,7 @@ function helfi_navigation_page_attachments(array &$attachments) : void { */ function helfi_navigation_form_node_form_alter( array &$form, - FormStateInterface $form_state + FormStateInterface $form_state, ) :void { assert($form_state->getFormObject() instanceof EntityFormInterface); /** @var \Drupal\node\NodeInterface $node */ diff --git a/src/ApiManager.php b/src/ApiManager.php index 707b38f..3804df2 100644 --- a/src/ApiManager.php +++ b/src/ApiManager.php @@ -78,7 +78,7 @@ public function withBypassCache() : self { public function get( string $langcode, string $menuId, - array $options = [] + array $options = [], ) : ApiResponse { $key = $this->getCacheKey(sprintf('external_menu:%s:%s', $menuId, $langcode), $options); diff --git a/src/Event/MenuTreeBuilderLink.php b/src/Event/MenuTreeBuilderLink.php index 75e001f..066869f 100644 --- a/src/Event/MenuTreeBuilderLink.php +++ b/src/Event/MenuTreeBuilderLink.php @@ -25,7 +25,7 @@ final class MenuTreeBuilderLink extends Event { public function __construct( public Url $url, public string $language, - public array $item + public array $item, ) { } diff --git a/src/ExternalMenuTreeBuilder.php b/src/ExternalMenuTreeBuilder.php index 108412e..820f556 100644 --- a/src/ExternalMenuTreeBuilder.php +++ b/src/ExternalMenuTreeBuilder.php @@ -130,7 +130,7 @@ private function transform(array $items, array $options): array { private function createLink( object $item, string $menu, - bool $expand_all_items + bool $expand_all_items, ): array { $link_definition = [ 'menu_name' => $menu, diff --git a/src/Menu/MenuTreeBuilder.php b/src/Menu/MenuTreeBuilder.php index a5ae4d2..3c2496c 100644 --- a/src/Menu/MenuTreeBuilder.php +++ b/src/Menu/MenuTreeBuilder.php @@ -42,7 +42,7 @@ public function __construct( private readonly InternalDomainResolver $domainResolver, private readonly MenuLinkTreeInterface $menuTree, private readonly MenuLinkManagerInterface $menuLinkManager, - private readonly EventDispatcherInterface $eventDispatcher + private readonly EventDispatcherInterface $eventDispatcher, ) { } @@ -68,7 +68,7 @@ public function build( string $menuName, string $langcode, object $rootElement = NULL, - MenuTreeParameters $parameters = NULL + MenuTreeParameters $parameters = NULL, ): array { if (!$parameters) { $parameters = new MenuTreeParameters(); diff --git a/src/Plugin/Block/MenuBlockBase.php b/src/Plugin/Block/MenuBlockBase.php index f37dda0..74cefd1 100644 --- a/src/Plugin/Block/MenuBlockBase.php +++ b/src/Plugin/Block/MenuBlockBase.php @@ -27,7 +27,7 @@ public static function create( ContainerInterface $container, array $configuration, $plugin_id, - $plugin_definition + $plugin_definition, ) : static { $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition); $instance->logger = $container->get('logger.channel.helfi_navigation'); diff --git a/src/Plugin/Block/MobileMenuFallbackBlock.php b/src/Plugin/Block/MobileMenuFallbackBlock.php index 177162e..304060e 100644 --- a/src/Plugin/Block/MobileMenuFallbackBlock.php +++ b/src/Plugin/Block/MobileMenuFallbackBlock.php @@ -79,7 +79,7 @@ public static function create( ContainerInterface $container, array $configuration, $plugin_id, - $plugin_definition + $plugin_definition, ): static { $instance = parent::create($container, $configuration, $plugin_id, $plugin_definition); $instance->configFactory = $container->get('config.factory'); diff --git a/src/Plugin/QueueWorker/MenuQueue.php b/src/Plugin/QueueWorker/MenuQueue.php index 7cc77d0..5f6778b 100644 --- a/src/Plugin/QueueWorker/MenuQueue.php +++ b/src/Plugin/QueueWorker/MenuQueue.php @@ -7,7 +7,6 @@ use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Drupal\Core\Queue\QueueWorkerBase; use Drupal\helfi_api_base\Cache\CacheTagInvalidatorInterface; -use Drupal\helfi_api_base\Environment\Project; use Drupal\helfi_navigation\MainMenuManager; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -67,7 +66,8 @@ public function processItem($data) : void { $this->mainMenuManager->sync($language); } catch (\Throwable) { - // The failed sync will be logged by ApiManager. + // Don't invalidate remote caches if sync failed. + return; } } @@ -80,11 +80,6 @@ public function processItem($data) : void { // locally. sprintf('external_menu:%s:%s', $menuName, $language), ]); - $this->cacheTagInvalidator->invalidateTags([ - // This is used by REST API collection endpoint on Etusivu. - 'config:rest.resource.helfi_global_menu_collection', - ], [Project::ETUSIVU]); - } } diff --git a/tests/src/Traits/MenuLinkTrait.php b/tests/src/Traits/MenuLinkTrait.php index 45926e2..9ffb083 100644 --- a/tests/src/Traits/MenuLinkTrait.php +++ b/tests/src/Traits/MenuLinkTrait.php @@ -53,7 +53,7 @@ protected function createNodeWithAlias() : NodeInterface { * The menu link. */ protected function createTestLink( - array $overrides = [] + array $overrides = [], ) : MenuLinkContentInterface { $defaults = [ 'menu_name' => 'main', diff --git a/tests/src/Unit/ApiManagerTest.php b/tests/src/Unit/ApiManagerTest.php index bfc81cf..7e8aaa2 100644 --- a/tests/src/Unit/ApiManagerTest.php +++ b/tests/src/Unit/ApiManagerTest.php @@ -90,9 +90,9 @@ private function getTimeMock(int $expectedTime) : ObjectProphecy { * The api client. */ private function getApiClientMock( - ClientInterface $httpClient, - TimeInterface $time = NULL, - EnvironmentResolverInterface $environmentResolver = NULL, + ClientInterface $httpClient, + TimeInterface $time = NULL, + EnvironmentResolverInterface $environmentResolver = NULL, ): ApiClient { if (!$time) { $time = $this->getTimeMock(time())->reveal(); diff --git a/tests/src/Unit/Plugin/QueueWorker/MenuQueueTest.php b/tests/src/Unit/Plugin/QueueWorker/MenuQueueTest.php index 2cc9615..ce652ee 100644 --- a/tests/src/Unit/Plugin/QueueWorker/MenuQueueTest.php +++ b/tests/src/Unit/Plugin/QueueWorker/MenuQueueTest.php @@ -7,7 +7,6 @@ use Drupal\helfi_api_base\Azure\PubSub\PubSubManagerInterface; use Drupal\helfi_api_base\Cache\CacheTagInvalidator; use Drupal\helfi_api_base\Cache\CacheTagInvalidatorInterface; -use Drupal\helfi_api_base\Environment\Project; use Drupal\helfi_navigation\MainMenuManager; use Drupal\helfi_navigation\Plugin\QueueWorker\MenuQueue; use Drupal\Tests\UnitTestCase; @@ -84,10 +83,6 @@ public function testCacheInvalidator() : void { 'external_menu:main:fi', ]) ->shouldBeCalled(); - $cacheTagInvalidator->invalidateTags([ - 'config:rest.resource.helfi_global_menu_collection', - ], [Project::ETUSIVU]) - ->shouldBeCalled(); $container->set('helfi_api_base.cache_tag_invalidator', $cacheTagInvalidator->reveal()); $sut = MenuQueue::create($container, [], '', []);