コード例 #1
0
 public function render($name = null, $data = array(), $status = null)
 {
     $contentView = new \Slim\View();
     $data = array_merge($data, (array) $this->templateData);
     if (isset($this->environment['slim.flash'])) {
         $contentView->setData('flash', $this->environment['slim.flash']);
         $this->templateData->flash = $this->environment['slim.flash'];
     }
     $contentView->setTemplatesDirectory($this->appRoot() . '/views');
     $contentView->appendData((array) $this->templateData);
     $contentView->appendData($data);
     if ($name !== null) {
         $this->templateData->content = $contentView->fetch(rtrim($name, '.php') . '.php');
     } else {
         $this->templateData->content = '';
     }
     // Call before render
     if (method_exists($this, 'beforeRender') && !$this->beforeRenderCalled) {
         $this->beforeRender();
     }
     parent::render('template-' . rtrim($this->template, '.php') . '.php', (array) $this->templateData, $status);
 }
コード例 #2
0
ファイル: ViewTest.php プロジェクト: WTer/NJB
 public function testAppendDataInvalidArgument()
 {
     $this->setExpectedException('InvalidArgumentException');
     $view = new \Slim\View();
     $view->appendData('foo');
 }
コード例 #3
0
ファイル: Mail.php プロジェクト: sujata-patne/icon_api
 public static function send_mail($msg, $data = array())
 {
     global $config, $app;
     $app = \Slim\Slim::getInstance();
     $mode = $app->getMode();
     $mandrill = new Mandrill($config[$mode]['mandrill_apikey']);
     if (!is_array($msg)) {
         parse_str($msg, $msg);
     }
     foreach (array('text', 'html') as $t) {
         if (!empty($msg[$t]) && strpos(trim($msg[$t]), 'slim:') === 0) {
             $view = new \Slim\View();
             $view->appendData($data);
             $view->setTemplatesDirectory($app->config('templates.path'));
             $msg[$t] = $view->fetch('email/' . substr(trim($msg[$t]), 5));
         }
     }
     //        if (isset($msg['from'])) {
     //            $msg['from_email'] = $msg['from'];
     //            unset($msg['from']);
     //        }
     if (!is_array($msg['to'])) {
         $msg['to'] = array(array('email' => $msg['to']));
     }
     return $mandrill->call('/messages/send', array('message' => $msg));
 }
コード例 #4
-1
ファイル: mail.php プロジェクト: 2bj/slim-common
 function send($msg = '', $data = array())
 {
     global $app;
     $mandrill = new Mandrill(config('mandrill.apikey'));
     if (!is_array($msg)) {
         parse_str($msg, $msg);
     }
     foreach (array('text', 'html') as $t) {
         if (!empty($msg[$t]) && strpos(trim($msg[$t]), 'slim:') === 0) {
             $view = new \Slim\View();
             $view->appendData($data);
             $view->setTemplatesDirectory($app->config('templates.path'));
             $msg[$t] = $view->fetch('email/' . substr(trim($msg[$t]), 5));
         }
     }
     if (isset($msg['from'])) {
         $msg['from_email'] = $msg['from'];
         unset($msg['from']);
     }
     if (!is_array($msg['to'])) {
         $msg['to'] = array(array('email' => $msg['to']));
     }
     return $mandrill->call('/messages/send', array('message' => $msg));
 }