diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-15 23:35:39 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-16 10:00:40 +0900 |
| commit | fec6939ee24cd0173e8dd545309d9adeeb32cae0 (patch) | |
| tree | 6c00b692a8125917437dd96d87a5225e70595532 /crates/shirabe/src/plugin | |
| parent | 597570ddef91aa6170b443e86ea741c67b4cb8d6 (diff) | |
| download | php-shirabe-fec6939ee24cd0173e8dd545309d9adeeb32cae0.tar.gz php-shirabe-fec6939ee24cd0173e8dd545309d9adeeb32cae0.tar.zst php-shirabe-fec6939ee24cd0173e8dd545309d9adeeb32cae0.zip | |
feat(port): port PreFileDownloadEvent.php
Diffstat (limited to 'crates/shirabe/src/plugin')
| -rw-r--r-- | crates/shirabe/src/plugin/pre_file_download_event.rs | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/crates/shirabe/src/plugin/pre_file_download_event.rs b/crates/shirabe/src/plugin/pre_file_download_event.rs index 91cd74e..0e2be7a 100644 --- a/crates/shirabe/src/plugin/pre_file_download_event.rs +++ b/crates/shirabe/src/plugin/pre_file_download_event.rs @@ -1 +1,74 @@ //! ref: composer/src/Composer/Plugin/PreFileDownloadEvent.php + +use indexmap::IndexMap; +use shirabe_php_shim::PhpMixed; + +use crate::event_dispatcher::event::Event; +use crate::util::http_downloader::HttpDownloader; + +#[derive(Debug)] +pub struct PreFileDownloadEvent { + inner: Event, + http_downloader: HttpDownloader, + processed_url: String, + custom_cache_key: Option<String>, + r#type: String, + context: PhpMixed, + transport_options: IndexMap<String, Box<PhpMixed>>, +} + +impl PreFileDownloadEvent { + pub fn new( + name: String, + http_downloader: HttpDownloader, + processed_url: String, + r#type: String, + context: PhpMixed, + ) -> Self { + Self { + inner: Event::new(name, vec![], IndexMap::new()), + http_downloader, + processed_url, + custom_cache_key: None, + r#type, + context, + transport_options: IndexMap::new(), + } + } + + pub fn get_http_downloader(&self) -> &HttpDownloader { + &self.http_downloader + } + + pub fn get_processed_url(&self) -> &str { + &self.processed_url + } + + pub fn set_processed_url(&mut self, processed_url: String) { + self.processed_url = processed_url; + } + + pub fn get_custom_cache_key(&self) -> Option<&str> { + self.custom_cache_key.as_deref() + } + + pub fn set_custom_cache_key(&mut self, custom_cache_key: Option<String>) { + self.custom_cache_key = custom_cache_key; + } + + pub fn get_type(&self) -> &str { + &self.r#type + } + + pub fn get_context(&self) -> &PhpMixed { + &self.context + } + + pub fn get_transport_options(&self) -> &IndexMap<String, Box<PhpMixed>> { + &self.transport_options + } + + pub fn set_transport_options(&mut self, options: IndexMap<String, Box<PhpMixed>>) { + self.transport_options = options; + } +} |
