示例#1
0
 /**
  * Build static cache
  *
  * @return void
  */
 public function cmd_static()
 {
     \System\Init::basic();
     $lib_list = \System\Composer::get_libs();
     $libs = array();
     foreach ($lib_list as $lib) {
         $libs[$lib] = $lib;
     }
     array_push($libs, null);
     \Helper\Cli::do_over($libs, function ($key, $name) {
         \System\Cache::build_static_for($name);
     }, 'Collecting static files');
 }
示例#2
0
 public function cmd_lostAndFound()
 {
     \System\Init::full();
     $users = \Workshop\SignUp::get_all()->where(array("solved" => true, "newsletter" => true, "sentLostAndFound" => false))->fetch();
     \Helper\Cli::do_over($users, function ($key, $user) {
         $ren = new \System\Template\Renderer\Txt();
         $ren->reset_layout();
         $ren->partial('mail/notif/lost-and-found', array("user" => $user, "symvar" => $user->check->symvar));
         $mail = new \Helper\Offcom\Mail(array('rcpt' => array($user->email), 'subject' => 'Improtřesk 2016 - Ztráty a nálezy, pozvánka', 'reply_to' => \System\Settings::get('offcom', 'default', 'reply_to'), 'message' => $ren->render_content()));
         $mail->send();
         $user->sentLostAndFound = true;
         $user->save();
     });
 }
示例#3
0
文件: db.php 项目: just-paja/fudjan
 private static function seed_data($data_set_name, $data_set_models)
 {
     \System\Init::full();
     foreach ($data_set_models as $model => $data_set) {
         $extra = array("model" => $model);
         \Helper\Cli::do_over($data_set, function ($key, $tdata, $extra) {
             $model = $extra['model'];
             $obj = null;
             $idc = $model::get_id_col($model);
             if (isset($tdata[$col = 'id']) || isset($tdata[$col = $idc])) {
                 $tdata[$idc] = $tdata[$col];
                 $obj = $model::find($tdata[$col]);
             }
             if ($obj) {
                 $obj->update_attrs($tdata);
             } else {
                 $obj = new $model($tdata);
                 $obj->is_new_object = true;
             }
             $obj->save();
             foreach ($tdata as $attr => $val) {
                 if (is_array($val) && $model::is_rel($attr)) {
                     if ($model::get_attr_type($attr) == $model::REL_HAS_MANY) {
                         $def = $model::get_attr($attr);
                         if (any($def['is_bilinear']) && any($def['is_master'])) {
                             unset($obj->{$attr});
                             $obj->{$attr} = $val;
                         }
                     }
                 }
             }
         }, $data_set_name . ': ' . \System\Loader::get_model_from_class($model), $extra);
     }
 }