2022-10-25 06:53:10 -04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
/**
|
2024-05-23 03:26:56 -04:00
|
|
|
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2022-10-25 06:53:10 -04:00
|
|
|
*/
|
|
|
|
|
namespace OCP\Preview;
|
|
|
|
|
|
|
|
|
|
use OCP\Files\Node;
|
2023-06-06 17:12:40 -04:00
|
|
|
use OCP\IPreview;
|
2022-10-25 06:53:10 -04:00
|
|
|
|
|
|
|
|
/**
|
2024-07-23 12:49:26 -04:00
|
|
|
* Emitted before a file preview is being fetched.
|
|
|
|
|
*
|
|
|
|
|
* It can be used to block preview rendering by throwing a ``OCP\Files\NotFoundException``
|
|
|
|
|
*
|
2022-10-25 06:53:10 -04:00
|
|
|
* @since 25.0.1
|
2024-07-23 12:49:26 -04:00
|
|
|
* @since 28.0.0 the constructor arguments ``$width``, ``$height``, ``$crop`` and ``$mode`` are no longer nullable.
|
2023-03-13 04:58:31 -04:00
|
|
|
* @since 31.0.0 the constructor arguments ``$mimeType`` was added
|
2022-10-25 06:53:10 -04:00
|
|
|
*/
|
|
|
|
|
class BeforePreviewFetchedEvent extends \OCP\EventDispatcher\Event {
|
|
|
|
|
/**
|
|
|
|
|
* @since 25.0.1
|
|
|
|
|
*/
|
2023-06-06 17:12:40 -04:00
|
|
|
public function __construct(
|
|
|
|
|
private Node $node,
|
2023-03-13 04:58:31 -04:00
|
|
|
/** @deprecated 28.0.0 passing null is deprecated **/
|
2023-06-06 17:12:40 -04:00
|
|
|
private ?int $width = null,
|
2024-09-13 10:01:55 -04:00
|
|
|
/** @deprecated 28.0.0 passing null is deprecated **/
|
2023-06-06 17:12:40 -04:00
|
|
|
private ?int $height = null,
|
2024-09-13 10:01:55 -04:00
|
|
|
/** @deprecated 28.0.0 passing null is deprecated **/
|
2023-06-06 17:12:40 -04:00
|
|
|
private ?bool $crop = null,
|
2024-09-13 10:01:55 -04:00
|
|
|
/** @deprecated 28.0.0 passing null is deprecated **/
|
2023-06-06 17:12:40 -04:00
|
|
|
private ?string $mode = null,
|
2023-03-13 04:58:31 -04:00
|
|
|
private ?string $mimeType = null,
|
2023-06-06 17:12:40 -04:00
|
|
|
) {
|
2022-10-25 06:53:10 -04:00
|
|
|
parent::__construct();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @since 25.0.1
|
|
|
|
|
*/
|
|
|
|
|
public function getNode(): Node {
|
|
|
|
|
return $this->node;
|
|
|
|
|
}
|
2023-06-06 17:12:40 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @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;
|
|
|
|
|
}
|
2023-03-13 04:58:31 -04:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @since 31.0.0
|
|
|
|
|
*/
|
|
|
|
|
public function getMimeType(): ?string {
|
|
|
|
|
return $this->mimeType;
|
|
|
|
|
}
|
2022-10-25 06:53:10 -04:00
|
|
|
}
|