diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-22 01:29:48 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-22 01:43:48 +0900 |
| commit | 0b06f54103490e3ce5658e82bbc0119633e26cd8 (patch) | |
| tree | 687b075131d3679725e77e0931ff7c503a6c3034 /crates/shirabe/src/installer/plugin_installer.rs | |
| parent | 2914770fba6b3cc03a68fae493f60470a41962ec (diff) | |
| download | php-shirabe-0b06f54103490e3ce5658e82bbc0119633e26cd8.tar.gz php-shirabe-0b06f54103490e3ce5658e82bbc0119633e26cd8.tar.zst php-shirabe-0b06f54103490e3ce5658e82bbc0119633e26cd8.zip | |
refactor(composer): unify Composer/PartialComposer via Rc handles
Model PHP's `Composer extends PartialComposer` as a PartialOrFullComposer
enum and merge partial_composer.rs into composer.rs. Introduce
ComposerHandle / PartialComposerHandle (plus their Weak variants) so the
graph can be shared, and build it at once with Rc::new_cyclic in the
factory to resolve the back-reference cycles.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/installer/plugin_installer.rs')
| -rw-r--r-- | crates/shirabe/src/installer/plugin_installer.rs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/crates/shirabe/src/installer/plugin_installer.rs b/crates/shirabe/src/installer/plugin_installer.rs index dff57d8..e1d4c5e 100644 --- a/crates/shirabe/src/installer/plugin_installer.rs +++ b/crates/shirabe/src/installer/plugin_installer.rs @@ -1,11 +1,11 @@ //! ref: composer/src/Composer/Installer/PluginInstaller.php +use crate::composer::PartialComposerWeakHandle; use crate::installer::BinaryInstaller; use crate::installer::InstallerInterface; use crate::installer::LibraryInstaller; use crate::io::IOInterface; use crate::package::PackageInterface; -use crate::partial_composer::PartialComposer; use crate::plugin::PluginManager; use crate::repository::InstalledRepositoryInterface; use crate::util::Filesystem; @@ -22,7 +22,7 @@ pub struct PluginInstaller { impl PluginInstaller { pub fn new( io: Box<dyn IOInterface>, - composer: PartialComposer, + composer: PartialComposerWeakHandle, fs: Option<std::rc::Rc<std::cell::RefCell<Filesystem>>>, binary_installer: Option<BinaryInstaller>, ) -> Self { @@ -39,7 +39,7 @@ impl PluginInstaller { pub fn disable_plugins(&mut self) { // TODO(plugin): disable plugins via plugin manager - self.get_plugin_manager_mut().disable_plugins(); + self.get_plugin_manager().borrow_mut().disable_plugins(); } fn rollback_install( @@ -56,15 +56,10 @@ impl PluginInstaller { Err(e) } - fn get_plugin_manager(&self) -> &PluginManager { + fn get_plugin_manager(&self) -> std::rc::Rc<std::cell::RefCell<PluginManager>> { // TODO(plugin): PartialComposer does not expose PluginManager; revisit when wiring plugin support todo!("PartialComposer.get_plugin_manager") } - - fn get_plugin_manager_mut(&mut self) -> &mut PluginManager { - // TODO(plugin): return mutable plugin manager from composer - todo!() - } } impl InstallerInterface for PluginInstaller { @@ -87,7 +82,10 @@ impl InstallerInterface for PluginInstaller { prev_package: Option<&dyn PackageInterface>, ) -> Result<Option<Box<dyn PromiseInterface>>> { if (r#type == "install" || r#type == "update") - && !self.get_plugin_manager().are_plugins_disabled("local") + && !self + .get_plugin_manager() + .borrow() + .are_plugins_disabled("local") { let plugin_optional = package .get_extra() @@ -176,7 +174,9 @@ impl InstallerInterface for PluginInstaller { package: &dyn PackageInterface, ) -> Result<Option<Box<dyn PromiseInterface>>> { // TODO(plugin): uninstall package from plugin manager - self.get_plugin_manager_mut().uninstall_package(package); + self.get_plugin_manager() + .borrow_mut() + .uninstall_package(package); self.inner.uninstall(repo, package) } |
