-
-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[stacked 12] Use pipes photo partners (#2376)
- Loading branch information
Showing
5 changed files
with
152 additions
and
4 deletions.
There are no files selected for viewing
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
16 changes: 16 additions & 0 deletions
16
app/Actions/Photo/Pipes/PhotoPartner/DeleteOldVideoPartner.php
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,16 @@ | ||
<?php | ||
|
||
namespace App\Actions\Photo\Pipes\PhotoPartner; | ||
|
||
use App\Contracts\PhotoCreate\PhotoPartnerPipe; | ||
use App\DTO\PhotoCreate\PhotoPartnerDTO; | ||
|
||
class DeleteOldVideoPartner implements PhotoPartnerPipe | ||
{ | ||
public function handle(PhotoPartnerDTO $state, \Closure $next): PhotoPartnerDTO | ||
{ | ||
$state->oldVideo->delete(); | ||
|
||
return $next($state); | ||
} | ||
} |
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,17 @@ | ||
<?php | ||
|
||
namespace App\Actions\Photo\Pipes\PhotoPartner; | ||
|
||
use App\Contracts\PhotoCreate\PhotoPartnerPipe; | ||
use App\DTO\PhotoCreate\PhotoPartnerDTO; | ||
|
||
class SetOldChecksum implements PhotoPartnerPipe | ||
{ | ||
public function handle(PhotoPartnerDTO $state, \Closure $next): PhotoPartnerDTO | ||
{ | ||
// As the video is uploaded already, we must copy over the checksum | ||
$state->photo->live_photo_checksum = $state->oldVideo->checksum; | ||
|
||
return $next($state); | ||
} | ||
} |
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,19 @@ | ||
<?php | ||
|
||
namespace App\Contracts\PhotoCreate; | ||
|
||
use App\DTO\PhotoCreate\PhotoPartnerDTO; | ||
|
||
/** | ||
* Basic definition of a Photo Partner pipe. | ||
*/ | ||
interface PhotoPartnerPipe | ||
{ | ||
/** | ||
* @param PhotoPartnerDTO $state | ||
* @param \Closure(PhotoPartnerDTO $state): PhotoPartnerDTO $next | ||
* | ||
* @return PhotoPartnerDTO | ||
*/ | ||
public function handle(PhotoPartnerDTO $state, \Closure $next): PhotoPartnerDTO; | ||
} |
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,24 @@ | ||
<?php | ||
|
||
namespace App\DTO\PhotoCreate; | ||
|
||
use App\Contracts\Image\StreamStats; | ||
use App\Contracts\PhotoCreate\PhotoDTO; | ||
use App\Models\Photo; | ||
|
||
class PhotoPartnerDTO implements PhotoDTO | ||
{ | ||
public StreamStats|null $streamStat; | ||
public string $videoPath; | ||
|
||
public function __construct( | ||
public readonly Photo $photo, | ||
public readonly Photo $oldVideo, | ||
) { | ||
} | ||
|
||
public function getPhoto(): Photo | ||
{ | ||
return $this->photo; | ||
} | ||
} |