[李景山php]每天laravel-20160906|Dispatcher-6

    /**
     * Broadcast the given event class.
     *
     * @param  \Illuminate\Contracts\Broadcasting\ShouldBroadcast  $event
     * @return void
     */
    protected function broadcastEvent($event)
    {// why use this function name is broadcast
        // event class means event instance
        if ($this->queueResolver) {// use this queueResolver function
            $connection = $event instanceof ShouldBroadcastNow ? 'sync' : null;// determine this instance about

            $queue = method_exists($event, 'onQueue') ? $event->onQueue() : null;// determine method_exits

            $this->resolveQueue()->connection($connection)->pushOn($queue, 'Illuminate\Broadcasting\BroadcastEvent', [
                'event' => serialize(clone $event),
            ]);// good look bad use ,maybe
        }
    }

    /**
     * Get all of the listeners for a given event name.
     *
     * @param  string  $eventName
     * @return array
     */
    public function getListeners($eventName)
    {// Get all of the listeners for a given event name.
        $wildcards = $this->getWildcardListeners($eventName);// get the wild card by eventsName use this function ,that name is cardlisters
        // first use eventName
        if (! isset($this->sorted[$eventName])) {
            $this->sortListeners($eventName);// use this sort Listeners
        }// if isset eventsName never be sort ,

        return array_merge($this->sorted[$eventName], $wildcards);// array_merge
    }

    /**
     * Get the wildcard listeners for the event.
     *
     * @param  string  $eventName
     * @return array
     */
    protected function getWildcardListeners($eventName)
    {
        $wildcards = [];// getWildcardListeners() set the listener

        foreach ($this->wildcards as $key => $listeners) {// foreach $this->wildcards as key
            if (Str::is($key, $eventName)) {// determine is a str
                $wildcards = array_merge($wildcards, $listeners); // get the array_merge
            }
        }

        return $wildcards;
    }
// first get listener,second get the wildcard listener
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值