public static function getRoute(Query $config) { // Get the route unserializing the query (if possible) $serializedRoute = json_decode($config->getQuery(), true); if ($serializedRoute !== null) { $params = []; if (isset($serializedRoute['params']) && is_array($serializedRoute['params'])) { // Unserialize models if there are ones foreach ($serializedRoute['params'] as $key => $value) { $params[$key] = ModelFactory::isModel($value) ? ModelFactory::getModel($value) : $value; } } return new Route($serializedRoute['controller'], $serializedRoute['action'], $params); } else { $routes = static::getInstance()->routes; foreach ($routes as $route) { $params = static::urlMatch($route['path'], $config->getQuery()); if ($params !== false) { return new Route($route['definition']['controller'], $route['definition']['action'], $params); } } } return false; }
public function getImByUser(\AlfredSlack\Models\UserModel $user) { $userId = $user->getId(); // Get the IM id if a user $ims = $this->getIms(true); $im = Utils::find($ims, ['user' => $userId]); if (empty($im)) { $im = $this->openIm($user); } return ModelFactory::getModel($im, '\\AlfredSlack\\Models\\ImModel'); }