Skip to content

Commit

Permalink
[stacked 2] Move Import & Parameters DTO (LycheeOrg#2365)
Browse files Browse the repository at this point in the history
  • Loading branch information
ildyria committed Apr 11, 2024
1 parent a887a5f commit e7b45ac
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 23 deletions.
2 changes: 1 addition & 1 deletion app/Actions/Import/Exec.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use App\Actions\Album\Create as AlbumCreate;
use App\Actions\Photo\Create as PhotoCreate;
use App\Actions\Photo\Strategies\ImportMode;
use App\DTO\BaseImportReport;
use App\DTO\ImportEventReport;
use App\DTO\ImportMode;
use App\DTO\ImportProgressReport;
use App\Exceptions\FileOperationException;
use App\Exceptions\Handler;
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Import/FromServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Actions\Import;

use App\Actions\Photo\Strategies\ImportMode;
use App\DTO\ImportMode;
use App\Models\Album;
use function Safe\ini_get;
use Symfony\Component\HttpFoundation\StreamedResponse;
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Import/FromUrl.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace App\Actions\Import;

use App\Actions\Photo\Create;
use App\Actions\Photo\Strategies\ImportMode;
use App\DTO\ImportMode;
use App\Exceptions\Handler;
use App\Exceptions\MassImportException;
use App\Image\Files\BaseMediaFile;
Expand Down
12 changes: 6 additions & 6 deletions app/Actions/Photo/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
use App\Actions\Photo\Strategies\AddDuplicateStrategy;
use App\Actions\Photo\Strategies\AddPhotoPartnerStrategy;
use App\Actions\Photo\Strategies\AddStandaloneStrategy;
use App\Actions\Photo\Strategies\AddStrategyParameters;
use App\Actions\Photo\Strategies\AddVideoPartnerStrategy;
use App\Actions\Photo\Strategies\ImportMode;
use App\Actions\User\Notify;
use App\Contracts\Exceptions\LycheeException;
use App\Contracts\Models\AbstractAlbum;
use App\DTO\ImportMode;
use App\DTO\ImportParam;
use App\Exceptions\ExternalComponentFailedException;
use App\Exceptions\ExternalComponentMissingException;
use App\Exceptions\Internal\IllegalOrderOfOperationException;
Expand All @@ -31,12 +31,12 @@

class Create
{
/** @var AddStrategyParameters the strategy parameters prepared and compiled by this class */
protected AddStrategyParameters $strategyParameters;
/** @var ImportParam the strategy parameters prepared and compiled by this class */
protected ImportParam $strategyParameters;

public function __construct(?ImportMode $importMode, int $intendedOwnerId)
{
$this->strategyParameters = new AddStrategyParameters($importMode, $intendedOwnerId);
$this->strategyParameters = new ImportParam($importMode, $intendedOwnerId);
}

/**
Expand Down Expand Up @@ -116,7 +116,7 @@ public function add(NativeLocalFile $sourceFile, ?AbstractAlbum $album, ?int $fi

/**
* Extracts the meta-data of the source file and initializes
* {@link AddStrategyParameters::$exifInfo} of {@link Create::$strategyParameters}.
* {@link ImportParam::$exifInfo} of {@link Create::$strategyParameters}.
*
* @param NativeLocalFile $sourceFile the source file
* @param int $fileLastModifiedTime the timestamp to use if there's no creation date in Exif
Expand Down
7 changes: 4 additions & 3 deletions app/Actions/Photo/Strategies/AbstractAddStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Actions\Photo\Strategies;

use App\DTO\ImportParam;
use App\Exceptions\MediaFileOperationException;
use App\Exceptions\ModelDBException;
use App\Exceptions\UnauthenticatedException;
Expand All @@ -10,7 +11,7 @@
abstract class AbstractAddStrategy
{
protected function __construct(
protected AddStrategyParameters $parameters,
protected ImportParam $parameters,
protected Photo $photo
) {
}
Expand All @@ -25,8 +26,8 @@ abstract public function do(): Photo;

/**
* Hydrates meta-info of the media file from the
* {@link AddStrategyParameters::$exifInfo} attribute of the associated
* {@link AddStrategyParameters} object into the associated {@link Photo}
* {@link ImportParam::$exifInfo} attribute of the associated
* {@link ImportParam} object into the associated {@link Photo}
* object.
*
* Meta information is conditionally copied if and only if the target
Expand Down
3 changes: 2 additions & 1 deletion app/Actions/Photo/Strategies/AddDuplicateStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Actions\Photo\Strategies;

use App\DTO\ImportParam;
use App\Exceptions\ModelDBException;
use App\Exceptions\PhotoResyncedException;
use App\Exceptions\PhotoSkippedException;
Expand All @@ -11,7 +12,7 @@

class AddDuplicateStrategy extends AbstractAddStrategy
{
public function __construct(AddStrategyParameters $parameters, Photo $existing)
public function __construct(ImportParam $parameters, Photo $existing)
{
parent::__construct($parameters, $existing);
}
Expand Down
6 changes: 4 additions & 2 deletions app/Actions/Photo/Strategies/AddPhotoPartnerStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace App\Actions\Photo\Strategies;

use App\Contracts\Exceptions\LycheeException;
use App\DTO\ImportMode;
use App\DTO\ImportParam;
use App\Image\Files\NativeLocalFile;
use App\Models\Photo;

Expand All @@ -21,7 +23,7 @@ class AddPhotoPartnerStrategy extends AddStandaloneStrategy
{
protected Photo $existingVideo;

public function __construct(AddStrategyParameters $parameters, NativeLocalFile $photoSourceFile, Photo $existingVideo)
public function __construct(ImportParam $parameters, NativeLocalFile $photoSourceFile, Photo $existingVideo)
{
parent::__construct($parameters, $photoSourceFile);
$this->existingVideo = $existingVideo;
Expand All @@ -46,7 +48,7 @@ public function do(): Photo
// "steals away" the stored video file from the existing video entity
// and moves it to the correct destination of a live partner for the
// photo.
$parameters = new AddStrategyParameters(
$parameters = new ImportParam(
new ImportMode(deleteImported: true),
$this->parameters->intendedOwnerId
);
Expand Down
3 changes: 2 additions & 1 deletion app/Actions/Photo/Strategies/AddStandaloneStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use App\Contracts\Models\AbstractSizeVariantNamingStrategy;
use App\Contracts\Models\SizeVariantFactory;
use App\DTO\ImageDimension;
use App\DTO\ImportParam;
use App\Enum\SizeVariantType;
use App\Exceptions\ConfigurationException;
use App\Exceptions\Handler;
Expand All @@ -34,7 +35,7 @@ class AddStandaloneStrategy extends AbstractAddStrategy
/**
* @throws FrameworkException
*/
public function __construct(AddStrategyParameters $parameters, NativeLocalFile $sourceFile)
public function __construct(ImportParam $parameters, NativeLocalFile $sourceFile)
{
try {
parent::__construct($parameters, new Photo());
Expand Down
3 changes: 2 additions & 1 deletion app/Actions/Photo/Strategies/AddVideoPartnerStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Actions\Diagnostics\Pipes\Checks\BasicPermissionCheck;
use App\Contracts\Models\AbstractSizeVariantNamingStrategy;
use App\DTO\ImportParam;
use App\Exceptions\ConfigurationException;
use App\Exceptions\Handler;
use App\Exceptions\Internal\LycheeAssertionError;
Expand All @@ -28,7 +29,7 @@ class AddVideoPartnerStrategy extends AbstractAddStrategy
{
protected BaseMediaFile $videoSourceFile;

public function __construct(AddStrategyParameters $parameters, BaseMediaFile $videoSourceFile, Photo $existingPhoto)
public function __construct(ImportParam $parameters, BaseMediaFile $videoSourceFile, Photo $existingPhoto)
{
parent::__construct($parameters, $existingPhoto);
$this->videoSourceFile = $videoSourceFile;
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Commands/Sync.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace App\Console\Commands;

use App\Actions\Import\Exec;
use App\Actions\Photo\Strategies\ImportMode;
use App\Contracts\Exceptions\ExternalLycheeException;
use App\DTO\ImportMode;
use App\Exceptions\ConfigurationKeyMissingException;
use App\Exceptions\UnexpectedException;
use App\Models\Album;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace App\Actions\Photo\Strategies;
namespace App\DTO;

/**
* Define import mode.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace App\Actions\Photo\Strategies;
namespace App\DTO;

use App\Metadata\Extractor;
use App\Models\Album;

class AddStrategyParameters
final class ImportParam
{
public ImportMode $importMode;

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Requests/Import/ImportServerRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace App\Http\Requests\Import;

use App\Actions\Photo\Strategies\ImportMode;
use App\Contracts\Http\Requests\HasAlbum;
use App\Contracts\Http\Requests\RequestAttribute;
use App\Contracts\Models\AbstractAlbum;
use App\DTO\ImportMode;
use App\Http\Requests\BaseApiRequest;
use App\Http\Requests\Traits\HasAlbumTrait;
use App\Http\RuleSets\Import\ImportServerRuleSet;
Expand Down
2 changes: 1 addition & 1 deletion app/Jobs/ProcessImageJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace App\Jobs;

use App\Actions\Photo\Create;
use App\Actions\Photo\Strategies\ImportMode;
use App\Contracts\Models\AbstractAlbum;
use App\DTO\ImportMode;
use App\Enum\JobStatus;
use App\Factories\AlbumFactory;
use App\Image\Files\ProcessableJobFile;
Expand Down

0 comments on commit e7b45ac

Please sign in to comment.