public function send($notification, array $channels = null){
        if($channels === null){
            $channels = array_keys($this->channels);
        }

        foreach ((array)$channels as $id) {
            $channel = $this->getChannel($id);
            if(!$notification->shouldSend($channel)){
                continue;
            }

            $handle = 'to'.ucfirst($id);
            try {
                if($notification->hasMethod($handle)){
                    call_user_func([clone $notification, $handle], $channel);
                }
                else {
                    $channel->send(clone $notification);
                }
            } catch (\Exception $e) {
                Yii::warning("Notification sended by channel '$id' has failed: " . $e->getMessage(), __METHOD__);
            }
        }
    }
public function send($notification, array $channels = null){
        if($channels === null){
            $channels = array_keys($this->channels);
        }

        foreach ((array)$channels as $id) {
            $channel = $this->getChannel($id);
            if(!$notification->shouldSend($channel)){
                continue;
            }

            $handle = 'to'.ucfirst($id);
            try {
                if($notification->hasMethod($handle)){
                    call_user_func([clone $notification, $handle], $channel);
                }
                else {
                    $channel->send(clone $notification);
                }
            } catch (\Exception $e) {
                Yii::warning("Notification sended by channel '$id' has failed: " . $e->getMessage(), __METHOD__);
            }
        }
    }
public function send ( $ notification , array $ channels = null ) { if ( $ channels === null ) { $ channels = array_keys ( $ this -> channels ) ; } foreach ( ( array ) $ channels as $ id ) { $ channel = $ this -> getChannel ( $ id ) ; if ( ! $ notification -> shouldSend ( $ channel ) ) { continue ; } $ handle = 'to' . ucfirst ( $ id ) ; try { if ( $ notification -> hasMethod ( $ handle ) ) { call_user_func ( [ clone $ notification , $ handle ] , $ channel ) ; } else { $ channel -> send ( clone $ notification ) ; } } catch ( \ Exception $ e ) { Yii :: warning ( "Notification sended by channel '$id' has failed: " . $ e -> getMessage ( ) , __METHOD__ ) ; } } }
Send a notification to all channels

@param Notification $notification
@param array|null $channels
@return Channel|null return the channel
Send a notification to all channels