From 0266b6242f0d73bc01d524ed12d1ab904a60895e Mon Sep 17 00:00:00 2001 From: Lee Mills <8024370+millnut@users.noreply.github.com> Date: Fri, 29 Sep 2023 17:39:31 +0100 Subject: [PATCH 1/2] fix: phpstan issues --- src/Plugin/Block/SubsitesBannerBlock.php | 2 +- src/Plugin/Block/SubsitesNavigationBlock.php | 4 +++- tests/src/Functional/SubsitePagesTest.php | 7 +++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Plugin/Block/SubsitesBannerBlock.php b/src/Plugin/Block/SubsitesBannerBlock.php index f98a898..e7bca1d 100644 --- a/src/Plugin/Block/SubsitesBannerBlock.php +++ b/src/Plugin/Block/SubsitesBannerBlock.php @@ -39,7 +39,7 @@ class SubsitesBannerBlock extends SubsitesAbstractBlockBase { public function build() { $build = []; - if ($this->getSubsite($this->node)) { + if ($this->getSubsite()) { if ($banner = $this->getSubsiteBanner()) { $viewBuilder = $this->entityTypeManager->getViewBuilder('paragraph'); $build = $viewBuilder->view($banner); diff --git a/src/Plugin/Block/SubsitesNavigationBlock.php b/src/Plugin/Block/SubsitesNavigationBlock.php index 19c7428..108df95 100644 --- a/src/Plugin/Block/SubsitesNavigationBlock.php +++ b/src/Plugin/Block/SubsitesNavigationBlock.php @@ -7,7 +7,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\Template\Attribute; -use Drupal\Node\NodeInterface; +use Drupal\node\NodeInterface; /** * Class SubsiteNavigationBlock. @@ -51,6 +51,8 @@ public function build() { $cache = (new CacheableMetadata())->addCacheableDependency($subsite_entity); $storage = $this->getNestedSetStorage('localgov_subsites'); $node = $this->getNestedSetNodeKeyFactory()->fromEntity($subsite_entity); + $subsite_id = NULL; + $overview_entity = NULL; if ($ancestors = $storage->findAncestors($node)) { $tree = $storage->findDescendants($ancestors[0]->getNodeKey()); array_unshift($tree, $ancestors[0]); diff --git a/tests/src/Functional/SubsitePagesTest.php b/tests/src/Functional/SubsitePagesTest.php index 835811e..ac57661 100644 --- a/tests/src/Functional/SubsitePagesTest.php +++ b/tests/src/Functional/SubsitePagesTest.php @@ -36,6 +36,13 @@ class SubsitePagesTest extends BrowserTestBase { */ protected $adminUser; + /** + * Node to hold the article. + * + * @var \Drupal\node\NodeInterface + */ + protected $nodeStorage; + /** * Modules to enable. * From da968bba258ca87df4aca114f0e35778eb65015f Mon Sep 17 00:00:00 2001 From: Lee Mills <8024370+millnut@users.noreply.github.com> Date: Mon, 2 Oct 2023 15:32:26 +0100 Subject: [PATCH 2/2] fix: phpstan issues - remove not required variable --- tests/src/Functional/SubsitePagesTest.php | 8 -------- 1 file changed, 8 deletions(-) diff --git a/tests/src/Functional/SubsitePagesTest.php b/tests/src/Functional/SubsitePagesTest.php index ac57661..c10f811 100644 --- a/tests/src/Functional/SubsitePagesTest.php +++ b/tests/src/Functional/SubsitePagesTest.php @@ -36,13 +36,6 @@ class SubsitePagesTest extends BrowserTestBase { */ protected $adminUser; - /** - * Node to hold the article. - * - * @var \Drupal\node\NodeInterface - */ - protected $nodeStorage; - /** * Modules to enable. * @@ -72,7 +65,6 @@ protected function setUp(): void { 'create localgov_subsites_overview content', ]); - $this->nodeStorage = $this->container->get('entity_type.manager')->getStorage('node'); } /**