Rumah >pembangunan bahagian belakang >tutorial php >[李景山php]每天laravel-20160906|Dispatcher-6
<code><span>/** * Broadcast the given event class. * *<span> @param</span> \Illuminate\Contracts\Broadcasting\ShouldBroadcast $event *<span> @return</span> void */</span><span>protected</span><span><span>function</span><span>broadcastEvent</span><span>(<span>$event</span>)</span> {</span><span>// why use this function name is broadcast</span><span>// event class means event instance</span><span>if</span> (<span>$this</span>->queueResolver) {<span>// use this queueResolver function</span><span>$connection</span> = <span>$event</span><span>instanceof</span> ShouldBroadcastNow ? <span>'sync'</span> : <span>null</span>;<span>// determine this instance about</span><span>$queue</span> = method_exists(<span>$event</span>, <span>'onQueue'</span>) ? <span>$event</span>->onQueue() : <span>null</span>;<span>// determine method_exits</span><span>$this</span>->resolveQueue()->connection(<span>$connection</span>)->pushOn(<span>$queue</span>, <span>'Illuminate\Broadcasting\BroadcastEvent'</span>, [ <span>'event'</span> => serialize(<span>clone</span><span>$event</span>), ]);<span>// good look bad use ,maybe</span> } } <span>/** * Get all of the listeners for a given event name. * *<span> @param</span> string $eventName *<span> @return</span> array */</span><span>public</span><span><span>function</span><span>getListeners</span><span>(<span>$eventName</span>)</span> {</span><span>// Get all of the listeners for a given event name.</span><span>$wildcards</span> = <span>$this</span>->getWildcardListeners(<span>$eventName</span>);<span>// get the wild card by eventsName use this function ,that name is cardlisters</span><span>// first use eventName</span><span>if</span> (! <span>isset</span>(<span>$this</span>->sorted[<span>$eventName</span>])) { <span>$this</span>->sortListeners(<span>$eventName</span>);<span>// use this sort Listeners</span> }<span>// if isset eventsName never be sort ,</span><span>return</span> array_merge(<span>$this</span>->sorted[<span>$eventName</span>], <span>$wildcards</span>);<span>// array_merge</span> } <span>/** * Get the wildcard listeners for the event. * *<span> @param</span> string $eventName *<span> @return</span> array */</span><span>protected</span><span><span>function</span><span>getWildcardListeners</span><span>(<span>$eventName</span>)</span> {</span><span>$wildcards</span> = [];<span>// getWildcardListeners() set the listener</span><span>foreach</span> (<span>$this</span>->wildcards <span>as</span><span>$key</span> => <span>$listeners</span>) {<span>// foreach $this->wildcards as key</span><span>if</span> (Str::is(<span>$key</span>, <span>$eventName</span>)) {<span>// determine is a str</span><span>$wildcards</span> = array_merge(<span>$wildcards</span>, <span>$listeners</span>); <span>// get the array_merge</span> } } <span>return</span><span>$wildcards</span>; } <span>// first get listener,second get the wildcard listener</span></code>').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });
以上就介绍了 [李景山php]每天laravel-20160906|Dispatcher-6,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。