namespace OCP\Preview;
use OCP\Files\Node;
+use OCP\IPreview;
/**
* @since 25.0.1
*/
class BeforePreviewFetchedEvent extends \OCP\EventDispatcher\Event {
- private Node $node;
-
/**
* @since 25.0.1
*/
- public function __construct(Node $node) {
+ public function __construct(
+ private Node $node,
+ /** @deprecated 28.0.0 null deprecated **/
+ private ?int $width = null,
+ /** @deprecated 28.0.0 null deprecated **/
+ private ?int $height = null,
+ /** @deprecated 28.0.0 null deprecated **/
+ private ?bool $crop = null,
+ /** @deprecated 28.0.0 null deprecated **/
+ private ?string $mode = null,
+ ) {
parent::__construct();
- $this->node = $node;
}
/**
public function getNode(): Node {
return $this->node;
}
+
+ /**
+ * @since 28.0.0
+ */
+ public function getWidth(): ?int {
+ return $this->width;
+ }
+
+ /**
+ * @since 28.0.0
+ */
+ public function getHeight(): ?int {
+ return $this->height;
+ }
+
+ /**
+ * @since 28.0.0
+ */
+ public function isCrop(): ?bool {
+ return $this->crop;
+ }
+
+ /**
+ * @since 28.0.0
+ * @return null|IPreview::MODE_FILL|IPreview::MODE_COVER
+ */
+ public function getMode(): ?string {
+ return $this->mode;
+ }
}
$this->eventDispatcher->expects($this->once())
->method('dispatchTyped')
- ->with(new BeforePreviewFetchedEvent($file));
+ ->with(new BeforePreviewFetchedEvent($file, 100, 100, false, IPreview::MODE_FILL));
$result = $this->generator->getPreview($file, 100, 100);
$this->assertSame($previewFile, $result);
$this->eventDispatcher->expects($this->once())
->method('dispatchTyped')
- ->with(new BeforePreviewFetchedEvent($file));
+ ->with(new BeforePreviewFetchedEvent($file, 100, 100, false, IPreview::MODE_FILL));
$result = $this->generator->getPreview($file, 100, 100);
$this->assertSame($previewFile, $result);
$this->eventDispatcher->expects($this->once())
->method('dispatchTyped')
- ->with(new BeforePreviewFetchedEvent($file));
+ ->with(new BeforePreviewFetchedEvent($file, 1024, 512, true, IPreview::MODE_COVER));
$this->generator->getPreview($file, 1024, 512, true, IPreview::MODE_COVER, 'invalidType');
}
$this->eventDispatcher->expects($this->once())
->method('dispatchTyped')
- ->with(new BeforePreviewFetchedEvent($file));
+ ->with(new BeforePreviewFetchedEvent($file, 1024, 512, true, IPreview::MODE_COVER));
$result = $this->generator->getPreview($file, 1024, 512, true, IPreview::MODE_COVER, 'invalidType');
$this->assertSame($preview, $result);
$this->eventDispatcher->expects($this->once())
->method('dispatchTyped')
- ->with(new BeforePreviewFetchedEvent($file));
+ ->with(new BeforePreviewFetchedEvent($file, 100, 100, false, IPreview::MODE_FILL));
$this->expectException(NotFoundException::class);
$this->generator->getPreview($file, 100, 100);
$this->eventDispatcher->expects($this->once())
->method('dispatchTyped')
- ->with(new BeforePreviewFetchedEvent($file));
+ ->with(new BeforePreviewFetchedEvent($file, $reqX, $reqY, $crop, $mode));
$result = $this->generator->getPreview($file, $reqX, $reqY, $crop, $mode);
if ($expectedX === $maxX && $expectedY === $maxY) {