diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f8e3b9..103a659 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - Raise minimum required version to TYPO3 10.4.11 +### Fixed +- Show dashboard widgets in non-composer installation + ## [0.3.1] - 2020-12-22 ### Added diff --git a/Classes/Backend/DashboardPresetsProvider.php b/Classes/Backend/DashboardPresetsProvider.php index f85e982..dc73cfe 100644 --- a/Classes/Backend/DashboardPresetsProvider.php +++ b/Classes/Backend/DashboardPresetsProvider.php @@ -41,7 +41,7 @@ final class DashboardPresetsProvider */ public function __construct($configurationFinder = null) { - $this->configurationFinder = $configurationFinder ?? new ConfigurationFinder(Environment::getProjectPath()); + $this->configurationFinder = $configurationFinder ?? new ConfigurationFinder(Environment::getConfigPath()); } public function getPresets(): array diff --git a/Classes/Configuration/ConfigurationFinder.php b/Classes/Configuration/ConfigurationFinder.php index f0de94e..a42a13d 100644 --- a/Classes/Configuration/ConfigurationFinder.php +++ b/Classes/Configuration/ConfigurationFinder.php @@ -19,12 +19,12 @@ class ConfigurationFinder implements \IteratorAggregate, \Countable /** @var array */ private $configurations = []; - public function __construct(string $projectPath) + public function __construct(string $configPath) { $finder = new Finder(); try { $finder - ->in($projectPath . '/config/sites/*') + ->in($configPath . '/sites/*') ->name('config.yaml'); foreach ($finder as $file) { diff --git a/Configuration/Services.php b/Configuration/Services.php index fbf53b3..15ec56d 100644 --- a/Configuration/Services.php +++ b/Configuration/Services.php @@ -48,7 +48,7 @@ $services->alias(RepositoryInterface::class, CachingRepositoryDecorator::class); - $configurationFinder = new ConfigurationFinder(Environment::getProjectPath()); + $configurationFinder = new ConfigurationFinder(Environment::getConfigPath()); foreach ($configurationFinder as $matomoConfiguration) { /** @var Configuration $matomoConfiguration */ $connectionConfigurationId = 'matomo_widgets.connectionConfiguration.' . $matomoConfiguration->getSiteIdentifier(); diff --git a/Tests/Unit/Configuration/ConfigurationFinderTest.php b/Tests/Unit/Configuration/ConfigurationFinderTest.php index cce1366..3ab5426 100644 --- a/Tests/Unit/Configuration/ConfigurationFinderTest.php +++ b/Tests/Unit/Configuration/ConfigurationFinderTest.php @@ -17,23 +17,23 @@ class ConfigurationFinderTest extends TestCase { /** @var string */ - private static $tmpDir; + private static $configPath; public static function setUpBeforeClass(): void { - self::$tmpDir = \realpath(\sys_get_temp_dir()) . \DIRECTORY_SEPARATOR . 'matomo_widgets_configuration_finder'; + self::$configPath = \realpath(\sys_get_temp_dir()) . \DIRECTORY_SEPARATOR . 'matomo_widgets_configuration_finder'; - if (\is_dir(self::$tmpDir)) { + if (\is_dir(self::$configPath)) { self::tearDownAfterClass(); } else { - \mkdir(self::$tmpDir); + \mkdir(self::$configPath); } } public static function tearDownAfterClass(): void { $paths = new \RecursiveIteratorIterator( - new \RecursiveDirectoryIterator(self::$tmpDir, \RecursiveDirectoryIterator::SKIP_DOTS), + new \RecursiveDirectoryIterator(self::$configPath, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST ); @@ -60,7 +60,7 @@ protected function tearDown(): void */ public function classIsTraversable(): void { - $subject = new ConfigurationFinder(self::$tmpDir); + $subject = new ConfigurationFinder(self::$configPath); self::assertInstanceOf(\Traversable::class, $subject); } @@ -70,7 +70,7 @@ public function classIsTraversable(): void */ public function classImplementsCountable(): void { - $subject = new ConfigurationFinder(self::$tmpDir); + $subject = new ConfigurationFinder(self::$configPath); self::assertInstanceOf(\Countable::class, $subject); } @@ -80,7 +80,7 @@ public function classImplementsCountable(): void */ public function noSiteConfigurationFoundThenNoMatomoConfigurationExists(): void { - $subject = new ConfigurationFinder(self::$tmpDir); + $subject = new ConfigurationFinder(self::$configPath); self::assertCount(0, $subject); } @@ -91,7 +91,7 @@ public function noSiteConfigurationFoundThenNoMatomoConfigurationExists(): void public function siteConfigurationWithNoMatomoConfigurationIsNotTakenIntoAccount(): void { $this->createSiteConfiguration('some_site', []); - $subject = new ConfigurationFinder(self::$tmpDir); + $subject = new ConfigurationFinder(self::$configPath); self::assertCount(0, $subject); } @@ -108,7 +108,7 @@ public function siteConfigurationWithEmptyMatomoConfigurationIsNotTakenIntoAccou 'matomoWidgetsUrl' => '', ]; $this->createSiteConfiguration('some_site', $configuration); - $subject = new ConfigurationFinder(self::$tmpDir); + $subject = new ConfigurationFinder(self::$configPath); self::assertCount(0, $subject); } @@ -127,7 +127,7 @@ public function siteConfigurationWithAvailableMatomoConfigurationIsTakenIntoAcco 'matomoWidgetsEnableActionsPerMonth' => false, ]; $this->createSiteConfiguration('some_site', $configuration); - $subject = new ConfigurationFinder(self::$tmpDir); + $subject = new ConfigurationFinder(self::$configPath); self::assertCount(1, $subject); @@ -156,7 +156,7 @@ public function siteConfigurationWithAvailableMatomoConfigurationButMissingIdSit 'matomoWidgetsUrl' => 'https://example.org/', ]; $this->createSiteConfiguration('some_site', $configuration); - $subject = new ConfigurationFinder(self::$tmpDir); + $subject = new ConfigurationFinder(self::$configPath); self::assertCount(0, $subject); } @@ -173,14 +173,14 @@ public function siteConfigurationWithAvailableMatomoConfigurationButMissingUrlIs 'matomoWidgetsUrl' => '', ]; $this->createSiteConfiguration('some_site', $configuration); - $subject = new ConfigurationFinder(self::$tmpDir); + $subject = new ConfigurationFinder(self::$configPath); self::assertCount(0, $subject); } private function createSiteConfiguration(string $identifier, array $configuration): void { - $path = self::$tmpDir . '/config/sites/' . $identifier; + $path = self::$configPath . '/sites/' . $identifier; \mkdir($path, 0777, true); $yamlConfiguration = '';