-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
de-duplicate code in a more comprehensible way
- Loading branch information
Showing
15 changed files
with
370 additions
and
211 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
namespace App\Classes\MediaHandler; | ||
|
||
use App\Enums\MediaStorage; | ||
use App\Enums\MediaType; | ||
use App\Enums\ResponseState; | ||
use App\Interfaces\MediaHandlerInterface; | ||
use CdnHelper; | ||
use Illuminate\Contracts\Filesystem\Filesystem; | ||
use Throwable; | ||
|
||
abstract class MediaHandler implements MediaHandlerInterface | ||
{ | ||
protected MediaType $type; | ||
protected MediaStorage $derivativesStorage; | ||
protected ResponseState $uploadSuccessful; | ||
protected ResponseState $uploadFailed; | ||
protected ResponseState $versionSetSuccessful; | ||
protected ResponseState $versionSetFailed; | ||
|
||
/** | ||
* @return Filesystem | ||
*/ | ||
public function getDerivativesDisk(): Filesystem | ||
{ | ||
return $this->derivativesStorage->getDisk(); | ||
} | ||
|
||
/** | ||
* @param string $basePath | ||
* @return bool | ||
*/ | ||
public function invalidateCdnCache(string $basePath): bool | ||
{ | ||
if (CdnHelper::isConfigured()) { | ||
try { | ||
CdnHelper::invalidateMedia($this->type, $basePath); | ||
} catch (Throwable) { | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace App\Facades; | ||
|
||
use Illuminate\Support\Facades\Facade; | ||
|
||
class DeliveryFacade extends Facade | ||
{ | ||
/** | ||
* Get the registered name of the component. | ||
* | ||
* @return string | ||
*/ | ||
protected static function getFacadeAccessor(): string | ||
{ | ||
return 'delivery'; | ||
} | ||
} |
Oops, something went wrong.