[李景山php]每天laravel-20161114|FileViewFinder-2.php
来源:互联网 发布:js 遍历数组 编辑:程序博客网 时间:2024/05/16 15:02
/** * Get the path to a template with a named path. * * @param string $name * @return string */ protected function findNamedPathView($name) { list($namespace, $view) = $this->getNamespaceSegments($name);// get this namespace and view return $this->findInPaths($view, $this->hints[$namespace]);// findInPaths }// Get the path to a template with a named path /** * Get the segments of a template with a named path. * * @param string $name * @return array * * @throws \InvalidArgumentException */ protected function getNamespaceSegments($name) {// Get the segments of a template with a named path. $segments = explode(static::HINT_PATH_DELIMITER, $name);// get a segments // in this segments if (count($segments) != 2) { throw new InvalidArgumentException("View [$name] has an invalid name."); }// if the result not like as we think, so threw exception if (! isset($this->hints[$segments[0]])) { throw new InvalidArgumentException("No hint path defined for [{$segments[0]}]."); }// if no hints , we will throw Exception return $segments;// return segments } /** * Find the given view in the list of paths. * * @param string $name * @param array $paths * @return string * * @throws \InvalidArgumentException */ protected function findInPaths($name, $paths) {//Find the given view in the list of paths. foreach ((array) $paths as $path) { foreach ($this->getPossibleViewFiles($name) as $file) { if ($this->files->exists($viewPath = $path.'/'.$file)) { return $viewPath;// if find it just return } }// get Possible View Files }// loop path throw new InvalidArgumentException("View [$name] not found.");// default throw Exception } /** * Get an array of possible view files. * * @param string $name * @return array */ protected function getPossibleViewFiles($name) {//get Possible View Files return array_map(function ($extension) use ($name) { return str_replace('.', '/', $name).'.'.$extension; }, $this->extensions);// two powerfull }//Get an array of possible view files. /** * Add a location to the finder. * * @param string $location * @return void */ public function addLocation($location) { $this->paths[] = $location;// add location to path }//Add a location to the finder /** * Add a namespace hint to the finder. * * @param string $namespace * @param string|array $hints * @return void */ public function addNamespace($namespace, $hints) {//add a namespace hint to the finder $hints = (array) $hints;// get the array hints if (isset($this->hints[$namespace])) { $hints = array_merge($this->hints[$namespace], $hints); }// if it is isset, combine it with new hints $this->hints[$namespace] = $hints;// then reset it } /** * Prepend a namespace hint to the finder. * * @param string $namespace * @param string|array $hints * @return void */ public function prependNamespace($namespace, $hints) {//Prepend a namespace hint to the finder. $hints = (array) $hints;// get a right hints if (isset($this->hints[$namespace])) { $hints = array_merge($hints, $this->hints[$namespace]); }// this is a good way to hints $this->hints[$namespace] = $hints;// rewrite it } /** * Register an extension with the view finder. * * @param string $extension * @return void */ public function addExtension($extension) {//register an extension with the view finder. if (($index = array_search($extension, $this->extensions)) !== false) { unset($this->extensions[$index]); }// index array_unshift($this->extensions, $extension); }// add function use this system function to add it /** * Returns whether or not the view specify a hint information. * * @param string $name * @return bool */ public function hasHintInformation($name) { return strpos($name, static::HINT_PATH_DELIMITER) > 0; }// Returns whether or not the view specify a hint information. /** * Get the filesystem instance. * * @return \Illuminate\Filesystem\Filesystem */ public function getFilesystem() { return $this->files;// return files }// get the filesystem instance. /** * Get the active view paths. * * @return array */ public function getPaths() { return $this->paths; }//get paths /** * Get the namespace to file path hints. * * @return array */ public function getHints() { return $this->hints; }//get hints /** * Get registered extensions. * * @return array */ public function getExtensions() { return $this->extensions; }// get extensions}
0 0
- [李景山php]每天laravel-20161114|FileViewFinder-2.php
- [李景山php]每天laravel-20161113|FileViewFinder-1.php
- [李景山php]每天laravel-20161030|BladeCompiler-2.php
- [李景山php]每天laravel-20161111|Factory-2.php
- [李景山php]每天laravel-20160922|RedisServicProvider.php
- [李景山php]每天laravel-20160923|Hub.php
- [李景山php]每天laravel-20160924|PiplineServiceProvider.php
- [李景山php]每天laravel-20160925|Pipeline.php
- [李景山php]每天laravel-20160926|DatabasePresenceVerifier.php
- [李景山php]每天laravel-20160927|Factory.php
- [李景山php]每天laravel-20160928|PresenceVerifierInterface.php
- [李景山php]每天laravel-20160929|ValidatesWhenResolved.php
- [李景山php]每天laravel-20160930|ValidationException.php
- [李景山php]每天laravel-20161001|ValidationServiceProvider.php
- [李景山php]每天laravel-20161016|JsonResponse.php
- [李景山php]每天laravel-20161017|ResponseTrait.php
- [李景山php]每天laravel-20161017|UploadedFile.php
- [李景山php]每天laravel-20161023|Reponse.php
- mongoDB In-Memory Storage Engine
- 二进制思想以及数据的存储
- java菜鸟的成长历程 数组
- 当众责备
- jeebbs-src-v7.0版导入myeclipse步骤说明(开源论坛系统)
- [李景山php]每天laravel-20161114|FileViewFinder-2.php
- 2016-9-12
- 频率、波长、传输距离、传输速率之间的关系总结
- 如何优化tomcat配置(从内存、并发、缓存4个方面)优化
- 基于Gulp的前端自动化工程搭建
- Kubernetes容器集群中的日志系统集成实践
- transitionend 事件
- 让 Terminal/vim 使用 Solarized 配色
- Vert.x开篇