Skip to content

Commit

Permalink
[BUGFIX] Show dashboard widgets in non-composer installation
Browse files Browse the repository at this point in the history
Resolves: #5
brotkrueml committed Jan 11, 2021
1 parent 0970745 commit d94a507
Showing 5 changed files with 21 additions and 18 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion Classes/Backend/DashboardPresetsProvider.php
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions Classes/Configuration/ConfigurationFinder.php
Original file line number Diff line number Diff line change
@@ -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) {
2 changes: 1 addition & 1 deletion Configuration/Services.php
Original file line number Diff line number Diff line change
@@ -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();
28 changes: 14 additions & 14 deletions Tests/Unit/Configuration/ConfigurationFinderTest.php
Original file line number Diff line number Diff line change
@@ -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 = '';

0 comments on commit d94a507

Please sign in to comment.