/** * Create plugin config file. * * @param string $toFile */ public function createConfigFile($toFile) { if (file_exists($toFile)) { $this->getOutput()->debug('Config file already exists in plugin, skipping creation of config file.'); return; } if (!$this->configDumper->hasConfig()) { $this->getOutput()->debug('No config to write out, skipping creation of config file.'); return; } $this->configDumper->dump($toFile); $this->getOutput()->debug('Created config file at ' . $toFile); }
/** * Create a new installer factory from input options. * * @param InputInterface $input * * @return InstallerFactory */ public function initializeInstallerFactory(InputInterface $input) { $validate = new Validate(); $resolver = new DatabaseResolver(); $pluginDir = realpath($validate->directory($input->getOption('plugin'))); $pluginsDir = $input->getOption('extra-plugins'); if (!empty($pluginsDir)) { $pluginsDir = realpath($validate->directory($pluginsDir)); } $dumper = new ConfigDumper(); $dumper->addSection('filter', 'notPaths', $this->csvToArray($input->getOption('not-paths'))); $dumper->addSection('filter', 'notNames', $this->csvToArray($input->getOption('not-names'))); $factory = new InstallerFactory(); $factory->moodle = new Moodle($input->getOption('moodle')); $factory->plugin = new MoodlePlugin($pluginDir); $factory->execute = $this->execute; $factory->branch = $validate->moodleBranch($input->getOption('branch')); $factory->dataDir = $input->getOption('data'); $factory->dumper = $dumper; $factory->pluginsDir = $pluginsDir; $factory->database = $resolver->resolveDatabase($input->getOption('db-type'), $input->getOption('db-name'), $input->getOption('db-user'), $input->getOption('db-pass'), $input->getOption('db-host')); return $factory; }