Skip to content

Commit

Permalink
[stacked 3] Move RotateStrategy to Rotate action (LycheeOrg#2366)
Browse files Browse the repository at this point in the history
  • Loading branch information
ildyria committed Apr 11, 2024
1 parent e7b45ac commit 61c42e8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

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

use App\Contracts\Exceptions\LycheeException;
use App\Contracts\Models\AbstractSizeVariantNamingStrategy;
Expand All @@ -21,7 +21,7 @@
use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Support\Collection;

class RotateStrategy
class Rotate
{
protected Photo $photo;
/** @var int either `1` for counterclockwise or `-1` for clockwise rotation */
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/PhotoEditorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Http\Controllers;

use App\Actions\Photo\Strategies\RotateStrategy;
use App\Actions\Photo\Rotate;
use App\Contracts\Exceptions\LycheeException;
use App\Exceptions\ConfigurationException;
use App\Http\Requests\Photo\RotatePhotoRequest;
Expand All @@ -27,7 +27,7 @@ public function rotate(RotatePhotoRequest $request): PhotoResource
throw new ConfigurationException('support for rotation disabled by configuration');
}

$rotateStrategy = new RotateStrategy($request->photo(), $request->direction());
$rotateStrategy = new Rotate($request->photo(), $request->direction());
$photo = $rotateStrategy->do();

return PhotoResource::make($photo);
Expand Down
10 changes: 5 additions & 5 deletions app/Livewire/Traits/UsePhotoViewActions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace App\Livewire\Traits;

use App\Actions\Photo\Strategies\RotateStrategy;
use App\Actions\Photo\Rotate;
use App\Enum\Livewire\NotificationType;
use App\Http\Resources\Models\PhotoResource;
use App\Livewire\Forms\PhotoUpdateForm;
Expand Down Expand Up @@ -88,8 +88,8 @@ public function rotate_ccw(string $photoID): void

$photo = Photo::query()->findOrFail($photoID);
Gate::authorize(PhotoPolicy::CAN_EDIT, [Photo::class, $photo]);
$rotateStrategy = new RotateStrategy($photo, -1);
$photo = $rotateStrategy->do();
$rotate = new Rotate($photo, -1);
$photo = $rotate->do();
// Force hard refresh of the page (to load the rotated image)
$this->redirect(route('livewire-gallery-photo', ['albumId' => $this->albumId, 'photoId' => $photo->id]));
}
Expand All @@ -109,8 +109,8 @@ public function rotate_cw(string $photoID): void

$photo = Photo::query()->findOrFail($photoID);
Gate::authorize(PhotoPolicy::CAN_EDIT, [Photo::class, $photo]);
$rotateStrategy = new RotateStrategy($photo, 1);
$photo = $rotateStrategy->do();
$rotate = new Rotate($photo, 1);
$photo = $rotate->do();
// Force hard refresh of the page (to load the rotated image)
$this->redirect(route('livewire-gallery-photo', ['albumId' => $this->albumId, 'photoId' => $photo->id]));
}
Expand Down

0 comments on commit 61c42e8

Please sign in to comment.