Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
StyleCIBot committed Nov 25, 2024
1 parent bb7ffd8 commit 7066e55
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 19 deletions.
16 changes: 7 additions & 9 deletions extend.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

return [
(new Extend\Frontend('admin'))
->js(__DIR__ . '/js/dist/admin.js')
->css(__DIR__ . '/less/admin.less')
->js(__DIR__.'/js/dist/admin.js')
->css(__DIR__.'/less/admin.less')
->content(Content\AdminPayload::class),

new Extend\Locales(__DIR__ . '/locale'),
new Extend\Locales(__DIR__.'/locale'),

(new Extend\Settings())
->default('fof-s3-assets.share_s3_config_with_fof_upload', false),
Expand All @@ -30,12 +30,10 @@
->register(Provider\S3DiskProvider::class),

(new Extend\Event())
->listen(SettingsSaving::class, Listener\SettingsChanged::class)

(new S3Lifecycle()),
->listen(SettingsSaving::class, Listener\SettingsChanged::class)(new S3Lifecycle()),

(new Extend\Conditional())
->when((resolve(ConditionalCheck::class))->validConfig(), fn() => [
->when(resolve(ConditionalCheck::class)->validConfig(), fn () => [
(new Extend\Console())
->command(Console\CopyAssetsCommand::class),

Expand All @@ -44,6 +42,6 @@
->driver('local', Driver\S3Driver::class),

(new Extend\Event())
->listen(ClearingCache::class, Listener\RepublishAssets::class)
])
->listen(ClearingCache::class, Listener\RepublishAssets::class),
]),
];
19 changes: 15 additions & 4 deletions src/ConditionalCheck.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of fof/s3-assets.
*
* Copyright (c) FriendsOfFlarum
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/

namespace FoF\S3Assets;

use Exception;
Expand All @@ -10,23 +19,24 @@
class ConditionalCheck
{
const CACHE_KEY = 'fof-s3-assets-config-valid';

public function __construct(
protected DriverConfig $config,
protected S3DiskConfigValidator $validator,
protected Store $cache
) {}
) {
}

/**
* Checks to see if the supplied config passes the required checks
* Checks to see if the supplied config passes the required checks.
*/
public function validConfig(): bool
{
// If we have a cached value, return it
if (($cacheValue = $this->cache->get(self::CACHE_KEY)) && $cacheValue !== null) {
return $cacheValue;
}

// If we don't have a cached value, check the config
$config = $this->config->config();

Expand All @@ -39,6 +49,7 @@ public function validConfig(): bool
$this->cache->forever(self::CACHE_KEY, true);
} catch (Exception $e) {
$this->cache->forever(self::CACHE_KEY, false);

return false;
}

Expand Down
12 changes: 11 additions & 1 deletion src/Listener/RepublishAssets.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of fof/s3-assets.
*
* Copyright (c) FriendsOfFlarum
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/

namespace FoF\S3Assets\Listener;

use Flarum\Foundation\Event\ClearingCache;
Expand All @@ -9,7 +18,8 @@ class RepublishAssets
{
public function __construct(
protected S3Repository $s3
) {}
) {
}

public function handle(ClearingCache $event)
{
Expand Down
12 changes: 11 additions & 1 deletion src/Listener/SettingsChanged.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of fof/s3-assets.
*
* Copyright (c) FriendsOfFlarum
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/

namespace FoF\S3Assets\Listener;

use Flarum\Settings\Event\Saving;
Expand All @@ -10,7 +19,8 @@ class SettingsChanged
{
public function __construct(
protected Store $cache
) {}
) {
}

public function handle(Saving $event)
{
Expand Down
5 changes: 2 additions & 3 deletions src/Repository/S3Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public function __construct(
protected DriverConfig $config,
protected CacheClearCommand $cache,
protected AssetsPublishCommand $publish,

) {
}

Expand All @@ -36,7 +35,7 @@ public function cdnHost(): string
}

/**
* Just a helper method to call the Flarum clear cache command
* Just a helper method to call the Flarum clear cache command.
*
* @return void
*/
Expand All @@ -49,7 +48,7 @@ public function clearCache(): void
}

/**
* Just a helper method to call the Flarum publish assets command
* Just a helper method to call the Flarum publish assets command.
*
* @return void
*/
Expand Down
11 changes: 10 additions & 1 deletion src/S3Lifecycle.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
<?php

/*
* This file is part of fof/s3-assets.
*
* Copyright (c) FriendsOfFlarum
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/

namespace FoF\S3Assets;

use Flarum\Extend\LifecycleInterface;
use Illuminate\Contracts\Container\Container;
use Flarum\Extension\Extension;
use FoF\S3Assets\Repository\S3Repository;
use Illuminate\Contracts\Container\Container;

class S3Lifecycle implements LifecycleInterface
{
Expand Down

0 comments on commit 7066e55

Please sign in to comment.