/** * Get the addon routes. * * @return array */ public function getRoutes() { $routes = []; foreach (glob($this->addon->getPath('resources/routes/*')) as $include) { $include = (require $include); if (!is_array($include)) { continue; } $routes = array_merge($include, $routes); } return array_merge($this->routes, $routes); }
/** * Get the override view path. * * @param $view * @return null|string */ public function getOverloadPath(View $view) { /** * We can only overload namespaced * views right now. */ if (!str_contains($view->getName(), '::')) { return null; } /** * Split the view into it's * namespace and path. */ list($namespace, $path) = explode('::', $view->getName()); $path = str_replace('.', '/', $path); /** * If the module is shorthand * then check to see if we have * an active module to use for it. */ if ($namespace === 'module' && $this->module) { $namespace = $this->module->getNamespace(); } /** * If the view is already in * the theme then skip it. */ if ($namespace == 'theme' || str_is('*.theme.*', $namespace)) { return null; } /** * If the view is a streams view then * it's real easy to guess what the * override path should be. */ if ($namespace == 'streams') { $path = $this->theme->getNamespace('streams/' . $path); } /** * If the view uses a dot syntax namespace then * transform it all into the override view path. */ if ($addon = $this->addons->get($namespace)) { $path = $this->theme->getNamespace("addons/{$addon->getVendor()}/{$addon->getSlug()}-{$addon->getType()}/" . $path); } if ($this->view->exists($path)) { return $path; } /** * If the view uses a dot syntax namespace then * transform it all into the override view path. * * @deprecated since v3.0.0 */ if ($addon) { $path = $this->theme->getNamespace("addon/{$addon->getVendor()}/{$addon->getSlug()}-{$addon->getType()}/" . $path); } if ($this->view->exists($path)) { return $path; } return null; }