aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/installer/installer_event.rs
blob: 456a4bd272990a884314f94e49c410bc799ff352 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//! ref: composer/src/Composer/Installer/InstallerEvent.php

use crate::composer::Composer;
use crate::dependency_resolver::transaction::Transaction;
use crate::event_dispatcher::event::Event;
use crate::io::io_interface::IOInterface;

#[derive(Debug)]
pub struct InstallerEvent {
    inner: Event,
    composer: Composer,
    io: Box<dyn IOInterface>,
    dev_mode: bool,
    execute_operations: bool,
    transaction: Transaction,
}

impl InstallerEvent {
    pub fn new(
        event_name: String,
        composer: Composer,
        io: Box<dyn IOInterface>,
        dev_mode: bool,
        execute_operations: bool,
        transaction: Transaction,
    ) -> Self {
        let inner = Event::new(event_name, vec![], vec![]);
        Self {
            inner,
            composer,
            io,
            dev_mode,
            execute_operations,
            transaction,
        }
    }

    pub fn get_composer(&self) -> &Composer {
        &self.composer
    }

    pub fn get_io(&self) -> &dyn IOInterface {
        self.io.as_ref()
    }

    pub fn is_dev_mode(&self) -> bool {
        self.dev_mode
    }

    pub fn is_executing_operations(&self) -> bool {
        self.execute_operations
    }

    pub fn get_transaction(&self) -> Option<&Transaction> {
        Some(&self.transaction)
    }
}