_emailKey = array_shift($this->argv); $this->_locales = array_shift($this->argv); if ($this->_emailKey === null) { $this->usage(); exit; } } /** * Print command usage information. */ public function usage() { echo "Command-line tool for installing email templates.\n" . "Usage:\n" . "\t{$this->scriptName} emailKey aa_BB[,cc_DD,...] [path/to/emails.po]\n" . "\t\temailKey: The email key of the email to install, e.g. ANNOUNCEMENT\n" . "\t\taa_BB[,cc_DD,...]: The optional comma-separated list of locales to install. If none provided will be determined by site's installed locales\n"; } /** * Execute upgrade task */ public function execute() { // Load the necessary locale data $locales = explode(',', $this->_locales ?? ''); // Install to the database Repo::emailTemplate()->dao->installEmailTemplates( Repo::emailTemplate()->dao->getMainEmailTemplatesFilename(), $locales, $this->_emailKey ); } } $tool = new installEmailTemplates($argv ?? []); $tool->execute();