コード例 #1
0
ファイル: ServiceController.php プロジェクト: alfhan/plansys
 public function actionStart($name, $l = 1)
 {
     $params = ['svc' => null];
     $options = [];
     if ($l == 0) {
         $options['layout'] = '//layouts/blank';
     }
     $params['id'] = ServiceManager::run($name, $_GET);
     $this->renderForm("SysServiceForm", null, $params, $options);
 }
コード例 #2
0
ファイル: ServiceManager.php プロジェクト: rizabudi/plansys
 public static function start($serviceName, $params = null)
 {
     $pid = ServiceManager::run($serviceName, $params);
     $controller = Yii::app()->controller;
     if (is_null($pid)) {
         $msg = "Service {$serviceName} not found";
         if (!is_null($controller)) {
             $controller->renderForm("SysServiceNotFound", null, ['msg' => $msg]);
         } else {
             echo $msg;
         }
     } else {
         $full = 0;
         if (isset($_GET['full'])) {
             $full = $_GET['full'];
         }
         if (!is_null($controller)) {
             $controller->redirect(['/sys/service/view', 'name' => $serviceName, 'id' => $pid, 'full' => $full]);
         } else {
             echo "OK";
         }
     }
 }
コード例 #3
0
ファイル: ServiceCommand.php プロジェクト: rizabudi/plansys
 public function actionTest()
 {
     ServiceManager::run("Test");
 }
コード例 #4
0
ファイル: Email.php プロジェクト: rizabudi/plansys
 public static function send($from, $template, $params = [], $options = [])
 {
     if (!isset(self::$instance)) {
         self::$instance = new Email();
     }
     if (is_string($from)) {
         $from = [$from];
     } else {
         array_walk_recursive($from, function (&$value) {
             if (is_string($value)) {
                 $value = htmlentities($value);
             }
         });
     }
     array_walk_recursive($params, function (&$value) {
         if (is_string($value)) {
             $value = htmlentities($value);
         }
     });
     $currentUserId = null;
     if (isset(Yii::app()->user)) {
         $currentUserId = Yii::app()->user->id;
     }
     $eb = EmailBuilder::load($template);
     $mails = [];
     foreach ($from as $key => $value) {
         $email = $key;
         if (is_numeric($key)) {
             $email = $value;
         }
         ## merge local parameters
         if (is_array($value)) {
             $params = array_merge($params, $value);
         }
         $params['to'] = $email;
         $params['isPreview'] = false;
         if (!self::$instance->validator->validateValue($email)) {
             ## when email is not valid, fails silently...
             continue;
         }
         $html = $eb->render($params);
         $mails[] = ['subject' => $eb->subject, 'body' => $html, 'to' => $email];
     }
     ServiceManager::run('SendEmail', ['mails' => $mails]);
 }