assistant.php
1 year ago
assistfeedback.php
1 year ago
base.php
1 year ago
droppedfile.php
1 year ago
editimage.php
1 year ago
embed.php
1 year ago
feedback.php
1 year ago
function.php
1 year ago
image.php
1 year ago
parameter.php
1 year ago
text.php
1 year ago
transcribe.php
1 year ago
editimage.php
36 lines
| 1 | <?php |
| 2 | |
| 3 | class Meow_MWAI_Query_EditImage extends Meow_MWAI_Query_Image { |
| 4 | public ?Meow_MWAI_Query_DroppedFile $attachedFile = null; |
| 5 | public ?int $mediaId = null; |
| 6 | |
| 7 | public function set_file( Meow_MWAI_Query_DroppedFile $file ): void { |
| 8 | $this->attachedFile = $file; |
| 9 | } |
| 10 | |
| 11 | public function set_media_id( int $mediaId ) { |
| 12 | $this->mediaId = $mediaId; |
| 13 | } |
| 14 | |
| 15 | #[\ReturnTypeWillChange] |
| 16 | public function jsonSerialize(): array { |
| 17 | $json = parent::jsonSerialize(); |
| 18 | if ( !empty( $this->mediaId ) ) { |
| 19 | $json['mediaId'] = $this->mediaId; |
| 20 | } |
| 21 | return $json; |
| 22 | } |
| 23 | |
| 24 | public function inject_params( array $params ): void { |
| 25 | parent::inject_params( $params ); |
| 26 | $params = $this->convert_keys( $params ); |
| 27 | if ( !empty( $params['mediaId'] ) ) { |
| 28 | $this->set_media_id( intval( $params['mediaId'] ) ); |
| 29 | $path = get_attached_file( $this->mediaId ); |
| 30 | if ( $path ) { |
| 31 | $this->set_file( Meow_MWAI_Query_DroppedFile::from_path( $path, 'vision' ) ); |
| 32 | } |
| 33 | } |
| 34 | } |
| 35 | } |
| 36 |