Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

./vendor/bin/phpunit --coverage-html ./build
XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-html ./build
php coverage-checker.php ./build/clover.xml 95
10 changes: 10 additions & 0 deletions src/Configuration/Providers/ConfigurationServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use GamingEngine\Core\Configuration\Repositories\ConfigurationRepository;
use GamingEngine\Core\Configuration\Repositories\DatabaseConfigurationRepository;
use GamingEngine\Core\Configuration\SiteConfiguration;
use GamingEngine\Core\Core;
use GamingEngine\Core\Framework\Http\View\Composers\ConfigurationViewComposer;
use Illuminate\Support\Facades\View;
use Illuminate\Support\ServiceProvider;
Expand Down Expand Up @@ -47,6 +48,15 @@ function () {

public function boot()
{
/**
* @var Core $core
*/
$core = app(Core::class);

if (! $core->installed()) {
return;
}

View::composer('*', ConfigurationViewComposer::class);
}
}
18 changes: 9 additions & 9 deletions src/Configuration/Repositories/CachedConfigurationRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,6 @@ public function account(): AccountConfiguration
);
}

public function site(): SiteConfiguration
{
return $this->cache(
SiteConfiguration::type(),
fn () => $this->configurationRepository->site()
);
}

private function cache(string $category, callable $values)
{
return Cache::rememberForever(
Expand All @@ -52,13 +44,21 @@ private function cacheKey(string $category): string
);
}

public function site(): SiteConfiguration
{
return $this->cache(
SiteConfiguration::type(),
fn () => $this->configurationRepository->site()
);
}

public function update(BaseConfiguration $configuration): BaseConfiguration
{
$response = $this->configurationRepository->update($configuration);

Cache::put(
$this->cacheKey($configuration::type()),
fn () => $response,
$response,
);

return $response;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public function cached_configuration_will_re_cache_the_data_on_update()
$repository = new CachedConfigurationRepository($wrapped);

Cache::shouldReceive('put')
->withArgs(fn ($key, $c) => $configuration === $c())
->withArgs(fn ($key, $c) => $configuration === $c)
->andReturn($configuration);

$wrapped->shouldReceive('update')
Expand Down