private static function sendSlackMessage($message, $channel)
    {
        // do not send Slack messages in test mode for now
        // @todo Trap these for testing
        if (Director::isTest()) {
            return;
        }

        $hooksFromConfig = Config::inst()->get('Suilven\Notifier\Notify', 'slack_webhooks');

        // optionally override the channel
        $channelOverride = Config::inst()->get('Suilven\Notifier\Notify', 'channel_override');
        if (!empty($channelOverride)) {
            $channel = $channelOverride;
        }

        // get the appropriate webhook
        $url = null;

        if (!empty($hooksFromConfig)) {
            foreach($hooksFromConfig as $hook)
            {
                // stick with the default webhook but allow overriding on a per channel basis
                if ($hook['name'] == $channel)
                {
                    $url = $hook['url'];
                } elseif (empty($url) && $hook['name'] == 'default') {
                    $url = $hook['url'];
                }
            }
        }


        // Log an error if Slack config misconfigured
        if (empty($url)) {
            Injector::inst()->get(LoggerInterface::class)->error('The slack channel ' . $channel . ' has no webhook');
            return;
        }

        // create job
        $job = new NotifyViaSlackJob();
        $job->webhookURL = $url;
        $job->message = $message;
        $job->channel = $channel;

        // place on queue
        singleton(QueuedJobService::class)->queueJob($job);
    }
private static function sendSlackMessage($message, $channel)
    {
        // do not send Slack messages in test mode for now
        // @todo Trap these for testing
        if (Director::isTest()) {
            return;
        }

        $hooksFromConfig = Config::inst()->get('Suilven\Notifier\Notify', 'slack_webhooks');

        // optionally override the channel
        $channelOverride = Config::inst()->get('Suilven\Notifier\Notify', 'channel_override');
        if (!empty($channelOverride)) {
            $channel = $channelOverride;
        }

        // get the appropriate webhook
        $url = null;

        if (!empty($hooksFromConfig)) {
            foreach($hooksFromConfig as $hook)
            {
                // stick with the default webhook but allow overriding on a per channel basis
                if ($hook['name'] == $channel)
                {
                    $url = $hook['url'];
                } elseif (empty($url) && $hook['name'] == 'default') {
                    $url = $hook['url'];
                }
            }
        }


        // Log an error if Slack config misconfigured
        if (empty($url)) {
            Injector::inst()->get(LoggerInterface::class)->error('The slack channel ' . $channel . ' has no webhook');
            return;
        }

        // create job
        $job = new NotifyViaSlackJob();
        $job->webhookURL = $url;
        $job->message = $message;
        $job->channel = $channel;

        // place on queue
        singleton(QueuedJobService::class)->queueJob($job);
    }
private static function sendSlackMessage ( $ message , $ channel ) { // do not send Slack messages in test mode for now // @todo Trap these for testing if ( Director :: isTest ( ) ) { return ; } $ hooksFromConfig = Config :: inst ( ) -> get ( 'Suilven\Notifier\Notify' , 'slack_webhooks' ) ; // optionally override the channel $ channelOverride = Config :: inst ( ) -> get ( 'Suilven\Notifier\Notify' , 'channel_override' ) ; if ( ! empty ( $ channelOverride ) ) { $ channel = $ channelOverride ; } // get the appropriate webhook $ url = null ; if ( ! empty ( $ hooksFromConfig ) ) { foreach ( $ hooksFromConfig as $ hook ) { // stick with the default webhook but allow overriding on a per channel basis if ( $ hook [ 'name' ] == $ channel ) { $ url = $ hook [ 'url' ] ; } elseif ( empty ( $ url ) && $ hook [ 'name' ] == 'default' ) { $ url = $ hook [ 'url' ] ; } } } // Log an error if Slack config misconfigured if ( empty ( $ url ) ) { Injector :: inst ( ) -> get ( LoggerInterface :: class ) -> error ( 'The slack channel ' . $ channel . ' has no webhook' ) ; return ; } // create job $ job = new NotifyViaSlackJob ( ) ; $ job -> webhookURL = $ url ; $ job -> message = $ message ; $ job -> channel = $ channel ; // place on queue singleton ( QueuedJobService :: class ) -> queueJob ( $ job ) ; }
Note to self - Slack Webhook URLs have a default channel, but can be configured to send to any
BackTrace class has an error generator

Use $client->to($channel)->send($message);

@param $message
@param $channel
Note to self - Slack Webhook URLs have a default channel but can be configured to send to any BackTrace class has an error generator