[李景山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
}
时间: 2024-08-28 12:47:13

[李景山php]每天laravel-20161112|Factory-3.php的相关文章

[李景山php]每天laravel-20161110|Factory.php

<?php namespace Illuminate\View; use Closure; use Illuminate\Support\Arr; use Illuminate\Support\Str; use InvalidArgumentException; use Illuminate\Contracts\Support\Arrayable; use Illuminate\View\Engines\EngineResolver; use Illuminate\Contracts\Event

[李景山php]每天laravel-20161108|ShareErrorsFromSession.php

<?php namespace Illuminate\View\Middleware; use Closure; use Illuminate\Support\ViewErrorBag; use Illuminate\Contracts\View\Factory as ViewFactory; class ShareErrorsFromSession {     /**      * The view factory implementation.      *      * @var \Ill

Laravel Model Factory(模型工厂)的用法以及数据本地化

Model Factory的位置 生成数据方法:make是生成数据,create是生成数据并保存到数据库 本地化方法 这样便生成了中文数据 整理自www.laravist.com视频教程

[李景山php]每天laravel-20160920|Writer-2

    //2016-07-20     /**      * Register a file log handler.      *      * @param  string  $path      * @param  string  $level      * @return void      */     public function useFiles($path, $level = 'debug')     {         $this->monolog->pushHandle

[李景山php]每天laravel-20160831|EventServiceProvider

<?php namespace Illuminate\Events; use Illuminate\Support\ServiceProvider; class EventServiceProvider extends ServiceProvider {// Event Service Provider extends Service Provider     /**      * Register the service provider.      *      * @return void

[李景山php]每天laravel-20161115|View.php

<?php namespace Illuminate\View; use Exception; use Throwable; use ArrayAccess; use BadMethodCallException; use Illuminate\Support\Str; use Illuminate\Support\MessageBag; use Illuminate\Contracts\Support\Arrayable; use Illuminate\View\Engines\EngineI

[李景山php]每天laravel-20161109|ViewServiceProvider.php

<?php namespace Illuminate\View; use Illuminate\View\Engines\PhpEngine; use Illuminate\Support\ServiceProvider; use Illuminate\View\Engines\CompilerEngine; use Illuminate\View\Engines\EngineResolver; use Illuminate\View\Compilers\BladeCompiler; // co

[李景山php]每天laravel-20161021|Request.php-2

/**  * Determine if the current request URL and query string matches a pattern.  *  * @param  mixed  string  * @return bool  */ public function fullUrlIs() {// check string like URL     $url = $this->fullUrl();     foreach (func_get_args() as $patter

[李景山php]每天laravel-20160914|FileSystemManager-1

namespace Illuminate\Filesystem; use Closure; use Aws\S3\S3Client; use OpenCloud\Rackspace; use Illuminate\Support\Arr; use InvalidArgumentException; use League\Flysystem\AdapterInterface; use League\Flysystem\FilesystemInterface; use League\Flysyste

[李景山php]每天laravel-20161103|CompilerEngine.php-2

    /**      * Handle a view exception.      *      * @param  \Exception  $e      * @param  int  $obLevel      * @return void      *      * @throws $e      */     protected function handleViewException(Exception $e, $obLevel)     {         $e = new E