public function is_module_dispatch($srvName, $modName, $to, $from) { $routes = \WMD\Models\Route::all()->where('srv_name', $srvName)->where('mod_name', $modName); // Parse results several times to organize priority // 1. FROM && TO // 2. TO && * // 3. FROM && * // 4. * && * // match FROM && TO foreach ($routes as $route) { if ($route->from == $from && $route->to == $to) { return array(true, $route->mod_params); } } // match TO && * foreach ($routes as $route) { if ($route->to == $to && $route->from == '*') { return array(true, $route->mod_params); } } // match FROM && * foreach ($routes as $route) { if ($route->from == $from && $route->to == '*') { return array(true, $route->mod_params); } } // match * && * foreach ($routes as $route) { if ($route->from == '*' && $route->to == '*') { return array(true, $route->mod_params); } } return array(false, null); }
public function run() { DB::table('routes')->delete(); $route = \WMD\Models\Route::create(['comment' => 'Tous les SMS sont envoyés à WordsCloud', 'to' => '*', 'from' => '*', 'srv_name' => 'sms', 'mod_name' => '\\WMD\\Dispatchers\\WordsCloud', 'mod_params' => '']); $route->save(); if (empty($route->id)) { error_log('ERROR: ' . var_export($route->getErrors(), true)); } }