<?php namespace Illuminate\Pipeline; use Closure; use Illuminate\Contracts\Container\Container; use Illuminate\Contracts\Pipeline\Hub as HubContract; // amespace class Hub implements HubContract {// Class Hub implements HubContract /** * The container implementation. * * @var \Illuminate\Contracts\Container\Container */ protected $container;// The container implementation /** * All of the available pipelines. * * @var array */ protected $pipelines = [];//All of the available pipelines. /** * Create a new Hub instance. * * @param \Illuminate\Contracts\Container\Container $container * @return void */ public function __construct(Container $container) { $this->container = $container; }// Create a new Hub instance // use this parameter as container /** * Define the default named pipeline. * * @param \Closure $callback * @return void */ public function defaults(Closure $callback) { return $this->pipeline('default', $callback);//set default }//Define the default named pipeline /** * Define a new named pipeline. * * @param string $name * @param \Closure $callback * @return void */ public function pipeline($name, Closure $callback) { $this->pipelines[$name] = $callback;// this pipelines be set }//Define a new named pipeline. /** * Send an object through one of the available pipelines. * * @param mixed $object * @param string|null $pipeline * @return mixed */ public function pipe($object, $pipeline = null) { $pipeline = $pipeline ?: 'default'; return call_user_func( $this->pipelines[$pipeline], new Pipeline($this->container), $object );// just call a function use instanceof Pipeline }//Send an object through }
[李景山php]每天laravel-20160923|Hub.php
原创
©著作权归作者所有:来自51CTO博客作者lijingsan1的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章