287 ->join(ProductMetadata::class, 't1.product = p.id AND t1.language = "' . $language . '"')
288 ->leftJoin(CategoryMetadata::class, 't2.category = p.category AND t2.language = "' . $language . '"')
289 ->leftJoin(Category::class, 't3.id = p.category')
290 ->leftJoin(CategoryMetadata::class, 't4.category = t3.parent AND t2.language = "' . $language . '"')
291 ->leftJoin(Developer::class, 't5.id = p.developer')
292 ->leftJoin(ProductRate::class, 't6.product = p.id')
293 ->leftJoin(ProductRate::class, 't7.product = p.id AND t7.ip = ' . pure_int(request()->getIp()))
294 ->leftJoin(ContentWriter::class, 't8.id = p.editor')
295 ->leftJoin(ContentWriter::class, 't9.id = t1.translator')
296 ->leftJoin(ProductVersion::class, 't10.product = p.id')
297 ->leftJoin(Product::class, 't11.slug = "' . $slug . '"')
298 ->where(['p.slug' => $slug, 'p.type' => Product::TYPE[$type], 'p.platform' => Product::PLATFORM[$platform]])
299 ->fetch(\PDO::FETCH_ASSOC)
303 if ($product_arr === false) {
307 $product = new ProductHtml;
308 $product->load($product_arr);
310 $product->category = (new Category)->load([
311 'id' => $product->category,
44 return array_values($inputs);
47 protected function loadClass($callback, array $params = [])
49 if (is_array($callback) && !method_exists($callback[0], $callback[1])) {
50 throw new Exception('Method: ' . $callback[1] . ' does not exists in Class: ' . get_class($callback[0]));
53 return call_user_func($callback, ...$params);
56 protected function createClass(string $class, ...$args)
58 return new $class(...$args);
55 } elseif ($method === 'post') {
56 $callback[1] = 'store';
57 } elseif ($method === 'get' && isset($params[$action])) {
58 $callback[1] = 'show';
60 $callback[1] = 'index';
65 request()->setRoute($route);
67 return $this->loadClass($callback, $this->reflectParamiters($this->excapeParamiters($route->getParameters()), (is_array($callback) ? [$callback[0]::class, $callback[1]] : $callback)));
70 protected function callMiddlewares($middlewares): void
72 foreach ((array) $middlewares as $middleware) {
74 $class = $this->createClass($middleware);
76 if (!$class instanceof IMiddleware) {
77 throw new MiddlewareException($middleware . ' must be implement interface: ' . IMiddleware::class);
80 $this->loadClass([$class, 'handle'], $this->reflectParamiters([], [$middleware, 'handle']));
49 // call route middlewares
50 $this->callMiddlewares($route->getMiddlewares());
52 // utilize method required paramiters
53 $params = $this->utilizeRouteParam($matches, $route);
55 // set router paramiters
56 if (!empty($params)) {
57 $route->parameters($this->reflectParamiters($params, $route->getCallback()));
60 // dispatch route callback
61 return $this->dispatchRoute($route);
65 // not found any route for this path
66 // throw new NotFoundException('the route does not matched..');
70 public function route(string $name, $params = null): IRoute
72 foreach ($this->getRoutes() as $single_route) {
73 if (in_array($name, (array) $single_route->getName())) {
129 $this->triggerEvent(self::EVENT['created']);
132 public function run(): void
134 // Before Application Start Event
135 $this->triggerEvent(self::EVENT['beforeMount']);
137 // Start Application Route
138 echo $this->router->resolve();
140 // After Application Start Event
141 $this->triggerEvent(self::EVENT['mounted']);
144 public function getAuth(): Auth
146 if (!isset($this->auth)) {
147 $this->auth = new Auth;
29 // <div style="background:#000;color:#fff;padding:10px 20px;">
30 // <h3 style="font-size:25px;font-style: italic;color:blue;"></h3>
31 // <div style="border-bottom:1px solid rgba(255,255,255,0.25);padding:10px;margin-bottom:15px;">App Execution Has Started: {$started}</div>
32 // <div style="border-bottom:1px solid rgba(255,255,255,0.25);padding:10px;margin-bottom:15px;">App Execution Has End: {$end}</div>
33 // <div style="border-bottom:1px solid rgba(255,255,255,0.25);padding:10px;margin-bottom:15px;">App Total Execution: {$total}</div>
38 // run the application