[李景山php]每天laravel-20161112|Factory-3.php
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[李景山php]每天laravel-20161112|Factory-3.php相关的知识,希望对你有一定的参考价值。
/** * Parse a class based composer name. * * @param string $class * @param string $prefix * @return array */ protected function parseClassEvent($class, $prefix) {//Parse a class based composer name. if (Str::contains($class, ‘@‘)) { return explode(‘@‘, $class); }// this is contains type $method = Str::contains($prefix, ‘composing‘) ? ‘compose‘ : ‘create‘;// get method from prefix return [$class, $method];// return a array combine by class and method } /** * Call the composer for a given view. * * @param \Illuminate\Contracts\View\View $view * @return void */ public function callComposer(View $view) { $this->events->fire(‘composing: ‘.$view->getName(), [$view]);// start a view }//call the composer for a given view /** * Call the creator for a given view. * * @param \Illuminate\Contracts\View\View $view * @return void */ public function callCreator(View $view) { $this->events->fire(‘creating: ‘.$view->getName(), [$view]);//fire the creating }// call the creator for a given view. /** * Start injecting content into a section. * * @param string $section * @param string $content * @return void */ public function startSection($section, $content = ‘‘) {//start injecting content into a section if ($content === ‘‘) {// if null to get the content if (ob_start()) { $this->sectionStack[] = $section; } } else { $this->extendSection($section, $content);// set the extend } } /** * Inject inline content into a section. * * @param string $section * @param string $content * @return void */ public function inject($section, $content) { return $this->startSection($section, $content);// inject content to section }//Inject inline content into a section. // inject something to a object /** * Stop injecting content into a section and return its contents. * * @return string */ public function yieldSection() {// return the inject if (empty($this->sectionStack)) { return ‘‘; }// if all just null // inject itself return $this->yieldContent($this->stopSection()); // first to inject the Section // and yield it }// else stop inject this contents /** * Stop injecting content into a section. * * @param bool $overwrite * @return string * @throws \InvalidArgumentException */ public function stopSection($overwrite = false) {// stop injecting content into a section if (empty($this->sectionStack)) { throw new InvalidArgumentException(‘Cannot end a section without first starting one.‘); }// if the container is null $last = array_pop($this->sectionStack);// get this last options if ($overwrite) {// if overwrite $this->sections[$last] = ob_get_clean();// rewrite it } else { $this->extendSection($last, ob_get_clean());// add and append } return $last; }// return this last thing // stop just like to get it back /** * Stop injecting content into a section and append it. * * @return string * @throws \InvalidArgumentException */ public function appendSection() {//Stop injecting content into a section and append it if (empty($this->sectionStack)) { throw new InvalidArgumentException(‘Cannot end a section without first starting one.‘); }// null $last = array_pop($this->sectionStack);// last thing if (isset($this->sections[$last])) { $this->sections[$last] .= ob_get_clean(); } else { $this->sections[$last] = ob_get_clean(); }// this last return $last;// return }// i think stop this world is not too good /** * Append content to a given section. * * @param string $section * @param string $content * @return void */ protected function extendSection($section, $content) { if (isset($this->sections[$section])) { $content = str_replace(‘@parent‘, $content, $this->sections[$section]); }// set the section // like get the key,to unlock this thing $this->sections[$section] = $content;// set te sections }//Append content to a given section /** * Get the string contents of a section. * * @param string $section * @param string $default * @return string */ public function yieldContent($section, $default = ‘‘) {//Get the string contents of a section. $sectionContent = $default;// set the default if (isset($this->sections[$section])) { $sectionContent = $this->sections[$section]; }// level 2 to set it again,like a bitch, or right? $sectionContent = str_replace(‘@@parent‘, ‘--parent--holder--‘, $sectionContent);//get you want surface return str_replace( ‘--parent--holder--‘, ‘@parent‘, str_replace(‘@parent‘, ‘‘, $sectionContent) );// return a str_replace the } /** * Flush all of the section contents. * * @return void */ public function flushSections() { $this->renderCount = 0;//set render $this->sections = [];// set sections $this->sectionStack = [];// set this store }//Flush all of the section contents /** * Flush all of the section contents if done rendering. * * @return void */ public function flushSectionsIfDoneRendering() { if ($this->doneRendering()) { $this->flushSections(); }// something }//Flush all of the section contents if done rendering // flush render /** * Increment the rendering counter. * * @return void */ public function incrementRender() { $this->renderCount++;// plus and plus }// Increment the rendering counter /** * Decrement the rendering counter. * * @return void */ public function decrementRender() { $this->renderCount--;// reduce this count }// /** * Check if there are no active render operations. * * @return bool */ public function doneRendering() { return $this->renderCount == 0; }// donRendering to init this count /** * Add a location to the array of view locations. * * @param string $location * @return void */ public function addLocation($location) { $this->finder->addLocation($location);//add Location }//Add a location to the array of view locations /** * Add a new namespace to the loader. * * @param string $namespace * @param string|array $hints * @return void */ public function addNamespace($namespace, $hints) { $this->finder->addNamespace($namespace, $hints);// add Name space }//Add a new namespace to the loader /** * Prepend a new namespace to the loader. * * @param string $namespace * @param string|array $hints * @return void */ public function prependNamespace($namespace, $hints) { $this->finder->prependNamespace($namespace, $hints);// prepend }// Prepend a new namespace to te loader /** * Register a valid view extension and its engine. * * @param string $extension * @param string $engine * @param \Closure $resolver * @return void */ public function addExtension($extension, $engine, $resolver = null) {// Register a valid view extension and its engine. $this->finder->addExtension($extension);// add Extension if (isset($resolver)) {// set the resolver $this->engines->register($engine, $resolver); }// set the register unset($this->extensions[$extension]);// unset the extension $this->extensions = array_merge([$extension => $engine], $this->extensions); }// this extensions /** * Get the extension to engine bindings. * * @return array */ public function getExtensions() { return $this->extensions; }// Get the extension to engine bindings /** * Get the engine resolver instance. * * @return \Illuminate\View\Engines\EngineResolver */ public function getEngineResolver() { return $this->engines; }//Get the engine resolver instance /** * Get the view finder instance. * * @return \Illuminate\View\ViewFinderInterface */ public function getFinder() { return $this->finder; }//Get the view finder instance. /** * Set the view finder instance. * * @param \Illuminate\View\ViewFinderInterface $finder * @return void */ public function setFinder(ViewFinderInterface $finder) { $this->finder = $finder; }//set Finder /** * Get the event dispatcher instance. * * @return \Illuminate\Contracts\Events\Dispatcher */ public function getDispatcher() { return $this->events; }//get Dispatcher /** * Set the event dispatcher instance. * * @param \Illuminate\Contracts\Events\Dispatcher $events * @return void */ public function setDispatcher(Dispatcher $events) { $this->events = $events; }//set instance /** * Get the IoC container instance. * * @return \Illuminate\Contracts\Container\Container */ public function getContainer() { return $this->container; }//get Container /** * Set the IoC container instance. * * @param \Illuminate\Contracts\Container\Container $container * @return void */ public function setContainer(Container $container) { $this->container = $container; }//set Container /** * Get an item from the shared data. * * @param string $key * @param mixed $default * @return mixed */ public function shared($key, $default = null) { return Arr::get($this->shared, $key, $default); }//shared //Arr::get /** * Get all of the shared data for the environment. * * @return array */ public function getShared() { return $this->shared; }// get Shared /** * Check if section exists. * * @param string $name * @return bool */ public function hasSection($name) { return array_key_exists($name, $this->sections); }// has Section /** * Get the entire array of sections. * * @return array */ public function getSections() { return $this->sections; }// get Sections /** * Get all of the registered named views in environment. * * @return array */ public function getNames() { return $this->names; }// return name }
本文出自 “专注php 群号:414194301” 博客,请务必保留此出处http://jingshanls.blog.51cto.com/3357095/1850948
以上是关于[李景山php]每天laravel-20161112|Factory-3.php的主要内容,如果未能解决你的问题,请参考以下文章
[李景山php]每天laravel-20161028|Translator.php
[李景山php]每天laravel-20161107|PhpEngine.php
[李景山php]每天laravel-20161106|EngineResolver.php
[李景山php]每天laravel-20161108|ShareErrorsFromSession.php