/** * Initializes and return an instance of the given class name. * * @access public * @param string $className * @return mixed */ public function getInstance($className) { switch ($className) { case '\\Zepi\\Core\\Utils\\Manager\\ConfigurationManager': if ($this->configurationManager === null) { $path = $this->framework->getRootDirectory() . '/config/framework.json'; $configFileBackend = new \Zepi\Core\Utils\Backend\ConfigurationFileBackend($path); $this->configurationManager = $this->framework->initiateObject($className, array('configurationFileBackend' => $configFileBackend)); $this->configurationManager->loadConfigurationFile(); } return $this->configurationManager; break; default: return $this->framework->initiateObject($className); break; } }
/** * Configures one setting * * @access protected * @param string $path * @param string $value */ protected function configureSetting($path, $value) { $newValue = $this->cliHelper->inputText('Please enter the value for "' . $path . '":', $value); if ($newValue === $value) { return; } $this->configurationManager->setSetting($path, $newValue); }
/** * Sends a email * * @access public * @param string $recipient * @param string $subject * @param string $htmlBody * @param string $textBody * @return number */ public function sendMail($recipient, $subject, $htmlBody, $textBody = false) { $message = \Swift_Message::newInstance(); // Subject $message->setSubject($subject); // From $fromEmail = $this->configurationManager->getSetting('mailer.sendFrom'); $fromName = $this->configurationManager->getSetting('mailer.sendFromName'); $message->setFrom(array($fromEmail => $fromName)); // To $message->setTo($recipient); // HTML body $message->setBody($htmlBody, 'text/html'); // Text body if ($textBody === false) { $textBody = $this->createTextBody($htmlBody); } $message->addPart($textBody, 'text/plain'); $mailer = $this->getMailer(); return $mailer->send($message); }
/** * Returns the setting for the given group and key * * @access public * @param string $path * @return mixed */ public function getSetting($path) { return $this->configurationManager->getSetting($path); }