diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-26 20:04:02 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-26 20:04:02 +0900 |
| commit | f411daceacad66e0bd774fda7d3c5ef8533cc55c (patch) | |
| tree | eefb065e4d676a3f7031ca49bab21c773b00b134 /crates/shirabe/src/plugin | |
| parent | 1921f173ea219cb4b25847294d2d3fa465550fbb (diff) | |
| download | php-shirabe-f411daceacad66e0bd774fda7d3c5ef8533cc55c.tar.gz php-shirabe-f411daceacad66e0bd774fda7d3c5ef8533cc55c.tar.zst php-shirabe-f411daceacad66e0bd774fda7d3c5ef8533cc55c.zip | |
refactor(io): share IOInterface via Rc<RefCell<dyn _>> handle
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/plugin')
| -rw-r--r-- | crates/shirabe/src/plugin/plugin_manager.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/crates/shirabe/src/plugin/plugin_manager.rs b/crates/shirabe/src/plugin/plugin_manager.rs index ddde387..a03fcaa 100644 --- a/crates/shirabe/src/plugin/plugin_manager.rs +++ b/crates/shirabe/src/plugin/plugin_manager.rs @@ -21,6 +21,7 @@ use crate::composer::{ComposerHandle, ComposerWeakHandle}; use crate::event_dispatcher::EventSubscriberInterface; use crate::installer::InstallerInterface; use crate::io::IOInterface; +use crate::io::IOInterfaceImmutable; use crate::package::CompletePackage; use crate::package::Link; use crate::package::Locker; @@ -51,7 +52,7 @@ pub enum DisablePlugins { #[derive(Debug)] pub struct PluginManager { pub(crate) composer: ComposerWeakHandle, - pub(crate) io: Box<dyn IOInterface>, + pub(crate) io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, pub(crate) global_composer: Option<PartialComposerHandle>, pub(crate) version_parser: VersionParser, pub(crate) disable_plugins: DisablePlugins, @@ -72,7 +73,7 @@ static mut CLASS_COUNTER: i64 = 0; impl PluginManager { pub fn new( - io: Box<dyn IOInterface>, + io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>, composer: ComposerWeakHandle, global_composer: Option<PartialComposerHandle>, disable_plugins: DisablePlugins, @@ -475,7 +476,7 @@ impl PluginManager { String::new() } )); - plugin.activate(&self.composer_full(), &*self.io); + plugin.activate(&self.composer_full(), &*self.io.borrow()); // TODO(plugin): if plugin is EventSubscriberInterface, hook into the event dispatcher // The PHP code calls $this->composer->getEventDispatcher()->addSubscriber($plugin); @@ -502,7 +503,7 @@ impl PluginManager { self.io .write_error(&format!("Unloading plugin {}", get_class_obj(plugin))); let mut removed = self.plugins.remove(index); - removed.deactivate(&self.composer_full(), &*self.io); + removed.deactivate(&self.composer_full(), &*self.io.borrow()); // TODO(plugin): remove_listener accepts any callable/object in PHP; here we have // a plugin instance and need to translate to a Callable, which is not portable @@ -515,7 +516,7 @@ impl PluginManager { // TODO(plugin): plugin uninstall hook self.io .write_error(&format!("Uninstalling plugin {}", get_class_obj(plugin))); - plugin.uninstall(&self.composer_full(), &*self.io); + plugin.uninstall(&self.composer_full(), &*self.io.borrow()); } fn load_repository( |
