Added force flag to image deletion event to override trash extension
This commit is contained in:
parent
1bd9238b17
commit
a82fb56063
@ -42,15 +42,19 @@ class ImageDeletionEvent extends Event
|
|||||||
/** @var Image */
|
/** @var Image */
|
||||||
public $image;
|
public $image;
|
||||||
|
|
||||||
|
/** @var bool */
|
||||||
|
public $force = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes an image.
|
* Deletes an image.
|
||||||
*
|
*
|
||||||
* Used by things like tags and comments handlers to
|
* Used by things like tags and comments handlers to
|
||||||
* clean out related rows in their tables.
|
* clean out related rows in their tables.
|
||||||
*/
|
*/
|
||||||
public function __construct(Image $image)
|
public function __construct(Image $image, bool $force = false)
|
||||||
{
|
{
|
||||||
$this->image = $image;
|
$this->image = $image;
|
||||||
|
$this->force = $force;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ class Trash extends Extension
|
|||||||
|
|
||||||
public function onImageDeletion(ImageDeletionEvent $event)
|
public function onImageDeletion(ImageDeletionEvent $event)
|
||||||
{
|
{
|
||||||
if($event->image->trash===false) {
|
if($event->force===false && $event->image->trash===false) {
|
||||||
self::set_trash($event->image->id, true);
|
self::set_trash($event->image->id, true);
|
||||||
$event->stop_processing = true;
|
$event->stop_processing = true;
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ abstract class ShimmiePHPUnitTestCase extends \PHPUnit\Framework\TestCase
|
|||||||
{
|
{
|
||||||
$img = Image::by_id($image_id);
|
$img = Image::by_id($image_id);
|
||||||
if ($img) {
|
if ($img) {
|
||||||
$ide = new ImageDeletionEvent($img);
|
$ide = new ImageDeletionEvent($img, true);
|
||||||
send_event($ide);
|
send_event($ide);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user