/** * Handle the command. * * @param Application $application * @param Factory $views */ public function handle(Application $application, Factory $views) { $views->composer('*', 'Anomaly\\Streams\\Platform\\View\\ViewComposer'); $views->addNamespace('streams', __DIR__ . '/../../../resources/views'); $views->addNamespace('resources', base_path('resources/views')); $views->addNamespace('storage', $application->getStoragePath()); $views->addNamespace('app', $application->getResourcesPath()); $views->addNamespace('root', base_path()); $views->addExtension('html', 'php'); }
/** * Load subview from direct path. * * @param string $view * @param array $args * @return Theme */ public function load($view, $args = array()) { $view = ltrim($view, '/'); $segments = explode('/', str_replace('.', '/', $view)); // Pop file from segments. $view = array_pop($segments); // Custom directory path. $pathOfView = app('path.base') . '/' . implode('/', $segments); // Add temporary path with a hint type. $this->view->addNamespace('custom', $pathOfView); return $this->of('custom::' . $view, $args); }
/** * Load subview from direct path. * * @param string $view * @param array $args * @return Theme */ public function load($view, $args = array()) { $view = ltrim($view, '/'); $segments = explode('/', str_replace('.', '/', $view)); // Pop file from segments. $view = array_pop($segments); // Custom directory path. $pathOfView = app('path.base') . '/' . implode('/', $segments); //dd($pathOfView); try { // Add temporary path with a hint type. $this->view->addNamespace('custom', $pathOfView); return $this->of('custom::' . $view, $args); } catch (\InvalidArgumentException $e) { throw new \Exception('View ' . $pathOfView . ' not found.', 1); } }
/** * Add a new namespace to the loader. * * @param string $namespace * @param string|array $hints * @return void * @static */ public static function addNamespace($namespace, $hints) { \Illuminate\View\Factory::addNamespace($namespace, $hints); }
private function viewsBaseFolder() { $this->view->addNamespace('Comments', __DIR__ . "/../views"); }
/** * Setup the pagination environment. * * @return void */ protected function setupPaginationEnvironment() { $this->view->addNamespace('pagination', __DIR__ . '/views'); }
private function viewsBaseFolder() { $this->view->addNamespace('NewsLetter', __DIR__ . "/../views"); }
private function viewsBaseFolder() { $this->view->addNamespace('UserManagement', __DIR__ . "/../views"); }
private function viewsBaseFolder() { $this->view->addNamespace('Striped', __DIR__ . "/../views"); }
private function viewsBaseFolder() { $this->view->addNamespace('FileManager', __DIR__ . "/../views"); }
/** * Bootstrap the application services. * * @param Factory $view The vue factory */ public function boot(Factory $view, DatabaseManager $db) { $this->publishes([__DIR__ . '/config' => base_path('config')], 'alexvanvliet-viewnamespaces-config'); $this->publishes([__DIR__ . '/views' => base_path('resources/views')], 'alexvanvliet-viewnamespaces-views'); // Si la config existe if ($namespaces = config('viewnamespaces.namespaces')) { // On parcourt tous les namespaces foreach ($namespaces as $namespace => $options) { // Si c'est bien un tableau if (is_array($options)) { // Si le chemin par défaut existe if (isset($options['default']) && is_string($options['default'])) { // S'il y a une définition dynamique du chemin if (isset($options['dynamic']) && is_array($options['dynamic'])) { $dynamic = $options['dynamic']; // Si on a bien le type de la définition dynamique if (isset($dynamic['type']) && is_string($dynamic['type'])) { $added = false; switch ($dynamic['type']) { // Si c'est une définition par recherche dans la DB case 'sql': // Si la requête existe if (isset($dynamic['request']) && is_string($dynamic['request'])) { // On récupère la requête dans la DB $values = $db->select($dynamic['request']); // Si on a trouvé des valeurs if (count($values)) { // On prend la première $values = $values[0]; // Si on a définit un champ, on l'utilise sinon on prend par défaut if (isset($dynamic['field']) && is_string($dynamic['field'])) { $path = $values->{$dynamic['field']}; } else { $path = $values->path; } // S'il y a une base if (isset($dynamic['base']) && is_string($dynamic['base'])) { $base = $dynamic['base']; // Si la base finit par / on le retire $base = rtrim($base, '/'); // Si le chemin commence par / on le retire $path = ltrim($path, '/'); // On joint les deux avec un / $path = $base . '/' . $path; } // On ajoute le namespace $view->addNamespace($namespace, base_path($path)); $added = true; } } break; // Si c'est une définition par closure // Si c'est une définition par closure case 'function': // Si la closure existe if (isset($dynamic['function']) && is_callable($dynamic['function'])) { // On lance la closure $path = $dynamic['function'](); // Si ca retourne un chemin if ($path && is_string($path)) { // S'il y a une base if (isset($dynamic['base']) && is_string($dynamic['base'])) { $base = $dynamic['base']; // Si la base finit par / on le retire $base = rtrim($base, '/'); // Si le chemin commence par / on le retire $path = ltrim($path, '/'); // On joint les deux avec un / $path = $base . '/' . $path; } // On ajoute le namespace $view->addNamespace($namespace, base_path($path)); $added = true; } } break; } // Si on n'a pas ajouté le namespace ou qu'on veut l'ajouter if (!$added || isset($dynamic['prepend']) && $dynamic['prepend']) { // On ajoute le namespace par défaut $view->addNamespace($namespace, base_path($options['default'])); } } else { // On ajoute le namespace $view->addNamespace($namespace, base_path($options['default'])); } } else { // On ajoute le namespace $view->addNamespace($namespace, base_path($options['default'])); } } } elseif (is_string($options)) { $view->addNamespace($namespace, base_path($options)); } } } }
/** * Register Views * * Adds a namespace to the 'View' instance for use with the double colon. * * @return void */ protected function registerViews() { $this->view->addNamespace(strtolower($this->name), $this->directory . '/views'); }
private function viewsBaseFolder() { $this->view->addNamespace('Admin', __DIR__ . "/../../../Themes/Admin/views"); }