@@ 49-67 (lines=19) @@ | ||
46 | } |
|
47 | } |
|
48 | ||
49 | public function detectNodeSlug(Ajde_Core_Route $route) |
|
50 | { |
|
51 | $slug = $route->getRoute(); |
|
52 | ||
53 | $slug = trim($slug, '/'); |
|
54 | $lastSlash = strrpos($slug, '/'); |
|
55 | if ($lastSlash !== false) { |
|
56 | $slug = substr($slug, $lastSlash + 1); |
|
57 | } |
|
58 | ||
59 | $node = NodeModel::fromSlug($slug); |
|
60 | if ($node) { |
|
61 | $this->_detectedNode = $node; |
|
62 | $route->setRoute($slug); |
|
63 | $routes = config('routes.list'); |
|
64 | array_unshift($routes, ['%^('.preg_quote($slug).')$%' => ['slug']]); |
|
65 | Config::set('routes.list', $routes); |
|
66 | } |
|
67 | } |
|
68 | ||
69 | public function detectShopSlug(Ajde_Core_Route $route) |
|
70 | { |
|
@@ 69-86 (lines=18) @@ | ||
66 | } |
|
67 | } |
|
68 | ||
69 | public function detectShopSlug(Ajde_Core_Route $route) |
|
70 | { |
|
71 | $slug = $route->getRoute(); |
|
72 | ||
73 | $slug = trim($slug, '/'); |
|
74 | $lastSlash = strrpos($slug, '/'); |
|
75 | if ($lastSlash !== false) { |
|
76 | $lastSlugPart = substr($slug, $lastSlash + 1); |
|
77 | ||
78 | $product = ProductModel::fromSlug($lastSlugPart); |
|
79 | if ($product) { |
|
80 | $route->setRoute($slug); |
|
81 | $routes = config('routes.list'); |
|
82 | array_unshift($routes, ['%^(shop)/('.preg_quote($lastSlugPart).')$%' => ['module', 'slug']]); |
|
83 | Config::set('routes.list', $routes); |
|
84 | } |
|
85 | } |
|
86 | } |
|
87 | ||
88 | /** |
|
89 | * @return NodeModel|bool |