Esempio n. 1
0
 public function testHelpers()
 {
     Config::set('repository.url', 'https://github.com/doubleleft/hook');
     Config::set('repository.author', 'doubleleft');
     $string = Module::template("{{ config 'repository.url' }} by {{config 'repository.author'}}.")->compile();
     $this->assertTrue($string == "https://github.com/doubleleft/hook by doubleleft.");
     $string = Module::template("{{ public_url }}")->compile();
     $this->assertTrue($string == "http://localhost/");
 }
Esempio n. 2
0
 /**
  * Create a new Message.
  *
  * @param string $template_body path or data to be attached
  * @param string $options
  *
  * @return Swift_Mime_Attachment
  */
 public static function message($template_body = null, $options = array())
 {
     $message = new Message();
     MailHelper::setMessage($message);
     if ($template_body) {
         $template = Module::template($template_body);
         $message->body($template->compile($options));
     }
     return $message;
 }
Esempio n. 3
0
 protected function getTemplate($name)
 {
     if (is_null($this->template_string)) {
         $this->setTemplateString(Module::template($name)->getCode());
     }
     return $this->template_string;
     // foreach ($this->directories as $dir) {
     //     foreach ($this->extensions as $ext) {
     //         $path = $dir . DIRECTORY_SEPARATOR . ltrim($name . $ext, DIRECTORY_SEPARATOR);
     //         if (file_exists($path)) {
     //             return file_get_contents($path);
     //         }
     //     }
     // }
     // throw new NotFoundException("Template not found.");
 }
Esempio n. 4
0
 /**
  * Trigger 'forgot password' email
  */
 public function forgotPassword()
 {
     $data = $this->getData();
     $auth = Auth::where('email', $data['email'])->first();
     if (!$auth) {
         throw new Exceptions\NotFoundException("invalid_user");
     }
     if (!isset($data['subject'])) {
         $data['subject'] = 'Forgot your password?';
     }
     $body_data = Context::unsafe(function () use(&$auth) {
         $array = $auth->generateForgotPasswordToken()->toArray();
         $array['token'] = $auth->getAttribute(Auth::FORGOT_PASSWORD_FIELD);
         return $array;
     });
     $template = isset($data['template']) ? $data['template'] : self::TEMPLATE_FORGOT_PASSWORD;
     return array('success' => Mail::send(array('subject' => $data['subject'], 'from' => Config::get('mail.from', '*****@*****.**'), 'to' => $auth->email, 'body' => Module::template($template)->compile($body_data))) === 1);
 }