> 백엔드 개발 > PHP 튜토리얼 > [리징산 php]daily laravel-20160906|Dispatcher-6

[리징산 php]daily laravel-20160906|Dispatcher-6

WBOY
풀어 주다: 2016-07-28 08:29:34
원래의
1461명이 탐색했습니다.

<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 튜토리얼에 관심있는 친구들에게 도움이 되었으면 좋겠습니다.

관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿